[petsc-dev] MatProduct_AtB --with-scalar-type=complex

Pierre Jolivet pierre at joliv.et
Thu Jul 14 15:30:10 CDT 2022


Hello,
In the following example, the SeqAIJ implementation of MatProduct_AtB produce a different (and wrong) result, compared to the SeqDense implementation or MATLAB.
I want to compute B = A^H A (where ^H is the Hermitian transpose).
So I create a MatProduct with A and A.
Duplicate A into another Mat which I conjugate.
And I replace the first Mat of the product with this conjugate.
I expect to get the proper result, which I don’t.
Is the MatProduct_AtB implementation in the complex case not computing A^T B (where ^T is the transpose)? 
For reference, here is how to properly compute A^H A with current main: conj(A^H conj(A)) — so it requires an extra MatConjugate I’d like to avoid.

Thanks,
Pierre

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex1111.c
Type: application/octet-stream
Size: 1511 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220714/cb0f6657/attachment.obj>
-------------- next part --------------


$ ./ex1111 -product_view ::ascii_matlab -A_view ::ascii_matlab -convert false               
%Mat Object: 1 MPI process
%  type: seqdense
% Size = 2 2 
Mat_0xc4000001_0 = zeros(2,2);
Mat_0xc4000001_0 = [
7.2003197397953400e-01 + 6.1793966542126100e-02i 3.9777780919128602e-01 + 7.3036588248200474e-02i 
1.0022337819588500e-02 + 1.4463931936456476e-01i 1.0386628927366459e-01 + 2.5078039364333193e-01i 
];
%Mat Object: 1 MPI process
%  type: seqdense
% Size = 2 2 
Mat_0xc4000001_1 = zeros(2,2);
Mat_0xc4000001_1 = [
5.4328551781548817e-01 + 0.0000000000000000e+00i 3.2823965013353340e-01 + 1.5498666614872689e-02i 
3.2823965013353340e-01 + -1.5498666614872689e-02i 2.3724054059134142e-01 + 0.0000000000000000e+00i 
];

$ ./ex1111 -product_view ::ascii_matlab -convert true                       
%Mat Object: 1 MPI process
%  type: seqaij
% Size = 2 2 
% Nonzeros = 4 
zzz = zeros(4,4);
zzz = [
1 1  4.9380746380098023e-01 9.1886511660038694e-02
1 2  2.4666779825931440e-01 9.4705502650537468e-02
2 1  2.4666779825931440e-01 9.4705502650537468e-02
2 2  1.0079024247365802e-01 1.1019992594899400e-01
];
 Mat_0xc4000001_0 = spconvert(zzz);

$ ./ex1111 -product_view ::ascii_matlab -convert true -correct true
%Mat Object: 1 MPI process
%  type: seqaij
% Size = 2 2 
% Nonzeros = 4 
zzz = zeros(4,4);
zzz = [
1 1  5.4328551781548828e-01 -0.0000000000000000e+00
1 2  3.2823965013353340e-01 1.5498666614872696e-02
2 1  3.2823965013353340e-01 -1.5498666614872696e-02
2 2  2.3724054059134142e-01 -0.0000000000000000e+00
];
 Mat_0xc4000001_0 = spconvert(zzz);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2022-07-14 at 10.12.53 PM.png
Type: image/png
Size: 19937 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220714/cb0f6657/attachment.png>


More information about the petsc-dev mailing list