[petsc-dev] how to print with PescPrintf a PetscScalar value?

Luigia Ambrosio ambrosio.luigia at gmail.com
Wed Jul 4 03:15:23 CDT 2012


this is the source code (very simple)
  Vec            x;
  PetscInt       n = 10;
  PetscErrorCode ierr;
  PetscScalar one = 1.0;

  ierr = VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, n, &x);CHKERRQ(ierr);
  ierr = VecSet(x,one);CHKERRQ(ierr);
  PetscScalar sum=0.0;
  ierr = VecSum(x,&sum);CHKERRQ(ierr);
  ierr = PetscPrintf(PETSC_COMM_WORLD,"sum %f\n",(PetscRealPart)sum); CHKERRQ(ierr); puts("");
...

and this is the error message I get trying make myex
  error: 'PetscRealPart' was not declared in this scope

this is how I compile myex
myex: myex.o  chkopts
        -${CLINKER} -o myex myex.o ${PETSC_VEC_LIB}
        ${RM} -f myex.o

I have petsc 3.3 developer version

Luigia Ambrosio

Se la gente ferisce è perchè tu sei migliore e lo capisce bene! - Tiziano Ferro




Il giorno 04/lug/2012, alle ore 09:58, Jed Brown ha scritto:

> On Tue, Jul 3, 2012 at 11:53 PM, Luigia Ambrosio <ambrosio.luigia at gmail.com> wrote:
> It seems I don't have this function. I checked my configuring options, in particular
> --with-scalar-type=complex 
> 
> Which version of PETSc? Can you send the full error message?
>  
> 
> so I'm sure that a PetscScalar variable is handled as a complex number. I tried to use the PetscRealPart but it says:
> error: 'PetscRealPart' was not declared in this scope
> 
> I included also the header "petscmat.h" but there isn't defined this function. 
> It seems that I don't include the right header, I googled it but I didn't find it. Which header shiuld I include?
> 
> That header includes petscmath.h (which you should not include directly).
>  
> thanks
> 
> Luigia Ambrosio
> 
> Se la gente ferisce è perchè tu sei migliore e lo capisce bene! - Tiziano Ferro
> 
> 
> 
> 
> Il giorno 04/lug/2012, alle ore 09:28, Jed Brown ha scritto:
> 
>> On Tue, Jul 3, 2012 at 11:26 PM, Luigia Ambrosio <ambrosio.luigia at gmail.com> wrote:
>> Is there a function already avilable to get the real part of a petscscalar value?
>> 
>> 
>> PetscRealPart() and PetscImaginaryPart() 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120704/612fd4bd/attachment.html>


More information about the petsc-dev mailing list