Matrix multiplication

So that's my funcion to multiply 2 matrices together, it works for square matrcies but not for any other IE [1,2], [3,4] etc..

matrix^ MatrixMultiply(matrix^ a, matrix^ b)
{
int n = a->GetLength(0);
int m = a->GetLength(1);

matrix^ tempA = gcnew matrix(n, m);
matrix^ tempB = gcnew matrix(n, m);
matrix^ AB = gcnew matrix(n, m);

tempA = MatrixCopy(a);
tempB = MatrixCopy(b);

for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
for (int k = 0; k < m; k++)
AB[i, j] += tempA[i, k] * tempB[k, j];

return AB;
}
}
Topic archived. No new replies allowed.