xref: /petsc/include/petscmath.h (revision 0d0cc1b5d2b67ade4c84155aeb27e352abeca5a9)
1e489efc1SBarry Smith /*
2314da920SBarry Smith 
3314da920SBarry Smith       PETSc mathematics include file. Defines certain basic mathematical
4314da920SBarry Smith     constants and functions for working with single and double precision
5314da920SBarry Smith     floating point numbers as well as complex and integers.
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;
18314da920SBarry Smith /*
19f4ccad53SBarry Smith 
20f4ccad53SBarry Smith      Defines operations that are different for complex and real numbers;
21f4ccad53SBarry Smith    note that one cannot really 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()
2859cb5930SBarry Smith 
291093a601SBarry Smith /*
301093a601SBarry Smith     Complex number definitions
311093a601SBarry Smith  */
32aa482453SBarry Smith #if defined(PETSC_USE_COMPLEX)
33b7940d39SSatish Balay #if defined(PETSC_CLANGUAGE_CXX)
341093a601SBarry Smith /* C++ support of complex number */
35df9b3741SSatish Balay #include <complex>
36adc17e78SSatish Balay 
37329f5518SBarry Smith #define PetscRealPart(a)      (a).real()
38329f5518SBarry Smith #define PetscImaginaryPart(a) (a).imag()
393f6de6efSSatish Balay #define PetscAbsScalar(a)     std::abs(a)
403f6de6efSSatish Balay #define PetscConj(a)          std::conj(a)
4118a7d68fSSatish Balay #define PetscSqrtScalar(a)    std::sqrt(a)
42184914b5SBarry Smith #define PetscPowScalar(a,b)   std::pow(a,b)
43184914b5SBarry Smith #define PetscExpScalar(a)     std::exp(a)
4406c1185fSBarry Smith #define PetscLogScalar(a)     std::log(a)
45184914b5SBarry Smith #define PetscSinScalar(a)     std::sin(a)
46184914b5SBarry Smith #define PetscCosScalar(a)     std::cos(a)
470bfd3fbfSBarry Smith 
4865460251SBarry Smith #if defined(PETSC_USE_SCALAR_SINGLE)
494a60b672SMatthew Knepley typedef std::complex<float> PetscScalar;
501093a601SBarry Smith #elif defined(PETSC_USE_SCALAR_DOUBLE)
511093a601SBarry Smith typedef std::complex<double> PetscScalar;
5265460251SBarry Smith #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
534a60b672SMatthew Knepley typedef std::complex<long double> PetscScalar;
544a60b672SMatthew Knepley #endif
55b7940d39SSatish Balay 
561093a601SBarry Smith #else
571093a601SBarry Smith /*  C support of complex numbers: Requires C99 compliant compiler*/
581093a601SBarry Smith #include <complex.h>
59b7940d39SSatish Balay 
6065460251SBarry Smith #if defined(PETSC_USE_SCALAR_SINGLE)
6185b47369SMatthew Knepley typedef float complex PetscScalar;
6285b47369SMatthew Knepley 
6385b47369SMatthew Knepley #define PetscRealPart(a)      crealf(a)
6485b47369SMatthew Knepley #define PetscImaginaryPart(a) cimagf(a)
6585b47369SMatthew Knepley #define PetscAbsScalar(a)     cabsf(a)
6685b47369SMatthew Knepley #define PetscConj(a)          conjf(a)
6785b47369SMatthew Knepley #define PetscSqrtScalar(a)    csqrtf(a)
6885b47369SMatthew Knepley #define PetscPowScalar(a,b)   cpowf(a,b)
6985b47369SMatthew Knepley #define PetscExpScalar(a)     cexpf(a)
7006c1185fSBarry Smith #define PetscLogScalar(a)     clogf(a)
7185b47369SMatthew Knepley #define PetscSinScalar(a)     csinf(a)
7285b47369SMatthew Knepley #define PetscCosScalar(a)     ccosf(a)
731093a601SBarry Smith 
741093a601SBarry Smith #elif defined(PETSC_USE_SCALAR_DOUBLE)
751093a601SBarry Smith typedef double complex PetscScalar;
761093a601SBarry Smith 
771093a601SBarry Smith #define PetscRealPart(a)      creal(a)
781093a601SBarry Smith #define PetscImaginaryPart(a) cimag(a)
791093a601SBarry Smith #define PetscAbsScalar(a)     cabs(a)
801093a601SBarry Smith #define PetscConj(a)          conj(a)
811093a601SBarry Smith #define PetscSqrtScalar(a)    csqrt(a)
821093a601SBarry Smith #define PetscPowScalar(a,b)   cpow(a,b)
831093a601SBarry Smith #define PetscExpScalar(a)     cexp(a)
841093a601SBarry Smith #define PetscLogScalar(a)     clog(a)
851093a601SBarry Smith #define PetscSinScalar(a)     csin(a)
861093a601SBarry Smith #define PetscCosScalar(a)     ccos(a)
871093a601SBarry Smith 
8865460251SBarry Smith #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
8985b47369SMatthew Knepley typedef long double complex PetscScalar;
9085b47369SMatthew Knepley 
9185b47369SMatthew Knepley #define PetscRealPart(a)      creall(a)
9285b47369SMatthew Knepley #define PetscImaginaryPart(a) cimagl(a)
9385b47369SMatthew Knepley #define PetscAbsScalar(a)     cabsl(a)
9485b47369SMatthew Knepley #define PetscConj(a)          conjl(a)
9585b47369SMatthew Knepley #define PetscSqrtScalar(a)    csqrtl(a)
9685b47369SMatthew Knepley #define PetscPowScalar(a,b)   cpowl(a,b)
9785b47369SMatthew Knepley #define PetscExpScalar(a)     cexpl(a)
9806c1185fSBarry Smith #define PetscLogScalar(a)     clogl(a)
9985b47369SMatthew Knepley #define PetscSinScalar(a)     csinl(a)
10085b47369SMatthew Knepley #define PetscCosScalar(a)     ccosl(a)
10185b47369SMatthew Knepley 
102b7940d39SSatish Balay #endif
1034a60b672SMatthew Knepley #endif
104e489efc1SBarry Smith 
1052c876bd9SBarry Smith #if !defined(PETSC_HAVE_MPI_C_DOUBLE_COMPLEX)
1067087cfbeSBarry Smith extern  MPI_Datatype  MPI_C_DOUBLE_COMPLEX;
1077087cfbeSBarry Smith extern  MPI_Datatype  MPI_C_COMPLEX;
1082c876bd9SBarry Smith #endif
1092c876bd9SBarry Smith 
110a83b8d76SBarry Smith #if defined(PETSC_USE_SCALAR_SINGLE)
111a83b8d76SBarry Smith #define MPIU_SCALAR MPI_C_COMPLEX
1121093a601SBarry Smith #elif defined(PETSC_USE_SCALAR_DOUBLE)
1132c876bd9SBarry Smith #define MPIU_SCALAR MPI_C_DOUBLE_COMPLEX
1141093a601SBarry Smith #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
1151093a601SBarry Smith #define MPIU_SCALAR error
116a83b8d76SBarry Smith #endif
11775567043SBarry Smith 
1181093a601SBarry Smith /*
1191093a601SBarry Smith     real number definitions
1201093a601SBarry Smith  */
121e489efc1SBarry Smith #else
12265460251SBarry Smith #if defined(PETSC_USE_SCALAR_SINGLE)
12387828ca2SBarry Smith #define MPIU_SCALAR           MPI_FLOAT
1241093a601SBarry Smith typedef float PetscScalar;
1251093a601SBarry Smith #elif defined(PETSC_USE_SCALAR_DOUBLE)
1261093a601SBarry Smith #define MPIU_SCALAR           MPI_DOUBLE
1271093a601SBarry Smith typedef double PetscScalar;
12865460251SBarry Smith #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
129f68b968cSBarry Smith #define MPIU_SCALAR           MPI_LONG_DOUBLE
1301093a601SBarry Smith typedef long double PetscScalar;
131*0d0cc1b5SBarry Smith #elif defined(PETSC_USE_SCALAR___FLOAT128)
132*0d0cc1b5SBarry Smith extern MPI_Datatype MPIU_SCALAR;
133*0d0cc1b5SBarry Smith typedef __float128 PetscScalar;
13487828ca2SBarry Smith #endif
135329f5518SBarry Smith #define PetscRealPart(a)      (a)
13675567043SBarry Smith #define PetscImaginaryPart(a) (0.)
137e489efc1SBarry Smith #define PetscAbsScalar(a)     (((a)<0.0)   ? -(a) : (a))
138e489efc1SBarry Smith #define PetscConj(a)          (a)
139*0d0cc1b5SBarry Smith #if !defined(PETSC_USE_SCALAR___FLOAT128)
14018a7d68fSSatish Balay #define PetscSqrtScalar(a)    sqrt(a)
141184914b5SBarry Smith #define PetscPowScalar(a,b)   pow(a,b)
142184914b5SBarry Smith #define PetscExpScalar(a)     exp(a)
14306c1185fSBarry Smith #define PetscLogScalar(a)     log(a)
144184914b5SBarry Smith #define PetscSinScalar(a)     sin(a)
145184914b5SBarry Smith #define PetscCosScalar(a)     cos(a)
146*0d0cc1b5SBarry Smith #else
147*0d0cc1b5SBarry Smith #include <quadmath.h>
148*0d0cc1b5SBarry Smith #define PetscSqrtScalar(a)    sqrtq(a)
149*0d0cc1b5SBarry Smith #define PetscPowScalar(a,b)   powq(a,b)
150*0d0cc1b5SBarry Smith #define PetscExpScalar(a)     expq(a)
151*0d0cc1b5SBarry Smith #define PetscLogScalar(a)     logq(a)
152*0d0cc1b5SBarry Smith #define PetscSinScalar(a)     sinq(a)
153*0d0cc1b5SBarry Smith #define PetscCosScalar(a)     cosq(a)
154*0d0cc1b5SBarry Smith #endif
155b0a32e0cSBarry Smith 
156e489efc1SBarry Smith #endif
157e489efc1SBarry Smith 
15865460251SBarry Smith #if defined(PETSC_USE_SCALAR_SINGLE)
159d7d1e502SBarry Smith #define MPIU_REAL   MPI_FLOAT
1601093a601SBarry Smith typedef float PetscReal;
1611093a601SBarry Smith #elif defined(PETSC_USE_SCALAR_DOUBLE)
1621093a601SBarry Smith #define MPIU_REAL   MPI_DOUBLE
1631093a601SBarry Smith typedef double PetscReal;
16465460251SBarry Smith #elif defined(PETSC_USE_SCALAR_LONG_DOUBLE)
165f68b968cSBarry Smith #define MPIU_REAL   MPI_LONG_DOUBLE
1661093a601SBarry Smith typedef long double PetscReal;
167*0d0cc1b5SBarry Smith #elif defined(PETSC_USE_SCALAR___FLOAT128)
168*0d0cc1b5SBarry Smith extern MPI_Datatype MPIU_REAL;
169*0d0cc1b5SBarry Smith typedef __float128 PetscReal;
170d7d1e502SBarry Smith #endif
171d7d1e502SBarry Smith 
172da9b6338SBarry Smith #define PetscSign(a) (((a) >= 0) ? ((a) == 0 ? 0 : 1) : -1)
17326aa1773SMatthew Knepley #define PetscAbs(a)  (((a) >= 0) ? (a) : -(a))
1743f1db9ecSBarry Smith 
175314da920SBarry Smith /* --------------------------------------------------------------------------*/
176314da920SBarry Smith 
177e489efc1SBarry Smith /*
178f22f69f0SBarry Smith    Certain objects may be created using either single or double precision.
179f22f69f0SBarry Smith    This is currently not used.
180e489efc1SBarry Smith */
181557d4da8SBarry Smith typedef enum { PETSC_SCALAR_DOUBLE,PETSC_SCALAR_SINGLE, PETSC_SCALAR_LONG_DOUBLE } PetscScalarPrecision;
182e489efc1SBarry Smith 
183e489efc1SBarry Smith /* PETSC_i is the imaginary number, i */
1847087cfbeSBarry Smith extern  PetscScalar  PETSC_i;
185e489efc1SBarry Smith 
186b6a5bde7SBarry Smith /*MC
187b6a5bde7SBarry Smith    PetscMin - Returns minimum of two numbers
188b6a5bde7SBarry Smith 
189eca87e8dSBarry Smith    Synopsis:
190eca87e8dSBarry Smith    type PetscMin(type v1,type v2)
191eca87e8dSBarry Smith 
192eca87e8dSBarry Smith    Not Collective
193eca87e8dSBarry Smith 
194b6a5bde7SBarry Smith    Input Parameter:
195b6a5bde7SBarry Smith +  v1 - first value to find minimum of
196b6a5bde7SBarry Smith -  v2 - second value to find minimum of
197b6a5bde7SBarry Smith 
198b6a5bde7SBarry Smith 
199b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
200b6a5bde7SBarry Smith 
201b6a5bde7SBarry Smith    Level: beginner
202b6a5bde7SBarry Smith 
203b6a5bde7SBarry Smith 
204b6a5bde7SBarry Smith .seealso: PetscMin(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
205b6a5bde7SBarry Smith 
206b6a5bde7SBarry Smith M*/
207e489efc1SBarry Smith #define PetscMin(a,b)   (((a)<(b)) ?  (a) : (b))
208b6a5bde7SBarry Smith 
209b6a5bde7SBarry Smith /*MC
210b6a5bde7SBarry Smith    PetscMax - Returns maxium of two numbers
211b6a5bde7SBarry Smith 
212eca87e8dSBarry Smith    Synopsis:
213eca87e8dSBarry Smith    type max PetscMax(type v1,type v2)
214eca87e8dSBarry Smith 
215eca87e8dSBarry Smith    Not Collective
216eca87e8dSBarry Smith 
217b6a5bde7SBarry Smith    Input Parameter:
218b6a5bde7SBarry Smith +  v1 - first value to find maximum of
219b6a5bde7SBarry Smith -  v2 - second value to find maximum of
220b6a5bde7SBarry Smith 
221b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
222b6a5bde7SBarry Smith 
223b6a5bde7SBarry Smith    Level: beginner
224b6a5bde7SBarry Smith 
225b6a5bde7SBarry Smith .seealso: PetscMin(), PetscAbsInt(), PetscAbsReal(), PetscSqr()
226b6a5bde7SBarry Smith 
227b6a5bde7SBarry Smith M*/
228e489efc1SBarry Smith #define PetscMax(a,b)   (((a)<(b)) ?  (b) : (a))
229b6a5bde7SBarry Smith 
230b6a5bde7SBarry Smith /*MC
231b6a5bde7SBarry Smith    PetscAbsInt - Returns the absolute value of an integer
232b6a5bde7SBarry Smith 
233b6a5bde7SBarry Smith    Synopsis:
234b6a5bde7SBarry Smith    int abs PetscAbsInt(int v1)
235b6a5bde7SBarry Smith 
236eca87e8dSBarry Smith    Not Collective
237eca87e8dSBarry Smith 
238eca87e8dSBarry Smith    Input Parameter:
239eca87e8dSBarry Smith .   v1 - the integer
240b6a5bde7SBarry Smith 
241b6a5bde7SBarry Smith    Level: beginner
242b6a5bde7SBarry Smith 
243b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsReal(), PetscSqr()
244b6a5bde7SBarry Smith 
245b6a5bde7SBarry Smith M*/
246e489efc1SBarry Smith #define PetscAbsInt(a)  (((a)<0)   ? -(a) : (a))
247b6a5bde7SBarry Smith 
248b6a5bde7SBarry Smith /*MC
249b6a5bde7SBarry Smith    PetscAbsReal - Returns the absolute value of an real number
250b6a5bde7SBarry Smith 
251eca87e8dSBarry Smith    Synopsis:
252eca87e8dSBarry Smith    Real abs PetscAbsReal(PetscReal v1)
253eca87e8dSBarry Smith 
254eca87e8dSBarry Smith    Not Collective
255eca87e8dSBarry Smith 
256b6a5bde7SBarry Smith    Input Parameter:
257b6a5bde7SBarry Smith .   v1 - the double
258b6a5bde7SBarry Smith 
259b6a5bde7SBarry Smith 
260b6a5bde7SBarry Smith    Level: beginner
261b6a5bde7SBarry Smith 
262b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsInt(), PetscSqr()
263b6a5bde7SBarry Smith 
264b6a5bde7SBarry Smith M*/
265f6275e2eSBarry Smith #define PetscAbsReal(a) (((a)<0)   ? -(a) : (a))
266b6a5bde7SBarry Smith 
267b6a5bde7SBarry Smith /*MC
268b6a5bde7SBarry Smith    PetscSqr - Returns the square of a number
269b6a5bde7SBarry Smith 
270b6a5bde7SBarry Smith    Synopsis:
271b6a5bde7SBarry Smith    type sqr PetscSqr(type v1)
272b6a5bde7SBarry Smith 
273eca87e8dSBarry Smith    Not Collective
274eca87e8dSBarry Smith 
275eca87e8dSBarry Smith    Input Parameter:
276eca87e8dSBarry Smith .   v1 - the value
277eca87e8dSBarry Smith 
278b6a5bde7SBarry Smith    Notes: type can be integer or floating point value
279b6a5bde7SBarry Smith 
280b6a5bde7SBarry Smith    Level: beginner
281b6a5bde7SBarry Smith 
282b6a5bde7SBarry Smith .seealso: PetscMax(), PetscMin(), PetscAbsInt(), PetscAbsReal()
283b6a5bde7SBarry Smith 
284b6a5bde7SBarry Smith M*/
2854ebda54eSMatthew Knepley #define PetscSqr(a)     ((a)*(a))
286e489efc1SBarry Smith 
287314da920SBarry Smith /* ----------------------------------------------------------------------------*/
288314da920SBarry Smith /*
28903c60df9SBarry Smith      Basic constants - These should be done much better
290314da920SBarry Smith */
291314da920SBarry Smith #define PETSC_PI                 3.14159265358979323846264
292314da920SBarry Smith #define PETSC_DEGREES_TO_RADIANS 0.01745329251994
29371fd2e92SBarry Smith #define PETSC_MAX_INT            2147483647
29471fd2e92SBarry Smith #define PETSC_MIN_INT            -2147483647
295e489efc1SBarry Smith 
29665460251SBarry Smith #if defined(PETSC_USE_SCALAR_SINGLE)
2977e032f8bSBarry Smith #  define PETSC_MAX                     1.e30
2987e032f8bSBarry Smith #  define PETSC_MIN                    -1.e30
299f10639e6SSatish Balay #  define PETSC_MACHINE_EPSILON         1.e-7
300f10639e6SSatish Balay #  define PETSC_SQRT_MACHINE_EPSILON    3.e-4
301cf6e855fSSatish Balay #  define PETSC_SMALL                   1.e-5
30282adfdadSBarry Smith #else
3037e032f8bSBarry Smith #  define PETSC_MAX                     1.e300
3047e032f8bSBarry Smith #  define PETSC_MIN                    -1.e300
305f10639e6SSatish Balay #  define PETSC_MACHINE_EPSILON         1.e-14
306f10639e6SSatish Balay #  define PETSC_SQRT_MACHINE_EPSILON    1.e-7
307cf6e855fSSatish Balay #  define PETSC_SMALL                   1.e-10
30882adfdadSBarry Smith #endif
30982adfdadSBarry Smith 
3109cf09972SJed Brown #if defined PETSC_HAVE_ADIC
3119cf09972SJed Brown /* Use MPI_Allreduce when ADIC is not available. */
3127087cfbeSBarry Smith extern PetscErrorCode  PetscGlobalMax(MPI_Comm, const PetscReal*,PetscReal*);
3137087cfbeSBarry Smith extern PetscErrorCode  PetscGlobalMin(MPI_Comm, const PetscReal*,PetscReal*);
3147087cfbeSBarry Smith extern PetscErrorCode  PetscGlobalSum(MPI_Comm, const PetscScalar*,PetscScalar*);
3159cf09972SJed Brown #endif
3163e523bebSBarry Smith 
3170763cb5fSBarry Smith /*MC
3180763cb5fSBarry Smith       PetscIsInfOrNan - Returns 1 if the input double has an infinity for Not-a-number (Nan) value, otherwise 0.
3193e523bebSBarry Smith 
3200763cb5fSBarry Smith     Input Parameter:
3210763cb5fSBarry Smith .     a - the double
3220763cb5fSBarry Smith 
3230763cb5fSBarry Smith 
3240763cb5fSBarry Smith      Notes: uses the C99 standard isinf() and isnan() on systems where they exist.
32583886165SBarry Smith       Otherwises uses ( (a - a) != 0.0), note that some optimizing compiles compile
3260763cb5fSBarry Smith       out this form, thus removing the check.
3270763cb5fSBarry Smith 
32883672c4dSSatish Balay      Level: beginner
32983672c4dSSatish Balay 
33083672c4dSSatish Balay M*/
3319a25a3ccSBarry Smith #if defined(PETSC_HAVE_ISINF) && defined(PETSC_HAVE_ISNAN)
33262cbcd01SMatthew G Knepley PETSC_STATIC_INLINE PetscErrorCode PetscIsInfOrNanScalar(PetscScalar a) {
33362cbcd01SMatthew G Knepley   return isinf(PetscAbsScalar(a)) || isnan(PetscAbsScalar(a));
33462cbcd01SMatthew G Knepley }
33562cbcd01SMatthew G Knepley PETSC_STATIC_INLINE PetscErrorCode PetscIsInfOrNanReal(PetscReal a) {
33662cbcd01SMatthew G Knepley   return isinf(a) || isnan(a);
33762cbcd01SMatthew G Knepley }
33862b4c0b3SBarry Smith #elif defined(PETSC_HAVE__FINITE) && defined(PETSC_HAVE__ISNAN)
339270b8587SSatish Balay #if defined(PETSC_HAVE_FLOAT_H)
34098725619SBarry Smith #include "float.h"  /* Microsoft Windows defines _finite() in float.h */
341270b8587SSatish Balay #endif
342961faeafSBarry Smith #if defined(PETSC_HAVE_IEEEFP_H)
343961faeafSBarry Smith #include "ieeefp.h"  /* Solaris prototypes these here */
344961faeafSBarry Smith #endif
34598725619SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscIsInfOrNanScalar(PetscScalar a) {
34698725619SBarry Smith   return !_finite(PetscAbsScalar(a)) || _isnan(PetscAbsScalar(a));
34798725619SBarry Smith }
34898725619SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscIsInfOrNanReal(PetscReal a) {
34998725619SBarry Smith   return !_finite(a) || _isnan(a);
35098725619SBarry Smith }
3519a25a3ccSBarry Smith #else
35298725619SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscIsInfOrNanScalar(PetscScalar a) {
35398725619SBarry Smith   return  ((a - a) != 0.0);
35498725619SBarry Smith }
35598725619SBarry Smith PETSC_STATIC_INLINE PetscErrorCode PetscIsInfOrNanReal(PetscReal a) {
35698725619SBarry Smith   return ((a - a) != 0.0);
35798725619SBarry Smith }
3589a25a3ccSBarry Smith #endif
3599a25a3ccSBarry Smith 
3609a25a3ccSBarry Smith 
361314da920SBarry Smith /* ----------------------------------------------------------------------------*/
362e489efc1SBarry Smith /*
363b0a32e0cSBarry Smith     PetscLogDouble variables are used to contain double precision numbers
364e489efc1SBarry Smith   that are not used in the numerical computations, but rather in logging,
365e489efc1SBarry Smith   timing etc.
366e489efc1SBarry Smith */
367b0a32e0cSBarry Smith typedef double PetscLogDouble;
368b9617806SBarry Smith #define MPIU_PETSCLOGDOUBLE MPI_DOUBLE
369e489efc1SBarry Smith 
37087828ca2SBarry Smith #define PassiveReal   PetscReal
371ea709b57SSatish Balay #define PassiveScalar PetscScalar
372d3ecb3a7SBarry Smith 
37398725619SBarry Smith /*
37498725619SBarry Smith     These macros are currently hardwired to match the regular data types, so there is no support for a different
37598725619SBarry Smith     MatScalar from PetscScalar. We left the MatScalar in the source just in case we use it again.
37698725619SBarry Smith  */
37798725619SBarry Smith #define MPIU_MATSCALAR MPIU_SCALAR
37898725619SBarry Smith typedef PetscScalar MatScalar;
37998725619SBarry Smith typedef PetscReal MatReal;
38098725619SBarry Smith 
381e9fa29b7SSatish Balay 
382e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
383e489efc1SBarry Smith #endif
384