xref: /petsc/include/petscmath.h (revision 8c764dc573411afbf35bf5567601635c9334af58)
1e489efc1SBarry Smith /*
2314da920SBarry Smith 
3314da920SBarry Smith       PETSc mathematics include file. Defines certain basic mathematical
4a5057860SBarry Smith     constants and functions for working with single, double, and quad precision
5a5057860SBarry Smith     floating point numbers as well as complex single and double.
6314da920SBarry Smith 
7d382aafbSBarry Smith     This file is included by petscsys.h and should not be used directly.
8e7029fe1SSatish Balay 
9e489efc1SBarry Smith */
10e489efc1SBarry Smith 
11488ecbafSBarry Smith #if !defined(__PETSCMATH_H)
12488ecbafSBarry Smith #define __PETSCMATH_H
130a5f7794SBarry Smith #include <math.h>
140a5f7794SBarry Smith 
15014dd563SJed Brown PETSC_EXTERN MPI_Datatype MPIU_2SCALAR;
16014dd563SJed Brown PETSC_EXTERN MPI_Datatype MPIU_2INT;
17c90a1750SBarry Smith 
18314da920SBarry Smith /*
19f4ccad53SBarry Smith 
20f4ccad53SBarry Smith      Defines operations that are different for complex and real numbers;
21a5057860SBarry Smith    note that one cannot mix the use of complex and real in the same
22f4ccad53SBarry Smith    PETSc program. All PETSc objects in one program are built around the object
2398725619SBarry Smith    PetscScalar which is either always a real or a complex.
24f4ccad53SBarry Smith 
25e489efc1SBarry Smith */
26b36a9721SBarry Smith 
2759cb5930SBarry Smith #define PetscExpPassiveScalar(a) PetscExpScalar()
28c1d390e3SJed Brown #if defined(PETSC_USE_REAL_SINGLE)
29c1d390e3SJed Brown #define MPIU_REAL   MPI_FLOAT
30c1d390e3SJed Brown typedef float PetscReal;
318f1a2a5eSBarry Smith #define PetscSqrtReal(a)    sqrt(a)
32c1d390e3SJed Brown #elif defined(PETSC_USE_REAL_DOUBLE)
33c1d390e3SJed Brown #define MPIU_REAL   MPI_DOUBLE
34c1d390e3SJed Brown typedef double PetscReal;
358f1a2a5eSBarry Smith #define PetscSqrtReal(a)    sqrt(a)
36c1d390e3SJed Brown #elif defined(PETSC_USE_REAL___FLOAT128)
37574fde7bSSatish Balay #if defined(__cplusplus)
38574fde7bSSatish Balay extern "C" {
39574fde7bSSatish Balay #endif
40574fde7bSSatish Balay #include <quadmath.h>
41574fde7bSSatish Balay #if defined(__cplusplus)
42574fde7bSSatish Balay }
43574fde7bSSatish Balay #endif
44c1d390e3SJed Brown #define MPIU_REAL MPIU___FLOAT128
45c1d390e3SJed Brown typedef __float128 PetscReal;
468f1a2a5eSBarry Smith #define PetscSqrtReal(a)    sqrtq(a)
47c1d390e3SJed Brown #endif /* PETSC_USE_REAL_* */
4859cb5930SBarry Smith 
491093a601SBarry Smith /*
501093a601SBarry Smith     Complex number definitions
511093a601SBarry Smith  */
52aa482453SBarry Smith #if defined(PETSC_USE_COMPLEX)
53b7940d39SSatish Balay #if defined(PETSC_CLANGUAGE_CXX)
541093a601SBarry Smith /* C++ support of complex number */
55debe9ee2SPaul Mullowney #if defined(PETSC_HAVE_CUSP)
56debe9ee2SPaul Mullowney #define complexlib cusp
579ae82921SPaul Mullowney #include <cusp/complex.h>
58debe9ee2SPaul Mullowney #else
59debe9ee2SPaul Mullowney #define complexlib std
60debe9ee2SPaul Mullowney #include <complex>
619ae82921SPaul Mullowney #endif
62b7940d39SSatish Balay 
63debe9ee2SPaul Mullowney #define PetscRealPart(a)      (a).real()
64debe9ee2SPaul Mullowney #define PetscImaginaryPart(a) (a).imag()
65debe9ee2SPaul Mullowney #define PetscAbsScalar(a)     complexlib::abs(a)
66debe9ee2SPaul Mullowney #define PetscConj(a)          complexlib::conj(a)
67debe9ee2SPaul Mullowney #define PetscSqrtScalar(a)    complexlib::sqrt(a)
68debe9ee2SPaul Mullowney #define PetscPowScalar(a,b)   complexlib::pow(a,b)
69debe9ee2SPaul Mullowney #define PetscExpScalar(a)     complexlib::exp(a)
70debe9ee2SPaul Mullowney #define PetscLogScalar(a)     complexlib::log(a)
71debe9ee2SPaul Mullowney #define PetscSinScalar(a)     complexlib::sin(a)
72debe9ee2SPaul Mullowney #define PetscCosScalar(a)     complexlib::cos(a)
73debe9ee2SPaul Mullowney 
74debe9ee2SPaul Mullowney #if defined(PETSC_USE_REAL_SINGLE)
75debe9ee2SPaul Mullowney typedef complexlib::complex<float> PetscScalar;
76debe9ee2SPaul Mullowney #elif defined(PETSC_USE_REAL_DOUBLE)
77debe9ee2SPaul Mullowney typedef complexlib::complex<double> PetscScalar;
78*8c764dc5SJose Roman #elif defined(PETSC_USE_REAL___FLOAT128)
79*8c764dc5SJose Roman typedef complexlib::complex<__float128> PetscScalar;
80debe9ee2SPaul Mullowney #endif  /* PETSC_USE_REAL_ */
81debe9ee2SPaul Mullowney 
821b65fc54SMatthew G Knepley #else /* PETSC_CLANGUAGE_CXX */
83b7940d39SSatish Balay 
84519e2a1fSPaul Mullowney /*  C support of complex numbers: Requires C99 compliant compiler*/
85519e2a1fSPaul Mullowney #include <complex.h>
86519e2a1fSPaul Mullowney 
87ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
8885b47369SMatthew Knepley typedef float complex PetscScalar;
8985b47369SMatthew Knepley 
9085b47369SMatthew Knepley #define PetscRealPart(a)      crealf(a)
9185b47369SMatthew Knepley #define PetscImaginaryPart(a) cimagf(a)
9285b47369SMatthew Knepley #define PetscAbsScalar(a)     cabsf(a)
9385b47369SMatthew Knepley #define PetscConj(a)          conjf(a)
9485b47369SMatthew Knepley #define PetscSqrtScalar(a)    csqrtf(a)
9585b47369SMatthew Knepley #define PetscPowScalar(a,b)   cpowf(a,b)
9685b47369SMatthew Knepley #define PetscExpScalar(a)     cexpf(a)
9706c1185fSBarry Smith #define PetscLogScalar(a)     clogf(a)
9885b47369SMatthew Knepley #define PetscSinScalar(a)     csinf(a)
9985b47369SMatthew Knepley #define PetscCosScalar(a)     ccosf(a)
1001093a601SBarry Smith 
101ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
1021093a601SBarry Smith typedef double complex PetscScalar;
1031093a601SBarry Smith 
1041093a601SBarry Smith #define PetscRealPart(a)      creal(a)
1051093a601SBarry Smith #define PetscImaginaryPart(a) cimag(a)
1061093a601SBarry Smith #define PetscAbsScalar(a)     cabs(a)
1071093a601SBarry Smith #define PetscConj(a)          conj(a)
1081093a601SBarry Smith #define PetscSqrtScalar(a)    csqrt(a)
1091093a601SBarry Smith #define PetscPowScalar(a,b)   cpow(a,b)
1101093a601SBarry Smith #define PetscExpScalar(a)     cexp(a)
1111093a601SBarry Smith #define PetscLogScalar(a)     clog(a)
1121093a601SBarry Smith #define PetscSinScalar(a)     csin(a)
1131093a601SBarry Smith #define PetscCosScalar(a)     ccos(a)
1141093a601SBarry Smith 
115*8c764dc5SJose Roman #elif defined(PETSC_USE_REAL___FLOAT128)
116*8c764dc5SJose Roman typedef __complex128 PetscScalar;
117*8c764dc5SJose Roman PETSC_EXTERN MPI_Datatype MPIU___FLOAT128;
118*8c764dc5SJose Roman PETSC_EXTERN MPI_Datatype MPIU___COMPLEX128;
119*8c764dc5SJose Roman #define MPIU_SCALAR MPIU___COMPLEX128
120*8c764dc5SJose Roman 
121*8c764dc5SJose Roman #define PetscRealPart(a)      crealq(a)
122*8c764dc5SJose Roman #define PetscImaginaryPart(a) cimagq(a)
123*8c764dc5SJose Roman #define PetscAbsScalar(a)     cabsq(a)
124*8c764dc5SJose Roman #define PetscConj(a)          conjq(a)
125*8c764dc5SJose Roman #define PetscSqrtScalar(a)    csqrtq(a)
126*8c764dc5SJose Roman #define PetscPowScalar(a,b)   cpowq(a,b)
127*8c764dc5SJose Roman #define PetscExpScalar(a)     cexpq(a)
128*8c764dc5SJose Roman #define PetscLogScalar(a)     clogq(a)
129*8c764dc5SJose Roman #define PetscSinScalar(a)     csinq(a)
130*8c764dc5SJose Roman #define PetscCosScalar(a)     ccosq(a)
131*8c764dc5SJose Roman 
132ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL_* */
1331b65fc54SMatthew G Knepley #endif /* PETSC_CLANGUAGE_CXX */
134e489efc1SBarry Smith 
13570da9c3bSJed Brown #if defined(PETSC_HAVE_MPI_C_DOUBLE_COMPLEX)
136500d8756SSatish Balay #define MPIU_C_DOUBLE_COMPLEX MPI_C_DOUBLE_COMPLEX
137500d8756SSatish Balay #define MPIU_C_COMPLEX MPI_C_COMPLEX
13870da9c3bSJed Brown #else
139014dd563SJed Brown PETSC_EXTERN MPI_Datatype MPIU_C_DOUBLE_COMPLEX;
140014dd563SJed Brown PETSC_EXTERN MPI_Datatype MPIU_C_COMPLEX;
1411b65fc54SMatthew G Knepley #endif /* PETSC_HAVE_MPI_C_DOUBLE_COMPLEX */
1422c876bd9SBarry Smith 
143ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
144500d8756SSatish Balay #define MPIU_SCALAR MPIU_C_COMPLEX
145ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
146500d8756SSatish Balay #define MPIU_SCALAR MPIU_C_DOUBLE_COMPLEX
147ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL_* */
14875567043SBarry Smith 
1491093a601SBarry Smith /*
1501093a601SBarry Smith     real number definitions
1511093a601SBarry Smith  */
1521b65fc54SMatthew G Knepley #else /* PETSC_USE_COMPLEX */
153ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
15487828ca2SBarry Smith #define MPIU_SCALAR           MPI_FLOAT
1551093a601SBarry Smith typedef float PetscScalar;
156ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
1571093a601SBarry Smith #define MPIU_SCALAR           MPI_DOUBLE
1581093a601SBarry Smith typedef double PetscScalar;
159ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128)
160014dd563SJed Brown PETSC_EXTERN MPI_Datatype MPIU___FLOAT128;
161c90a1750SBarry Smith #define MPIU_SCALAR MPIU___FLOAT128
1620d0cc1b5SBarry Smith typedef __float128 PetscScalar;
163ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL_* */
164329f5518SBarry Smith #define PetscRealPart(a)      (a)
165c1d390e3SJed Brown #define PetscImaginaryPart(a) ((PetscReal)0.)
166c1d390e3SJed Brown PETSC_STATIC_INLINE PetscReal PetscAbsScalar(PetscScalar a) {return a < 0.0 ? -a : a;}
167e489efc1SBarry Smith #define PetscConj(a)          (a)
168ce63c4c1SBarry Smith #if !defined(PETSC_USE_REAL___FLOAT128)
16918a7d68fSSatish Balay #define PetscSqrtScalar(a)    sqrt(a)
170184914b5SBarry Smith #define PetscPowScalar(a,b)   pow(a,b)
171184914b5SBarry Smith #define PetscExpScalar(a)     exp(a)
17206c1185fSBarry Smith #define PetscLogScalar(a)     log(a)
173184914b5SBarry Smith #define PetscSinScalar(a)     sin(a)
174184914b5SBarry Smith #define PetscCosScalar(a)     cos(a)
175ce63c4c1SBarry Smith #else /* PETSC_USE_REAL___FLOAT128 */
1760d0cc1b5SBarry Smith #define PetscSqrtScalar(a)    sqrtq(a)
1770d0cc1b5SBarry Smith #define PetscPowScalar(a,b)   powq(a,b)
1780d0cc1b5SBarry Smith #define PetscExpScalar(a)     expq(a)
1790d0cc1b5SBarry Smith #define PetscLogScalar(a)     logq(a)
1800d0cc1b5SBarry Smith #define PetscSinScalar(a)     sinq(a)
1810d0cc1b5SBarry Smith #define PetscCosScalar(a)     cosq(a)
182ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL___FLOAT128 */
183b0a32e0cSBarry Smith 
1841b65fc54SMatthew G Knepley #endif /* PETSC_USE_COMPLEX */
185e489efc1SBarry Smith 
186da9b6338SBarry Smith #define PetscSign(a) (((a) >= 0) ? ((a) == 0 ? 0 : 1) : -1)
18726aa1773SMatthew Knepley #define PetscAbs(a)  (((a) >= 0) ? (a) : -(a))
1883f1db9ecSBarry Smith 
189314da920SBarry Smith /* --------------------------------------------------------------------------*/
190314da920SBarry Smith 
191e489efc1SBarry Smith /*
192f22f69f0SBarry Smith    Certain objects may be created using either single or double precision.
193f22f69f0SBarry Smith    This is currently not used.
194e489efc1SBarry Smith */
195557d4da8SBarry Smith typedef enum { PETSC_SCALAR_DOUBLE,PETSC_SCALAR_SINGLE, PETSC_SCALAR_LONG_DOUBLE } PetscScalarPrecision;
196e489efc1SBarry Smith 
197e489efc1SBarry Smith /* PETSC_i is the imaginary number, i */
198014dd563SJed Brown PETSC_EXTERN PetscScalar   PETSC_i;
199e489efc1SBarry Smith 
200b6a5bde7SBarry Smith /*MC
201b6a5bde7SBarry Smith    PetscMin - Returns minimum of two numbers
202b6a5bde7SBarry Smith 
203eca87e8dSBarry Smith    Synopsis:
204eca87e8dSBarry Smith    type PetscMin(type v1,type v2)
205eca87e8dSBarry Smith 
206eca87e8dSBarry Smith    Not Collective
207eca87e8dSBarry Smith 
208b6a5bde7SBarry Smith    Input Parameter:
209b6a5bde7SBarry Smith +  v1 - first value to find minimum of
210b6a5bde7SBarry Smith -  v2 - second value to find minimum of
211b6a5bde7SBarry Smith 
212b6a5bde7SBarry Smith 
213b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
214b6a5bde7SBarry Smith 
215b6a5bde7SBarry Smith    Level: beginner
216b6a5bde7SBarry Smith 
217b6a5bde7SBarry Smith 
218d9a4bb16SJed Brown .seealso: PetscMin(), PetscClipInterval(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
219b6a5bde7SBarry Smith 
220b6a5bde7SBarry Smith M*/
221e489efc1SBarry Smith #define PetscMin(a,b)   (((a)<(b)) ?  (a) : (b))
222b6a5bde7SBarry Smith 
223b6a5bde7SBarry Smith /*MC
224b6a5bde7SBarry Smith    PetscMax - Returns maxium of two numbers
225b6a5bde7SBarry Smith 
226eca87e8dSBarry Smith    Synopsis:
227eca87e8dSBarry Smith    type max PetscMax(type v1,type v2)
228eca87e8dSBarry Smith 
229eca87e8dSBarry Smith    Not Collective
230eca87e8dSBarry Smith 
231b6a5bde7SBarry Smith    Input Parameter:
232b6a5bde7SBarry Smith +  v1 - first value to find maximum of
233b6a5bde7SBarry Smith -  v2 - second value to find maximum of
234b6a5bde7SBarry Smith 
235b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
236b6a5bde7SBarry Smith 
237b6a5bde7SBarry Smith    Level: beginner
238b6a5bde7SBarry Smith 
239d9a4bb16SJed Brown .seealso: PetscMin(), PetscClipInterval(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
240b6a5bde7SBarry Smith 
241b6a5bde7SBarry Smith M*/
242e489efc1SBarry Smith #define PetscMax(a,b)   (((a)<(b)) ?  (b) : (a))
243b6a5bde7SBarry Smith 
244b6a5bde7SBarry Smith /*MC
245d9a4bb16SJed Brown    PetscClipInterval - Returns a number clipped to be within an interval
246d9a4bb16SJed Brown 
247d9a4bb16SJed Brown    Synopsis:
248d9a4bb16SJed Brown    type clip PetscClipInterval(type x,type a,type b)
249d9a4bb16SJed Brown 
250d9a4bb16SJed Brown    Not Collective
251d9a4bb16SJed Brown 
252d9a4bb16SJed Brown    Input Parameter:
253d9a4bb16SJed Brown +  x - value to use if within interval (a,b)
254d9a4bb16SJed Brown .  a - lower end of interval
255d9a4bb16SJed Brown -  b - upper end of interval
256d9a4bb16SJed Brown 
257d9a4bb16SJed Brown    Notes: type can be integer or floating point value
258d9a4bb16SJed Brown 
259d9a4bb16SJed Brown    Level: beginner
260d9a4bb16SJed Brown 
261d9a4bb16SJed Brown .seealso: PetscMin(), PetscMax(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
262d9a4bb16SJed Brown 
263d9a4bb16SJed Brown M*/
264d9a4bb16SJed Brown #define PetscClipInterval(x,a,b)   (PetscMax((a),PetscMin((x),(b))))
265d9a4bb16SJed Brown 
266d9a4bb16SJed Brown /*MC
267b6a5bde7SBarry Smith    PetscAbsInt - Returns the absolute value of an integer
268b6a5bde7SBarry Smith 
269b6a5bde7SBarry Smith    Synopsis:
270b6a5bde7SBarry Smith    int abs PetscAbsInt(int v1)
271b6a5bde7SBarry Smith 
272eca87e8dSBarry Smith    Not Collective
273eca87e8dSBarry Smith 
274eca87e8dSBarry Smith    Input Parameter:
275eca87e8dSBarry Smith .   v1 - the integer
276b6a5bde7SBarry Smith 
277b6a5bde7SBarry Smith    Level: beginner
278b6a5bde7SBarry Smith 
279b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsReal(), PetscSqr()
280b6a5bde7SBarry Smith 
281b6a5bde7SBarry Smith M*/
282e489efc1SBarry Smith #define PetscAbsInt(a)  (((a)<0)   ? -(a) : (a))
283b6a5bde7SBarry Smith 
284b6a5bde7SBarry Smith /*MC
285b6a5bde7SBarry Smith    PetscAbsReal - Returns the absolute value of an real number
286b6a5bde7SBarry Smith 
287eca87e8dSBarry Smith    Synopsis:
288eca87e8dSBarry Smith    Real abs PetscAbsReal(PetscReal v1)
289eca87e8dSBarry Smith 
290eca87e8dSBarry Smith    Not Collective
291eca87e8dSBarry Smith 
292b6a5bde7SBarry Smith    Input Parameter:
293b6a5bde7SBarry Smith .   v1 - the double
294b6a5bde7SBarry Smith 
295b6a5bde7SBarry Smith 
296b6a5bde7SBarry Smith    Level: beginner
297b6a5bde7SBarry Smith 
298b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsInt(), PetscSqr()
299b6a5bde7SBarry Smith 
300b6a5bde7SBarry Smith M*/
301f6275e2eSBarry Smith #define PetscAbsReal(a) (((a)<0)   ? -(a) : (a))
302b6a5bde7SBarry Smith 
303b6a5bde7SBarry Smith /*MC
304b6a5bde7SBarry Smith    PetscSqr - Returns the square of a number
305b6a5bde7SBarry Smith 
306b6a5bde7SBarry Smith    Synopsis:
307b6a5bde7SBarry Smith    type sqr PetscSqr(type v1)
308b6a5bde7SBarry Smith 
309eca87e8dSBarry Smith    Not Collective
310eca87e8dSBarry Smith 
311eca87e8dSBarry Smith    Input Parameter:
312eca87e8dSBarry Smith .   v1 - the value
313eca87e8dSBarry Smith 
314b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
315b6a5bde7SBarry Smith 
316b6a5bde7SBarry Smith    Level: beginner
317b6a5bde7SBarry Smith 
318b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsInt(), PetscAbsReal()
319b6a5bde7SBarry Smith 
320b6a5bde7SBarry Smith M*/
3214ebda54eSMatthew Knepley #define PetscSqr(a)     ((a)*(a))
322e489efc1SBarry Smith 
323314da920SBarry Smith /* ----------------------------------------------------------------------------*/
324314da920SBarry Smith /*
325d34fcf5fSBarry Smith      Basic constants
326314da920SBarry Smith */
327ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL___FLOAT128)
328d34fcf5fSBarry Smith #define PETSC_PI                 M_PIq
329d34fcf5fSBarry Smith #elif defined(M_PI)
330d34fcf5fSBarry Smith #define PETSC_PI                 M_PI
331d34fcf5fSBarry Smith #else
332faa6e9b0SMatthew G Knepley #define PETSC_PI                 3.14159265358979323846264338327950288419716939937510582
333d34fcf5fSBarry Smith #endif
334d34fcf5fSBarry Smith 
335ab824b78SBarry Smith #if !defined(PETSC_USE_64BIT_INDICES)
33671fd2e92SBarry Smith #define PETSC_MAX_INT            2147483647
337ab824b78SBarry Smith #define PETSC_MIN_INT            (-PETSC_MAX_INT - 1)
338ab824b78SBarry Smith #else
339ab824b78SBarry Smith #define PETSC_MAX_INT            9223372036854775807L
340ab824b78SBarry Smith #define PETSC_MIN_INT            (-PETSC_MAX_INT - 1)
341ab824b78SBarry Smith #endif
342e489efc1SBarry Smith 
343ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
344ab824b78SBarry Smith #  define PETSC_MAX_REAL                3.40282346638528860e+38F
345ea345e14SBarry Smith #  define PETSC_MIN_REAL                -PETSC_MAX_REAL
34682a7e548SBarry Smith #  define PETSC_MACHINE_EPSILON         1.19209290e-07F
34782a7e548SBarry Smith #  define PETSC_SQRT_MACHINE_EPSILON    3.45266983e-04F
348cf6e855fSSatish Balay #  define PETSC_SMALL                   1.e-5
349ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
350ab824b78SBarry Smith #  define PETSC_MAX_REAL                1.7976931348623157e+308
351ea345e14SBarry Smith #  define PETSC_MIN_REAL                -PETSC_MAX_REAL
35282a7e548SBarry Smith #  define PETSC_MACHINE_EPSILON         2.2204460492503131e-16
35382a7e548SBarry Smith #  define PETSC_SQRT_MACHINE_EPSILON    1.490116119384766e-08
354cf6e855fSSatish Balay #  define PETSC_SMALL                   1.e-10
355ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128)
356ea345e14SBarry Smith #  define PETSC_MAX_REAL                FLT128_MAX
357ce63c4c1SBarry Smith #  define PETSC_MIN_REAL                -FLT128_MAX
358d34fcf5fSBarry Smith #  define PETSC_MACHINE_EPSILON         FLT128_EPSILON
359d34fcf5fSBarry Smith #  define PETSC_SQRT_MACHINE_EPSILON    1.38777878078e-17
360d34fcf5fSBarry Smith #  define PETSC_SMALL                   1.e-20
36182adfdadSBarry Smith #endif
36282adfdadSBarry Smith 
3639cf09972SJed Brown #if defined PETSC_HAVE_ADIC
3649cf09972SJed Brown /* Use MPI_Allreduce when ADIC is not available. */
365014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscGlobalMax(MPI_Comm, const PetscReal*,PetscReal*);
366014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscGlobalMin(MPI_Comm, const PetscReal*,PetscReal*);
367014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscGlobalSum(MPI_Comm, const PetscScalar*,PetscScalar*);
3689cf09972SJed Brown #endif
3693e523bebSBarry Smith 
370014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscIsInfOrNanScalar(PetscScalar);
371014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscIsInfOrNanReal(PetscReal);
3729a25a3ccSBarry Smith 
373314da920SBarry Smith /* ----------------------------------------------------------------------------*/
37487828ca2SBarry Smith #define PassiveReal   PetscReal
375ea709b57SSatish Balay #define PassiveScalar PetscScalar
376d3ecb3a7SBarry Smith 
37798725619SBarry Smith /*
37898725619SBarry Smith     These macros are currently hardwired to match the regular data types, so there is no support for a different
37998725619SBarry Smith     MatScalar from PetscScalar. We left the MatScalar in the source just in case we use it again.
38098725619SBarry Smith  */
38198725619SBarry Smith #define MPIU_MATSCALAR MPIU_SCALAR
38298725619SBarry Smith typedef PetscScalar MatScalar;
38398725619SBarry Smith typedef PetscReal MatReal;
38498725619SBarry Smith 
385e9fa29b7SSatish Balay 
386e489efc1SBarry Smith #endif
387