# PetscComplex
PETSc type that represents a complex number with precision matching that of `PetscReal`. 
## Synopsis
```
#include <petscsys.h>
PetscComplex number = 1. + 2.*PETSC_i;
```

## Notes
For MPI calls that require datatypes, use `MPIU_COMPLEX` as the datatype for `PetscComplex` and `MPIU_SUM` etc for operations.
They will automatically work correctly regardless of the size of `PetscComplex`.

See PetscScalar for details on how to ./configure the size of `PetscReal`

Complex numbers are automatically available if PETSc was able to find a working complex implementation

Petsc has a 'fix' for complex numbers to support expressions such as std::complex<PetscReal> + `PetscInt`, which are not supported by the standard
C++ library, but are convenient for petsc users. If the C++ compiler is able to compile code in petsccxxcomplexfix.h (This is checked by
configure), we include petsccxxcomplexfix.h to provide this convenience.

If the fix causes conflicts, or one really does not want this fix for a particular C++ file, one can define `PETSC_SKIP_CXX_COMPLEX_FIX`
at the beginning of the C++ file to skip the fix.




## See Also
 `PetscReal`, `PetscScalar`, `PetscComplex`, `PetscInt`, `MPIU_REAL`, `MPIU_SCALAR`, `MPIU_COMPLEX`, `MPIU_INT`, `PETSC_i`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscsystypes.h.html#PetscComplex">include/petscsystypes.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscsystypes.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
