[petsc-users] Binary format in real vs. complex scalar type configurations
Frederico Teixeira
teixeira at zmt.swiss
Tue May 11 15:19:30 CDT 2021
Hi Matt,
Thanks for your tip.
I will take a look at the "MatLoad()" implementation tomorrow and return to you to discuss it further. It sounds like a good strategy.
Regards,
Frederico.
Dr. Frederico Teixeira
Computational Modeler and Software Developer, [ http://www.itis.swiss/ | ZMT ] (member of [ https://www.z43.swiss/ | Zurich43 ] )
P +41 44 245 9698
Zeughausstrasse 43, 8004 Zurich, Switzerland
From: "Matthew Knepley" <knepley at gmail.com>
To: "Pierre Jolivet" <pierre at joliv.et>
Cc: "Frederico Teixeira" <teixeira at zmt.swiss>, "petsc-users" <petsc-users at mcs.anl.gov>
Sent: Tuesday, May 11, 2021 6:26:46 PM
Subject: Re: [petsc-users] Binary format in real vs. complex scalar type configurations
On Tue, May 11, 2021 at 12:03 PM Pierre Jolivet < [ mailto:pierre at joliv.et | pierre at joliv.et ] > wrote:
Hello Frederico,
I’m not sure that’s possible.
Here is what I do, it makes me sick, but mixing precisions/scalar types with PETSc is difficult (crossing my fingers this will be better with future).
In MATLAB (after putting petsc/share/petsc/matlab in the path):
A = PetscBinaryRead('your_binary_mat_with_re+im.dat','complex',true); % scalar-type=complex
PetscBinaryWrite('re.dat',real(A)); % scalar-type=real
PetscBinaryWrite('im.dat',imag(A)); % scalar-type=real
So what you want to happen is that MatLoad() looks at the datatype, sees that it is complex and PetscScalar is real, and returns two matrices with the real and imaginary parts?
The hard part is that the MatLoad interface returns a single matrix. I guess we could have a flag that says what to do with complex numbers (read real, read imaginary, read norm, etc.)
and you could read it twice. Would that work?
Thanks,
Matt
BQ_BEGIN
Thanks,
Pierre
BQ_BEGIN
On 11 May 2021, at 3:30 PM, Frederico Teixeira < [ mailto:teixeira at zmt.swiss | teixeira at zmt.swiss ] > wrote:
Dear fellows,
I hope this message finds you safe and well.
I have a complex-valued matrix and its real/imaginary components in binary format . They were extracted from a solver that only works with "scalar-type=complex" configuration.
I am getting weird results when I load them into a small test program that's configured with "scalar-type=real", but I believe this is expected.
At the end of the day, I would like to have both real and imaginary components as real-valued matrices.
Is it possible to do it? I want to test preconditioners that are tailored for this sort of problem.
Regards,
Frederico.
BQ_END
BQ_END
--
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
[ http://www.cse.buffalo.edu/~knepley/ | https://www.cse.buffalo.edu/~knepley/ ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210511/c62a1790/attachment-0001.html>
More information about the petsc-users
mailing list