xref: /petsc/include/petscmath.h (revision 9ae82921df069a58776bfe4da82b38e8ff7dd41c)
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>
14e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN
150a5f7794SBarry Smith 
167087cfbeSBarry Smith extern  MPI_Datatype  MPIU_2SCALAR;
177087cfbeSBarry Smith extern  MPI_Datatype  MPIU_2INT;
18c90a1750SBarry Smith 
19314da920SBarry Smith /*
20f4ccad53SBarry Smith 
21f4ccad53SBarry Smith      Defines operations that are different for complex and real numbers;
22a5057860SBarry Smith    note that one cannot mix the use of complex and real in the same
23f4ccad53SBarry Smith    PETSc program. All PETSc objects in one program are built around the object
2498725619SBarry Smith    PetscScalar which is either always a real or a complex.
25f4ccad53SBarry Smith 
26e489efc1SBarry Smith */
27b36a9721SBarry Smith 
2859cb5930SBarry Smith #define PetscExpPassiveScalar(a) PetscExpScalar()
29c1d390e3SJed Brown #if defined(PETSC_USE_REAL_SINGLE)
30c1d390e3SJed Brown #define MPIU_REAL   MPI_FLOAT
31c1d390e3SJed Brown typedef float PetscReal;
328f1a2a5eSBarry Smith #define PetscSqrtReal(a)    sqrt(a)
33c1d390e3SJed Brown #elif defined(PETSC_USE_REAL_DOUBLE)
34c1d390e3SJed Brown #define MPIU_REAL   MPI_DOUBLE
35c1d390e3SJed Brown typedef double PetscReal;
368f1a2a5eSBarry Smith #define PetscSqrtReal(a)    sqrt(a)
37c1d390e3SJed Brown #elif defined(PETSC_USE_REAL___FLOAT128)
38c1d390e3SJed Brown #define MPIU_REAL MPIU___FLOAT128
39c1d390e3SJed Brown typedef __float128 PetscReal;
408f1a2a5eSBarry Smith #define PetscSqrtReal(a)    sqrtq(a)
41c1d390e3SJed Brown #endif /* PETSC_USE_REAL_* */
4259cb5930SBarry Smith 
431093a601SBarry Smith /*
441093a601SBarry Smith     Complex number definitions
451093a601SBarry Smith  */
46aa482453SBarry Smith #if defined(PETSC_USE_COMPLEX)
47b7940d39SSatish Balay #if defined(PETSC_CLANGUAGE_CXX)
481093a601SBarry Smith /* C++ support of complex number */
49*9ae82921SPaul Mullowney /*
50df9b3741SSatish Balay #include <complex>
51adc17e78SSatish Balay 
52329f5518SBarry Smith #define PetscRealPart(a)      (a).real()
53329f5518SBarry Smith #define PetscImaginaryPart(a) (a).imag()
543f6de6efSSatish Balay #define PetscAbsScalar(a)     std::abs(a)
553f6de6efSSatish Balay #define PetscConj(a)          std::conj(a)
5618a7d68fSSatish Balay #define PetscSqrtScalar(a)    std::sqrt(a)
57184914b5SBarry Smith #define PetscPowScalar(a,b)   std::pow(a,b)
58184914b5SBarry Smith #define PetscExpScalar(a)     std::exp(a)
5906c1185fSBarry Smith #define PetscLogScalar(a)     std::log(a)
60184914b5SBarry Smith #define PetscSinScalar(a)     std::sin(a)
61184914b5SBarry Smith #define PetscCosScalar(a)     std::cos(a)
620bfd3fbfSBarry Smith 
63ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
644a60b672SMatthew Knepley typedef std::complex<float> PetscScalar;
65ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
661093a601SBarry Smith typedef std::complex<double> PetscScalar;
67*9ae82921SPaul Mullowney #endif */ /* PETSC_USE_REAL_* */
68*9ae82921SPaul Mullowney 
69*9ae82921SPaul Mullowney /* CUSP support of complex number */
70*9ae82921SPaul Mullowney 
71*9ae82921SPaul Mullowney #include <cusp/complex.h>
72*9ae82921SPaul Mullowney 
73*9ae82921SPaul Mullowney #define PetscRealPart(a)      (a).real()
74*9ae82921SPaul Mullowney #define PetscImaginaryPart(a) (a).imag()
75*9ae82921SPaul Mullowney #define PetscAbsScalar(a)     cusp::abs(a)
76*9ae82921SPaul Mullowney #define PetscConj(a)          cusp::conj(a)
77*9ae82921SPaul Mullowney #define PetscSqrtScalar(a)    cusp::sqrt(a)
78*9ae82921SPaul Mullowney #define PetscPowScalar(a,b)   cusp::pow(a,b)
79*9ae82921SPaul Mullowney #define PetscExpScalar(a)     cusp::exp(a)
80*9ae82921SPaul Mullowney #define PetscLogScalar(a)     cusp::log(a)
81*9ae82921SPaul Mullowney #define PetscSinScalar(a)     cusp::sin(a)
82*9ae82921SPaul Mullowney #define PetscCosScalar(a)     cusp::cos(a)
83*9ae82921SPaul Mullowney 
84*9ae82921SPaul Mullowney #if defined(PETSC_USE_REAL_SINGLE)
85*9ae82921SPaul Mullowney typedef cusp::complex<float> PetscScalar;
86*9ae82921SPaul Mullowney #elif defined(PETSC_USE_REAL_DOUBLE)
87*9ae82921SPaul Mullowney typedef cusp::complex<double> PetscScalar;
88*9ae82921SPaul Mullowney #endif
89b7940d39SSatish Balay 
901b65fc54SMatthew G Knepley #else /* PETSC_CLANGUAGE_CXX */
911093a601SBarry Smith /*  C support of complex numbers: Requires C99 compliant compiler*/
92*9ae82921SPaul Mullowney #include <cusp::complex.h>
93b7940d39SSatish Balay 
94ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
9585b47369SMatthew Knepley typedef float complex PetscScalar;
9685b47369SMatthew Knepley 
9785b47369SMatthew Knepley #define PetscRealPart(a)      crealf(a)
9885b47369SMatthew Knepley #define PetscImaginaryPart(a) cimagf(a)
9985b47369SMatthew Knepley #define PetscAbsScalar(a)     cabsf(a)
10085b47369SMatthew Knepley #define PetscConj(a)          conjf(a)
10185b47369SMatthew Knepley #define PetscSqrtScalar(a)    csqrtf(a)
10285b47369SMatthew Knepley #define PetscPowScalar(a,b)   cpowf(a,b)
10385b47369SMatthew Knepley #define PetscExpScalar(a)     cexpf(a)
10406c1185fSBarry Smith #define PetscLogScalar(a)     clogf(a)
10585b47369SMatthew Knepley #define PetscSinScalar(a)     csinf(a)
10685b47369SMatthew Knepley #define PetscCosScalar(a)     ccosf(a)
1071093a601SBarry Smith 
108ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
1091093a601SBarry Smith typedef double complex PetscScalar;
1101093a601SBarry Smith 
1111093a601SBarry Smith #define PetscRealPart(a)      creal(a)
1121093a601SBarry Smith #define PetscImaginaryPart(a) cimag(a)
1131093a601SBarry Smith #define PetscAbsScalar(a)     cabs(a)
1141093a601SBarry Smith #define PetscConj(a)          conj(a)
1151093a601SBarry Smith #define PetscSqrtScalar(a)    csqrt(a)
1161093a601SBarry Smith #define PetscPowScalar(a,b)   cpow(a,b)
1171093a601SBarry Smith #define PetscExpScalar(a)     cexp(a)
1181093a601SBarry Smith #define PetscLogScalar(a)     clog(a)
1191093a601SBarry Smith #define PetscSinScalar(a)     csin(a)
1201093a601SBarry Smith #define PetscCosScalar(a)     ccos(a)
1211093a601SBarry Smith 
122ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL_* */
1231b65fc54SMatthew G Knepley #endif /* PETSC_CLANGUAGE_CXX */
124e489efc1SBarry Smith 
12570da9c3bSJed Brown #if defined(PETSC_HAVE_MPI_C_DOUBLE_COMPLEX)
126500d8756SSatish Balay #define MPIU_C_DOUBLE_COMPLEX MPI_C_DOUBLE_COMPLEX
127500d8756SSatish Balay #define MPIU_C_COMPLEX MPI_C_COMPLEX
12870da9c3bSJed Brown #else
12970da9c3bSJed Brown extern MPI_Datatype  MPIU_C_DOUBLE_COMPLEX;
13070da9c3bSJed Brown extern MPI_Datatype  MPIU_C_COMPLEX;
1311b65fc54SMatthew G Knepley #endif /* PETSC_HAVE_MPI_C_DOUBLE_COMPLEX */
1322c876bd9SBarry Smith 
133ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
134500d8756SSatish Balay #define MPIU_SCALAR MPIU_C_COMPLEX
135ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
136500d8756SSatish Balay #define MPIU_SCALAR MPIU_C_DOUBLE_COMPLEX
137ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL_* */
13875567043SBarry Smith 
1391093a601SBarry Smith /*
1401093a601SBarry Smith     real number definitions
1411093a601SBarry Smith  */
1421b65fc54SMatthew G Knepley #else /* PETSC_USE_COMPLEX */
143ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
14487828ca2SBarry Smith #define MPIU_SCALAR           MPI_FLOAT
1451093a601SBarry Smith typedef float PetscScalar;
146ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
1471093a601SBarry Smith #define MPIU_SCALAR           MPI_DOUBLE
1481093a601SBarry Smith typedef double PetscScalar;
149ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128)
150c90a1750SBarry Smith extern MPI_Datatype MPIU___FLOAT128;
151c90a1750SBarry Smith #define MPIU_SCALAR MPIU___FLOAT128
1520d0cc1b5SBarry Smith typedef __float128 PetscScalar;
153ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL_* */
154329f5518SBarry Smith #define PetscRealPart(a)      (a)
155c1d390e3SJed Brown #define PetscImaginaryPart(a) ((PetscReal)0.)
156c1d390e3SJed Brown PETSC_STATIC_INLINE PetscReal PetscAbsScalar(PetscScalar a) {return a < 0.0 ? -a : a;}
157e489efc1SBarry Smith #define PetscConj(a)          (a)
158ce63c4c1SBarry Smith #if !defined(PETSC_USE_REAL___FLOAT128)
15918a7d68fSSatish Balay #define PetscSqrtScalar(a)    sqrt(a)
160184914b5SBarry Smith #define PetscPowScalar(a,b)   pow(a,b)
161184914b5SBarry Smith #define PetscExpScalar(a)     exp(a)
16206c1185fSBarry Smith #define PetscLogScalar(a)     log(a)
163184914b5SBarry Smith #define PetscSinScalar(a)     sin(a)
164184914b5SBarry Smith #define PetscCosScalar(a)     cos(a)
165ce63c4c1SBarry Smith #else /* PETSC_USE_REAL___FLOAT128 */
1660d0cc1b5SBarry Smith #include <quadmath.h>
1670d0cc1b5SBarry Smith #define PetscSqrtScalar(a)    sqrtq(a)
1680d0cc1b5SBarry Smith #define PetscPowScalar(a,b)   powq(a,b)
1690d0cc1b5SBarry Smith #define PetscExpScalar(a)     expq(a)
1700d0cc1b5SBarry Smith #define PetscLogScalar(a)     logq(a)
1710d0cc1b5SBarry Smith #define PetscSinScalar(a)     sinq(a)
1720d0cc1b5SBarry Smith #define PetscCosScalar(a)     cosq(a)
173ce63c4c1SBarry Smith #endif /* PETSC_USE_REAL___FLOAT128 */
174b0a32e0cSBarry Smith 
1751b65fc54SMatthew G Knepley #endif /* PETSC_USE_COMPLEX */
176e489efc1SBarry Smith 
177da9b6338SBarry Smith #define PetscSign(a) (((a) >= 0) ? ((a) == 0 ? 0 : 1) : -1)
17826aa1773SMatthew Knepley #define PetscAbs(a)  (((a) >= 0) ? (a) : -(a))
1793f1db9ecSBarry Smith 
180314da920SBarry Smith /* --------------------------------------------------------------------------*/
181314da920SBarry Smith 
182e489efc1SBarry Smith /*
183f22f69f0SBarry Smith    Certain objects may be created using either single or double precision.
184f22f69f0SBarry Smith    This is currently not used.
185e489efc1SBarry Smith */
186557d4da8SBarry Smith typedef enum { PETSC_SCALAR_DOUBLE,PETSC_SCALAR_SINGLE, PETSC_SCALAR_LONG_DOUBLE } PetscScalarPrecision;
187e489efc1SBarry Smith 
188e489efc1SBarry Smith /* PETSC_i is the imaginary number, i */
1897087cfbeSBarry Smith extern  PetscScalar  PETSC_i;
190e489efc1SBarry Smith 
191b6a5bde7SBarry Smith /*MC
192b6a5bde7SBarry Smith    PetscMin - Returns minimum of two numbers
193b6a5bde7SBarry Smith 
194eca87e8dSBarry Smith    Synopsis:
195eca87e8dSBarry Smith    type PetscMin(type v1,type v2)
196eca87e8dSBarry Smith 
197eca87e8dSBarry Smith    Not Collective
198eca87e8dSBarry Smith 
199b6a5bde7SBarry Smith    Input Parameter:
200b6a5bde7SBarry Smith +  v1 - first value to find minimum of
201b6a5bde7SBarry Smith -  v2 - second value to find minimum of
202b6a5bde7SBarry Smith 
203b6a5bde7SBarry Smith 
204b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
205b6a5bde7SBarry Smith 
206b6a5bde7SBarry Smith    Level: beginner
207b6a5bde7SBarry Smith 
208b6a5bde7SBarry Smith 
209d9a4bb16SJed Brown .seealso: PetscMin(), PetscClipInterval(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
210b6a5bde7SBarry Smith 
211b6a5bde7SBarry Smith M*/
212e489efc1SBarry Smith #define PetscMin(a,b)   (((a)<(b)) ?  (a) : (b))
213b6a5bde7SBarry Smith 
214b6a5bde7SBarry Smith /*MC
215b6a5bde7SBarry Smith    PetscMax - Returns maxium of two numbers
216b6a5bde7SBarry Smith 
217eca87e8dSBarry Smith    Synopsis:
218eca87e8dSBarry Smith    type max PetscMax(type v1,type v2)
219eca87e8dSBarry Smith 
220eca87e8dSBarry Smith    Not Collective
221eca87e8dSBarry Smith 
222b6a5bde7SBarry Smith    Input Parameter:
223b6a5bde7SBarry Smith +  v1 - first value to find maximum of
224b6a5bde7SBarry Smith -  v2 - second value to find maximum of
225b6a5bde7SBarry Smith 
226b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
227b6a5bde7SBarry Smith 
228b6a5bde7SBarry Smith    Level: beginner
229b6a5bde7SBarry Smith 
230d9a4bb16SJed Brown .seealso: PetscMin(), PetscClipInterval(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
231b6a5bde7SBarry Smith 
232b6a5bde7SBarry Smith M*/
233e489efc1SBarry Smith #define PetscMax(a,b)   (((a)<(b)) ?  (b) : (a))
234b6a5bde7SBarry Smith 
235b6a5bde7SBarry Smith /*MC
236d9a4bb16SJed Brown    PetscClipInterval - Returns a number clipped to be within an interval
237d9a4bb16SJed Brown 
238d9a4bb16SJed Brown    Synopsis:
239d9a4bb16SJed Brown    type clip PetscClipInterval(type x,type a,type b)
240d9a4bb16SJed Brown 
241d9a4bb16SJed Brown    Not Collective
242d9a4bb16SJed Brown 
243d9a4bb16SJed Brown    Input Parameter:
244d9a4bb16SJed Brown +  x - value to use if within interval (a,b)
245d9a4bb16SJed Brown .  a - lower end of interval
246d9a4bb16SJed Brown -  b - upper end of interval
247d9a4bb16SJed Brown 
248d9a4bb16SJed Brown    Notes: type can be integer or floating point value
249d9a4bb16SJed Brown 
250d9a4bb16SJed Brown    Level: beginner
251d9a4bb16SJed Brown 
252d9a4bb16SJed Brown .seealso: PetscMin(), PetscMax(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
253d9a4bb16SJed Brown 
254d9a4bb16SJed Brown M*/
255d9a4bb16SJed Brown #define PetscClipInterval(x,a,b)   (PetscMax((a),PetscMin((x),(b))))
256d9a4bb16SJed Brown 
257d9a4bb16SJed Brown /*MC
258b6a5bde7SBarry Smith    PetscAbsInt - Returns the absolute value of an integer
259b6a5bde7SBarry Smith 
260b6a5bde7SBarry Smith    Synopsis:
261b6a5bde7SBarry Smith    int abs PetscAbsInt(int v1)
262b6a5bde7SBarry Smith 
263eca87e8dSBarry Smith    Not Collective
264eca87e8dSBarry Smith 
265eca87e8dSBarry Smith    Input Parameter:
266eca87e8dSBarry Smith .   v1 - the integer
267b6a5bde7SBarry Smith 
268b6a5bde7SBarry Smith    Level: beginner
269b6a5bde7SBarry Smith 
270b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsReal(), PetscSqr()
271b6a5bde7SBarry Smith 
272b6a5bde7SBarry Smith M*/
273e489efc1SBarry Smith #define PetscAbsInt(a)  (((a)<0)   ? -(a) : (a))
274b6a5bde7SBarry Smith 
275b6a5bde7SBarry Smith /*MC
276b6a5bde7SBarry Smith    PetscAbsReal - Returns the absolute value of an real number
277b6a5bde7SBarry Smith 
278eca87e8dSBarry Smith    Synopsis:
279eca87e8dSBarry Smith    Real abs PetscAbsReal(PetscReal v1)
280eca87e8dSBarry Smith 
281eca87e8dSBarry Smith    Not Collective
282eca87e8dSBarry Smith 
283b6a5bde7SBarry Smith    Input Parameter:
284b6a5bde7SBarry Smith .   v1 - the double
285b6a5bde7SBarry Smith 
286b6a5bde7SBarry Smith 
287b6a5bde7SBarry Smith    Level: beginner
288b6a5bde7SBarry Smith 
289b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsInt(), PetscSqr()
290b6a5bde7SBarry Smith 
291b6a5bde7SBarry Smith M*/
292f6275e2eSBarry Smith #define PetscAbsReal(a) (((a)<0)   ? -(a) : (a))
293b6a5bde7SBarry Smith 
294b6a5bde7SBarry Smith /*MC
295b6a5bde7SBarry Smith    PetscSqr - Returns the square of a number
296b6a5bde7SBarry Smith 
297b6a5bde7SBarry Smith    Synopsis:
298b6a5bde7SBarry Smith    type sqr PetscSqr(type v1)
299b6a5bde7SBarry Smith 
300eca87e8dSBarry Smith    Not Collective
301eca87e8dSBarry Smith 
302eca87e8dSBarry Smith    Input Parameter:
303eca87e8dSBarry Smith .   v1 - the value
304eca87e8dSBarry Smith 
305b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
306b6a5bde7SBarry Smith 
307b6a5bde7SBarry Smith    Level: beginner
308b6a5bde7SBarry Smith 
309b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsInt(), PetscAbsReal()
310b6a5bde7SBarry Smith 
311b6a5bde7SBarry Smith M*/
3124ebda54eSMatthew Knepley #define PetscSqr(a)     ((a)*(a))
313e489efc1SBarry Smith 
314314da920SBarry Smith /* ----------------------------------------------------------------------------*/
315314da920SBarry Smith /*
316d34fcf5fSBarry Smith      Basic constants
317314da920SBarry Smith */
318ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL___FLOAT128)
319d34fcf5fSBarry Smith #define PETSC_PI                 M_PIq
320d34fcf5fSBarry Smith #elif defined(M_PI)
321d34fcf5fSBarry Smith #define PETSC_PI                 M_PI
322d34fcf5fSBarry Smith #else
323faa6e9b0SMatthew G Knepley #define PETSC_PI                 3.14159265358979323846264338327950288419716939937510582
324d34fcf5fSBarry Smith #endif
325d34fcf5fSBarry Smith 
326ab824b78SBarry Smith #if !defined(PETSC_USE_64BIT_INDICES)
32771fd2e92SBarry Smith #define PETSC_MAX_INT            2147483647
328ab824b78SBarry Smith #define PETSC_MIN_INT            (-PETSC_MAX_INT - 1)
329ab824b78SBarry Smith #else
330ab824b78SBarry Smith #define PETSC_MAX_INT            9223372036854775807L
331ab824b78SBarry Smith #define PETSC_MIN_INT            (-PETSC_MAX_INT - 1)
332ab824b78SBarry Smith #endif
333e489efc1SBarry Smith 
334ce63c4c1SBarry Smith #if defined(PETSC_USE_REAL_SINGLE)
335ab824b78SBarry Smith #  define PETSC_MAX_REAL                3.40282346638528860e+38F
336ea345e14SBarry Smith #  define PETSC_MIN_REAL                -PETSC_MAX_REAL
33782a7e548SBarry Smith #  define PETSC_MACHINE_EPSILON         1.19209290e-07F
33882a7e548SBarry Smith #  define PETSC_SQRT_MACHINE_EPSILON    3.45266983e-04F
339cf6e855fSSatish Balay #  define PETSC_SMALL                   1.e-5
340ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL_DOUBLE)
341ab824b78SBarry Smith #  define PETSC_MAX_REAL                1.7976931348623157e+308
342ea345e14SBarry Smith #  define PETSC_MIN_REAL                -PETSC_MAX_REAL
34382a7e548SBarry Smith #  define PETSC_MACHINE_EPSILON         2.2204460492503131e-16
34482a7e548SBarry Smith #  define PETSC_SQRT_MACHINE_EPSILON    1.490116119384766e-08
345cf6e855fSSatish Balay #  define PETSC_SMALL                   1.e-10
346ce63c4c1SBarry Smith #elif defined(PETSC_USE_REAL___FLOAT128)
347ea345e14SBarry Smith #  define PETSC_MAX_REAL                FLT128_MAX
348ce63c4c1SBarry Smith #  define PETSC_MIN_REAL                -FLT128_MAX
349d34fcf5fSBarry Smith #  define PETSC_MACHINE_EPSILON         FLT128_EPSILON
350d34fcf5fSBarry Smith #  define PETSC_SQRT_MACHINE_EPSILON    1.38777878078e-17
351d34fcf5fSBarry Smith #  define PETSC_SMALL                   1.e-20
35282adfdadSBarry Smith #endif
35382adfdadSBarry Smith 
3549cf09972SJed Brown #if defined PETSC_HAVE_ADIC
3559cf09972SJed Brown /* Use MPI_Allreduce when ADIC is not available. */
3567087cfbeSBarry Smith extern PetscErrorCode  PetscGlobalMax(MPI_Comm, const PetscReal*,PetscReal*);
3577087cfbeSBarry Smith extern PetscErrorCode  PetscGlobalMin(MPI_Comm, const PetscReal*,PetscReal*);
3587087cfbeSBarry Smith extern PetscErrorCode  PetscGlobalSum(MPI_Comm, const PetscScalar*,PetscScalar*);
3599cf09972SJed Brown #endif
3603e523bebSBarry Smith 
361a3630638SSatish Balay extern PetscErrorCode PetscIsInfOrNanScalar(PetscScalar);
362a3630638SSatish Balay extern PetscErrorCode PetscIsInfOrNanReal(PetscReal);
3639a25a3ccSBarry Smith 
364314da920SBarry Smith /* ----------------------------------------------------------------------------*/
36587828ca2SBarry Smith #define PassiveReal   PetscReal
366ea709b57SSatish Balay #define PassiveScalar PetscScalar
367d3ecb3a7SBarry Smith 
36898725619SBarry Smith /*
36998725619SBarry Smith     These macros are currently hardwired to match the regular data types, so there is no support for a different
37098725619SBarry Smith     MatScalar from PetscScalar. We left the MatScalar in the source just in case we use it again.
37198725619SBarry Smith  */
37298725619SBarry Smith #define MPIU_MATSCALAR MPIU_SCALAR
37398725619SBarry Smith typedef PetscScalar MatScalar;
37498725619SBarry Smith typedef PetscReal MatReal;
37598725619SBarry Smith 
376e9fa29b7SSatish Balay 
377e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
378e489efc1SBarry Smith #endif
379