[petsc-users] How to use PETSc real version and complex version simultaneously?

Matthew Knepley knepley at gmail.com
Wed Apr 5 13:04:36 CDT 2023


On Wed, Apr 5, 2023 at 1:59 PM gaochenyi14 <gaochenyi14 at 163.com> wrote:

> Hi,
>
> I rely on PETSc to deal with real and complex sparse matrices of dimension
> 1e4 * 1e4 or above. I want to use real version when only real matrices are
> involved, to achieve better performance, and use complex version only when
> complex matrices get involved. But in the manual it says different versions
> can not be used at the same time. Can this restriction be circumvented? If
> not, where does the restriction come from?
>

It is possible to do this, but it is cumbersome. You would have to compile
both versions of the library, dlopen() them, and get the symbols you need.
A group at Purdue has done this, but it is involved.

We use typedefs to change between real and complex. It would not be
difficult to allow storage in several types. However, prescribing how one
type interactes with another, particularly when data is passed in or out,
is challenging. This difficulty does not go away with templates since it is
about type interaction, not polymorphism.

  Thanks,

     Matt


> All the best,
> C.-Y. GAO
>


-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230405/c10e719c/attachment-0001.html>


More information about the petsc-users mailing list