+ 2
Does the .NET Framework Class Library provide any features for computing the product of two 2D arrays?
I've created a function that can multiply two double[3,3] arrays using for loops however, I was wondering if there's vectorised technique for doing the same task?
3 Réponses
+ 1
Any chance you know of any alternative way of achieving this?
+ 1
Sure, it's just basic 3x3 matrix multiplication:
public double[,] matrixMulti(double[,] a, double[,] b)
{
double[,] result = new double[3,3];
if(a.GetLength(0) == b.GetLength(1)){
for(int i = 0; I < a.GetLength(0); I++){
for(int j = 0; j < b.GetLength(1) j++){
for(int k = 0; k < a.GetLength(1); k++){
result[ i, j ] += a[ i, k] * b[ k, j ];
}
}
}
}
return result;
}
0
This question still hasn't really been answered so, any solutions would be greatly welcome.