I have a question regarding cblas_dgemv. I am trying to understand how it works. And what I am possibly doing wrong. I have an array Matrix and then I try to read that matrix RowMajor and ColumnMajor.
I am getting the expected result in the RowMajor Case; [6, 2, 4, 6]'.
However for the ColMajor, I am getting [-7, 3, 0, 5]' when the answer should be [6, 3, 2, 3]'
Here is my code. I am using Intel MKL.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <mkl.h>
#define NCols 5
#define Nrows 4
double A[] = { 8, 4, 7, 3, 5, 1, 1, 3, 2, 1, 2, 3, 2, 0, 1, 1 , 2, 3, 4, 1};
double x[] = { -1, 2, -1, 1, 2 };
double y[Nrows];
double alpha = 1.0, beta = 0.0;
char tbuf[1024];
int main() {
int i, j;
// Print original matrix
// y = Ax
cblas_dgemv(CblasRowMajor, CblasNoTrans, Nrows, NCols, alpha, A, NCols, x, 1, beta, y, 1);
// Print resulting vector
for (j = 0; j < Nrows; j++) {
printf(" %f\n", y[j]);
}
cblas_dgemv(CblasColMajor, CblasNoTrans, Nrows, NCols, alpha, A, NCols, x, 1, beta, y, 1);
// Print resulting vector
for (j = 0; j < Nrows; j++) {
printf(" %f\n", y[j]);
}
return 0;
}