I've written the following function for matrix multiplication using DGEMM. It takes three matrices a, b and c as double arrays and calculates axb=c. The three integers rowsA, colsB und colsA_rowsB are used by DGEMM to use the correct dimensions. Thee boolean trans is supposed to give the option to use the transpose of matrix b in the calculation, specifically axb^T=c.
void SvdUtility::getMatrixProduct(double a[], double b[], double c[], int rowsA, int colsA_rowsB, int colsB, bool trans)
{
if (trans)
{
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans, rowsA, colsB, colsA_rowsB, 1, a, rowsA, b, colsA_rowsB, 0, c, rowsA);
}
else
{
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, rowsA, colsB, colsA_rowsB, 1, a, rowsA, b, colsA_rowsB, 0, c, rowsA);
}
}
Now when I test my function with the following code it works just fine when I'm not transposing (first method call) but when I do (second method call) I get ** On entry to DGEMM parameter number 8 had an illegal value
double six[] {
2, 3, 5, 7, 11, 13
};
double four[] {
2, 3, 5, 7
};
double* test = new double[6];
SvdUtility::getMatrixProduct(six, four, test, 3, 2, 2, false);
SvdUtility::getMatrixProduct(six, four, test, 3, 2, 2, true);
I don't understand. The matrix that gets transposed is square, so dimensions shouldn't be a problem. Where am I wrong?