Binary format in real vs. complex scalar type configurations
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.
On Tue, May 11, 2021 at 9:30 AM Frederico Teixeira <[email protected]> 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.
Do you mean you want what is called "equivalent real form" where the real and complex parts are stored as type 'double' for example and operations like multiply take two pairs of doubles, do a complex multiply manually, and return a real/complex pair of doubles?
Regards, Frederico.
Hi Mark, I think so. The complex-valued linear system Ax = b, with A=T+Wi, u=x+yi, b=p+qi (i is the unit complex) can be transformed into a 2x2 real-valued system: [ T -W ] (x) = (p) [ W T ] (y) (q) Perhaps a bit more background can clarify things. System A stems from a Poisson equation with complex coefficients. There are ~130 piecewise constant coefficients ranging across 5 orders of magnitude. Most of the KSPs and PCs I managed to test take between 6000-9000 iterations to reach 10^-9. I hope to get some speed up with preconditioners that exploit the structure above. 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: "Mark Adams" <[email protected]> To: "Frederico Teixeira" <[email protected]> Cc: "petsc-users" <[email protected]> Sent: Tuesday, May 11, 2021 5:16:35 PM Subject: Re: [petsc-users] Binary format in real vs. complex scalar type configurations On Tue, May 11, 2021 at 9:30 AM Frederico Teixeira <[email protected]> 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. Do you mean you want what is called "equivalent real form" where the real and complex parts are stored as type 'double' for example and operations like multiply take two pairs of doubles, do a complex multiply manually, and return a real/complex pair of doubles? BQ_BEGIN Regards, Frederico. BQ_END
On Tue, May 11, 2021 at 4:03 PM Frederico Teixeira <[email protected]> wrote:
Hi Mark,
I think so. The complex-valued linear system Ax = b, with A=T+Wi, u=x+yi, b=p+qi (i is the unit complex) can be transformed into a 2x2 real-valued system: [ T -W ] (x) = (p) [ W T ] (y) (q)
Yes, this is ERF.
Perhaps a bit more background can clarify things. System A stems from a Poisson equation with complex coefficients. There are ~130 piecewise constant coefficients ranging across 5 orders of magnitude.
I assume these are big jumps, are they? You might be able to use GAMG or Hypre and tune the threshold to "see" these jumps if they are big enough. In general large random coefficient jumps are hard with generic AMG. You have 130 patches so a coarse grid could in theory resolve this structure with a not too large "grid" This may not be clear, but I would start with a real valued version of this and see if you can tune Hypre or GAMG to work OK. This could be done with, as I said, tuning the threshold parameter so that coarsening "sees" your jumps and respects them. Next, use a coarse grid solve that is big enough to capture the geometry of your jumps, approximately, where an exact solver is used and it does not care about jumps. As far as ERF, if you can translate it into a (complex) PetscScalar matrix somehow then you can use GAMG. I don't know about Hypre. Or, I have used ERF with some success. A long time ago. You want to interleave the real and complex parts. How big is |W| / |T| ? If this is small it should work OK, but it is hard to be sure.
Most of the KSPs and PCs I managed to test take between 6000-9000 iterations to reach 10^-9. I hope to get some speed up with preconditioners that exploit the structure above.
Regards, Frederico.
Dr. Frederico Teixeira Computational Modeler and Software Developer, ZMT <http://www.itis.swiss> (member of Zurich43 <https://www.z43.swiss>)
P +41 44 245 9698 Zeughausstrasse 43, 8004 Zurich, Switzerland
------------------------------ *From: *"Mark Adams" <[email protected]> *To: *"Frederico Teixeira" <[email protected]> *Cc: *"petsc-users" <[email protected]> *Sent: *Tuesday, May 11, 2021 5:16:35 PM *Subject: *Re: [petsc-users] Binary format in real vs. complex scalar type configurations
On Tue, May 11, 2021 at 9:30 AM Frederico Teixeira <[email protected]> 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.
Do you mean you want what is called "equivalent real form" where the real and complex parts are stored as type 'double' for example and operations like multiply take two pairs of doubles, do a complex multiply manually, and return a real/complex pair of doubles?
Regards, Frederico.
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 Thanks, Pierre
On 11 May 2021, at 3:30 PM, Frederico Teixeira <[email protected]> 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.
On Tue, May 11, 2021 at 12:03 PM Pierre Jolivet <[email protected]> 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
Thanks, Pierre
On 11 May 2021, at 3:30 PM, Frederico Teixeira <[email protected]> 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.
-- 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/>
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" <[email protected]> To: "Pierre Jolivet" <[email protected]> Cc: "Frederico Teixeira" <[email protected]>, "petsc-users" <[email protected]> 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:[email protected] | [email protected] ] > 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:[email protected] | [email protected] ] > 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/ ]
On 11 May 2021, at 6:26 PM, Matthew Knepley <[email protected]> wrote:
On Tue, May 11, 2021 at 12:03 PM Pierre Jolivet <[email protected] <mailto:[email protected]>> 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.
There is Mat[Real,Imaginary]Part(), maybe there could be Mat[Real,Imaginary]PartLoad()? It will be inefficient (complex Mat read twice in a very naive implementation), but functional and would not require tinkering with the options (but maybe you had something clear in mind). Also, just for reference, https://gitlab.com/petsc/petsc/-/issues/901 <https://gitlab.com/petsc/petsc/-/issues/901>. Frederico, as Barry wrote, it will work with Octave or Python. In fact, it will work in any code that does not include petsc.h or link to libpetsc. If you want to stick to C, I think you could simply copy/paste the MatLoad_SeqAIJ_Binary() implementation https://www.mcs.anl.gov/petsc/petsc-3.15.0/src/mat/impls/aij/seq/aij.c.html#... <https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/aij/seq/aij.c.html#line4811> and replace PETSC_SCALAR line 4861 by PETSC_COMPLEX. Then, as Matt wrote, instead of assembling a single Mat, assemble two Mats by splitting a->a in two PetscScalar arrays (remember that this is for your scalar-type=real configuration). Thanks, Pierre
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
Thanks, Pierre
On 11 May 2021, at 3:30 PM, Frederico Teixeira <[email protected] <mailto:[email protected]>> 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.
-- 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/>
On Wed, May 12, 2021 at 2:17 AM Pierre Jolivet <[email protected]> wrote:
On 11 May 2021, at 6:26 PM, Matthew Knepley <[email protected]> wrote:
On Tue, May 11, 2021 at 12:03 PM Pierre Jolivet <[email protected]> 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.
There is Mat[Real,Imaginary]Part(), maybe there could be Mat[Real,Imaginary]PartLoad()? It will be inefficient (complex Mat read twice in a very naive implementation), but functional and would not require tinkering with the options (but maybe you had something clear in mind). Also, just for reference, https://gitlab.com/petsc/petsc/-/issues/901.
Frederico, as Barry wrote, it will work with Octave or Python. In fact, it will work in any code that does not include petsc.h or link to libpetsc. If you want to stick to C, I think you could simply copy/paste the MatLoad_SeqAIJ_Binary() implementation https://www.mcs.anl.gov/petsc/petsc-3.15.0/src/mat/impls/aij/seq/aij.c.html#... <https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/aij/seq/aij.c.html#line4811> and replace PETSC_SCALAR line 4861 by PETSC_COMPLEX. Then, as Matt wrote, instead of assembling a single Mat, assemble two Mats by splitting a->a in two PetscScalar arrays (remember that this is for your scalar-type=real configuration).
Should this make two matrices, or the equivalent real matrix? / R Q \ \ -Q R / THanks, Matt
Thanks, Pierre
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
Thanks, Pierre
On 11 May 2021, at 3:30 PM, Frederico Teixeira <[email protected]> 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.
-- 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/>
-- 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/>
Matt, I initially had in mind to output the real and imaginary matrices separately, instead of the equivalent real matrix. Pierre, if you think there is value on it, I can contribute an implementation of "Mat[Real,Imaginary]PartLoad()" as you suggested, instead of solving the problem on my side with Python etc.. Regards, Frederico. From: "Matthew Knepley" <[email protected]> To: "Pierre Jolivet" <[email protected]> Cc: "Frederico Teixeira" <[email protected]>, "petsc-users" <[email protected]> Sent: Wednesday, May 12, 2021 1:35:55 PM Subject: Re: [petsc-users] Binary format in real vs. complex scalar type configurations On Wed, May 12, 2021 at 2:17 AM Pierre Jolivet < [ mailto:[email protected] | [email protected] ] > wrote: BQ_BEGIN On 11 May 2021, at 6:26 PM, Matthew Knepley < [ mailto:[email protected] | [email protected] ] > wrote: On Tue, May 11, 2021 at 12:03 PM Pierre Jolivet < [ mailto:[email protected] | [email protected] ] > wrote: BQ_BEGIN 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. BQ_END There is Mat[Real,Imaginary]Part(), maybe there could be Mat[Real,Imaginary]PartLoad()? It will be inefficient (complex Mat read twice in a very naive implementation), but functional and would not require tinkering with the options (but maybe you had something clear in mind). Also, just for reference, [ https://gitlab.com/petsc/petsc/-/issues/901 | https://gitlab.com/petsc/petsc/-/issues/901 ] . Frederico, as Barry wrote, it will work with Octave or Python. In fact, it will work in any code that does not include petsc.h or link to libpetsc. If you want to stick to C, I think you could simply copy/paste the MatLoad_SeqAIJ_Binary() implementation [ https://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/aij/seq/aij.c.html... | https://www.mcs.anl.gov/petsc/petsc-3.15.0/src/mat/impls/aij/seq/aij.c.html#... ] and replace PETSC_SCALAR line 4861 by PETSC_COMPLEX. Then, as Matt wrote, instead of assembling a single Mat, assemble two Mats by splitting a->a in two PetscScalar arrays (remember that this is for your scalar-type=real configuration). BQ_END Should this make two matrices, or the equivalent real matrix? / R Q \ \ -Q R / THanks, Matt BQ_BEGIN Thanks, Pierre BQ_BEGIN 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:[email protected] | [email protected] ] > 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/ ] 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/ ]
Hi Pierre, Thanks for your tip. I don't have access to MATLAB. Would Octave also work? Or Python? 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: "Pierre Jolivet" <[email protected]> To: "Frederico Teixeira" <[email protected]> Cc: "petsc-users" <[email protected]> Sent: Tuesday, May 11, 2021 6:03:20 PM Subject: Re: [petsc-users] Binary format in real vs. complex scalar type configurations 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 Thanks, Pierre On 11 May 2021, at 3:30 PM, Frederico Teixeira < [ mailto:[email protected] | [email protected] ] > 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.
On May 11, 2021, at 3:08 PM, Frederico Teixeira <[email protected]> wrote:
Hi Pierre,
Thanks for your tip. I don't have access to MATLAB. Would Octave also work? Or Python?
Yes, they should both be fine. All you need to is split the matrix into the 2 matrices in Octave or Python and then save both of them with the PETSc real format configure. Barry
Regards, Frederico.
Dr. Frederico Teixeira Computational Modeler and Software Developer, ZMT <http://www.itis.swiss/> (member of Zurich43 <https://www.z43.swiss/>)
P +41 44 245 9698 Zeughausstrasse 43, 8004 Zurich, Switzerland
From: "Pierre Jolivet" <[email protected]> To: "Frederico Teixeira" <[email protected]> Cc: "petsc-users" <[email protected]> Sent: Tuesday, May 11, 2021 6:03:20 PM Subject: Re: [petsc-users] Binary format in real vs. complex scalar type configurations
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
Thanks, Pierre
On 11 May 2021, at 3:30 PM, Frederico Teixeira <[email protected] <mailto:[email protected]>> 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.
participants (5)
-
Barry Smith -
Frederico Teixeira -
Mark Adams -
Matthew Knepley -
Pierre Jolivet