Complex matrix multiplication

Complex matrix multiplication

I want to multiply two complex matrices AT*A (matrix A is 121x14) to fit data using least squares . I tried two ways: MATMUL and MKL ZGEMM function. But I obtained different results and even more different results than in MATLAB (I suppose MATLAB is correct because results of LSQ fit are correct).

The results are:

           1           1
 (3.684336847451464E-023,0.000000000000000E+000)  MATMUL
 (3.684336847451464E-023,0.000000000000000E+000)  ZGEMM
 (3.684336847451463E-023,0.000000000000000E+000)  MATLAB

           1           2
 (4.137865872950605E-015,-2.121231277807491E-032)  MATMUL
 (4.137865872950604E-015,-2.121231277807491E-032)  ZGEMM
 (4.137865872950604E-015,-1.232595164406710E-032)  MATLAB

           1           3
 (7.552654647536070E-032,-4.003325551299034E-033)  MATMUL
 (7.554460206858933E-032,-4.021381144527664E-033)  ZGEMM
 (7.555137291605429E-032,-4.012353347913349E-033)  MATLAB

element (1,3) is different in all 3 versions and difference is on the 3rd decimal place which is unacceptable for me.

I am attaching code (windows, Visual Fortran Compiler XE used to produce these results.

What to do to improve precision of results?

publicaciones de 3 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

I forgot to attach code


Descargar matmul.zip31.66 KB

In two cases out of three, MATMUL and ZGEMM agree exactly or differ by just one unit in the last digit. Looked at impartially, that should weigh in favour of those being correct rather than MATLAB.

Also, you have the same 'precision' in all three cases (same number of digits), but its the 'accuracy' of those precise numbers that you are concerned about. The numbers exhibiting the biggest diffferences, in a percentage way (not absolute value way) are very small indeed. Why are you concerned about that, as your system would have to be very ill-conditioned, IMHO, to produce significantly different results as a result of such tiny differences?

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya