The version of Petsc installed on my machine has PetscScalar set to be complex. I am making a matrix which has all real entries.Something like the following code compiles:PetscScalar value_for_matrix;value_for_matrix=some+expression+that*returns_PetscReal;Is the real value returned by the right hand side put into the real part of the PetscScalar value?If this doesn't work, how should I put a PetscReal value into the real part of a complex PetscScalar?
Implicitly casting PetscReal to the real part of PetscComplex
petsc;c;complex
Yes, this does exactly what you would expect. If you want to create a complex number explicitly, you can multiply real values by PETSC_i. Note that you can use PetscRealPart(), PetscImaginaryPart(), PetscAbsScalar(), and PetscConj() to manipulate complex numbers.