// Divide a PETSc complex number by a real number.
void divide_petsc_complex_by_a_number ()
{
- PetscScalar alpha = 1.0 + 2.0i;
+ PetscScalar alpha = 1.0 + 2.0*PETSC_i;
const PetscScalar beta = alpha/2.;
logfile << " divide a petsc complex by 2.: "
// Initialize a std::complex number from an PETSc complex number
void make_std_complex_from_petsc_complex ()
{
- const PetscScalar alpha = 1.0 + 2.0i;
+ const PetscScalar alpha = 1.0 + 2.0*PETSC_i;
const std::complex<double> beta = alpha;
logfile << " make std::complex from petsc complex: "
// Initialize a PETSc complex number directly.
void make_petsc_complex ()
{
- const PetscScalar alpha = 1.0 + 2.0i;
+ const PetscScalar alpha = 1.0 + 2.0*PETSC_i;
logfile << " make petsc complex: "
<< PetscRealPart (alpha)
// then try to use operators to do the same thing - except it
// seems to work without(!)
logfile << " make std::complex from petsc complex: ";
- const PetscScalar alpha2 = 1.0 + 2.0i;
+ const PetscScalar alpha2 = 1.0 + 2.0*PETSC_i;
std::complex<double> number2;
number2 += alpha2;
<< std::endl;
logfile << " make std::complex from petsc complex: ";
- const PetscScalar alpha3 = 1.0 - 2.0i;
+ const PetscScalar alpha3 = 1.0 - 2.0*PETSC_i;
number2 += alpha3;
logfile << std::real (number2)
+++ /dev/null
-
- make petsc complex: 0.00000+0.00000i should be 0+0i
- make petsc complex: 0.00000+0.00000i should be 0+0i
- make petsc complex: 1.00000+2.00000i should be 1+2i
- make petsc complex from std::complex: 1.00000+2.00000i
- make std::complex from petsc complex: 1.00000+2.00000i
- make petsc complex from std::complex: 1.00000+2.00000i should be 1+2i
- make std::complex from petsc complex: 1.00000+2.00000i should be 1+2i
- make std::complex from petsc complex: 2.00000+0.00000i should be 2+0i
- divide a petsc complex by 2.: 0.500000+1.00000i should be 0.5+1i
- divide-equals a petsc complex by 2.: 0.500000+1.00000i should be 0.5+1i
-