setting complex numbers
Matthew Knepley
knepley at gmail.com
Mon Sep 8 09:56:14 CDT 2008
You have not called PetscInitialize() so PETSC_i has not been defined.
Matt
On Mon, Sep 8, 2008 at 9:44 AM, zhifeng sheng <z.sheng at ewi.tudelft.nl> wrote:
> Dear all
>
> I am now working with the complex version of Petsc but have some serious
> problems...
>
> It turned out that I could not set the imaginary part of a PetscScalar.
> Check the following code:
>
> int main(int argc, char *argv[])
> {
> #if !defined(PETSC_USE_COMPLEX)
> SETERRQ(1,"This example requires complex numbers");
> #endif
> PetscScalar ee = 3.0*PETSC_i;
> PetscScalar x = 4.0 + ee;
> std::cout<<PetscRealPart(x)<<" "<<PetscImaginaryPart(x)<<std::endl;
> }
>
> after compiling and run, it produces
>
>
> 4 0
>
> which means that the imaginary part is set to be zero....
>
> does anyone have this problem before, or could you please tell me what I did
> wrong in this piece of code.
>
> Thanks a lot
> 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