CodePlexProject Hosting for Open Source Software

This method calculates the “dot product” of a Matrix and Vector object.

The first overload takes a Matrix object as the first argument and a Vector object as a second argument. The dot product is then calculated by using each row in the matrix against the corresponding fields in the vector. For example:

var m = new Matrix(new double[,] {{1,2}, {3,4}}); var v = new Vector(new double[] {8,9}); var v2 = Matrix.Dot(m, v); // v2 is now equal to: // { (1*8)+(2*9), (3*8)+(4*9) } = { 26, 60 }

The second overload takes a Vector as the first argument and a Matrix as the second argument. The dot product is then calculated by using each column in the matrix against the corresponding fields in the vector. For example:

var m = new Matrix(new double[,] {{1,2}, {3,4}}); var v = new Vector(new double[] {8,9}); var v2 = Matrix.Dot(v, m); // v2 is now equal to: // { (1*8)+(3*9), (2*8)+(4*9) } = { 35, 52 }

Last edited Feb 8, 2011 at 5:31 AM by TimNelson, version 2