How use scalar type and complex type at the same time?

Matthew Knepley knepley at
Wed Aug 20 07:42:58 CDT 2008

On Wed, Aug 20, 2008 at 7:19 AM, Zhifeng Sheng <z.sheng at> wrote:
> Dear all
> I am working on a FEM program, which can be used to solve time domain and
> frequency domain EM problems. I finished the time domain solver part and now
> I need to implement the frequency domain solver.... So I built Petsc with
> --scalar-type = complex, and then my time domain solver can not be compiled,
> it says " can not convert double to PetscScalar".
> Is there any way that I can handle both real matrix and complex matrix at
> the same time? (without changing my old code too much?)

Right now, there is no way to do this, and there seems to be little
possibility in C.
Templating can handle this smoothly, but we would have to convert to C++. We
are weighing the options.


> Thanks
> Best regards
> Zhifeng Sheng
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which
their experiments lead.
-- Norbert Wiener

More information about the petsc-users mailing list