1*39829747SLisandro Dalcin #if !defined(PETSCCXXCOMPLEXFIX_H) 2*39829747SLisandro Dalcin #define PETSCCXXCOMPLEXFIX_H 3*39829747SLisandro Dalcin #if defined(__cplusplus) && defined(PETSC_HAVE_COMPLEX) && defined(PETSC_HAVE_CXX_COMPLEX) 4*39829747SLisandro Dalcin 5*39829747SLisandro Dalcin #define PETSC_CXX_COMPLEX_FIX(Type) \ 6*39829747SLisandro Dalcin static inline PetscComplex operator+(const PetscComplex& lhs, const Type& rhs) { return lhs + PetscReal(rhs); } \ 7*39829747SLisandro Dalcin static inline PetscComplex operator+(const Type& lhs, const PetscComplex& rhs) { return PetscReal(lhs) + rhs; } \ 8*39829747SLisandro Dalcin static inline PetscComplex operator-(const PetscComplex& lhs, const Type& rhs) { return lhs - PetscReal(rhs); } \ 9*39829747SLisandro Dalcin static inline PetscComplex operator-(const Type& lhs, const PetscComplex& rhs) { return PetscReal(lhs) - rhs; } \ 10*39829747SLisandro Dalcin static inline PetscComplex operator*(const PetscComplex& lhs, const Type& rhs) { return lhs * PetscReal(rhs); } \ 11*39829747SLisandro Dalcin static inline PetscComplex operator*(const Type& lhs, const PetscComplex& rhs) { return PetscReal(lhs) * rhs; } \ 12*39829747SLisandro Dalcin static inline PetscComplex operator/(const PetscComplex& lhs, const Type& rhs) { return lhs / PetscReal(rhs); } \ 13*39829747SLisandro Dalcin static inline PetscComplex operator/(const Type& lhs, const PetscComplex& rhs) { return PetscReal(lhs) / rhs; } \ 14*39829747SLisandro Dalcin static inline bool operator==(const PetscComplex& lhs, const Type& rhs) { return lhs.imag() == PetscReal(0) && lhs.real() == PetscReal(rhs); } \ 15*39829747SLisandro Dalcin static inline bool operator==(const Type& lhs, const PetscComplex& rhs) { return rhs.imag() == PetscReal(0) && rhs.real() == PetscReal(lhs); } \ 16*39829747SLisandro Dalcin static inline bool operator!=(const PetscComplex& lhs, const Type& rhs) { return lhs.imag() != PetscReal(0) || lhs.real() != PetscReal(rhs); } \ 17*39829747SLisandro Dalcin static inline bool operator!=(const Type& lhs, const PetscComplex& rhs) { return rhs.imag() != PetscReal(0) || rhs.real() != PetscReal(lhs); } \ 18*39829747SLisandro Dalcin /* PETSC_CXX_COMPLEX_FIX */ 19*39829747SLisandro Dalcin 20*39829747SLisandro Dalcin #if defined(PETSC_USE_REAL_SINGLE) 21*39829747SLisandro Dalcin PETSC_CXX_COMPLEX_FIX(double) 22*39829747SLisandro Dalcin #elif defined(PETSC_USE_REAL_DOUBLE) 23*39829747SLisandro Dalcin PETSC_CXX_COMPLEX_FIX(PetscInt) 24*39829747SLisandro Dalcin #endif /* PETSC_USE_REAL_* */ 25*39829747SLisandro Dalcin 26*39829747SLisandro Dalcin #endif /* __cplusplus && PETSC_HAVE_COMPLEX && PETSC_HAVE_CXX_COMPLEX */ 27*39829747SLisandro Dalcin #endif 28