There are several math libraries for c#, but they all seem to either define their own vector and matrix types, or operate on established c# classes like Vector3D or Vector.
Are there any math libraries that operate on "simple" vector and matrix types such as double[] and double[,]
Some example of "nice to have" functions would be
double[] v = new double[3];
double[] w = new double[3];
double m[,] = new double[3,3];
double vDOTv = DesiredClass.Dot(v); // v.v
double[] normV = DesiredClass.Normalize(v); // normalize vector
double[] cCROSSw = DesiredClass.Cross(v,w); // v x w
double vDOTm = DesiredClass.D开发者_StackOverflowot(v,m,i); // v.m[i] - dot product of v with ith row of m
You could create your own classes for these types and provide them with implicit conversion from and to double arrays, then create those utility methods accepting parameters of your own type that would work on those arrays since there is an implicit conversion.
But that would be a bit fishy, why not work on normal types already.
Math.Net Numerics provides various matrix methods including MatrixMultiply and MatrixNorm, that work on double[]
, so it looks like it does most of what you need. I couldn't see the dot product, but it might be under a different name I'm unaware of.
精彩评论