[petsc-users] Why PETSc needs PetscScalar datatype?
Smith, Barry F.
bsmith at mcs.anl.gov
Sat Aug 4 12:03:04 CDT 2018
For a particular configuration (./configure --with-scalar-type= real or complex) the PETSc objects, such as vectors and matrices either contain real values or complex values. In the same running code it is not possible to have some vectors with real numbers and some vectors with complex numbers.
Depending on how you configure PETSc ./configure --with-scalar-type= real or complex the variable name PetscScalar becomes either PetscReal or PetscComplex. PETSc code is written with PetscScalar so we can reconfigure the same source code and have it work with real numbers or complex.
For users who just work with real numbers you can simply use PetscReal as your variable type. If working with just with complex numbers you can use PetscComplex. If you want to sometimes configure with real numbers and sometimes configure with complex (which is not common) you use PetscScalar.
Barry
> On Aug 4, 2018, at 11:39 AM, Youjun Hu <youjunhu at gmail.com> wrote:
>
> Hi all,
>
> I am just wondering why PETSc introduces PetscScalar datatype in addition to the PetscReal and PetscComplex.
> Could someone help clarify the rationale behind this design?
> I am primarily a Fortran guy. The additional datatype PetscScalar seems to only confuse me rather than provide me any flexibility.
> Cheers,
> Youjun Hu
More information about the petsc-users
mailing list