I succeed in matrix-vector multiplication when working with cgemv a BLAS lvl 2 function in Lapack, but when I try the transpose, I get a wrong answer. Can you instruct me in my error? (I'm actually using the C wrapper, not FORTRAN.)
I'm attempting
| 4+i 3 | | 3+2i | | 4+i 3 |^T | 3+2i |
| 14+3i 2 | * | 2 | (AND) | 14+3i 2 | * | 2 |
To be clear, the first one succeeds. The second one gives incorrect output.
/* config variables */
char normal = 'N';
char transpose = 'T';
integer m = 2;
complex alpha = {r:1,i:0};
complex beta = {r:0,i:0};
integer one = 1;
/* data buffers */
complex a[4] = {(complex){r:4, i:1},(complex){r:14, i:3},(complex){r:3, i:0},(complex){r:6, i:0}};
complex x[2] = {(complex){r:3, i:2},(complex){r:2, i:0}};
complex y[2];
/* execution */
cgemv_(&normal, &m, &m, &alpha, &a[0], &m, &x[0], &one, &beta, &y[0], &one);
cgemv_(&transpose, &m, &m, &alpha, &a[0], &m, &x[0], &one, &beta, &y[0], &one);
After the first cgemv_ call, y holds 16.0000+11.0000i 48.0000+37.0000i, which MATLAB confirms to be correct.
But after the second cgemv_ call, y holds 38.0000+17.0000i 21.0000+6.0000i, whereas MATLAB says it should be 42.0000-1.0000i 21.0000+6.0000i. I've no idea what could be awry.