# alexkaratarakis/mathnet-numerics forked from mathnet/mathnet-numerics

[Matrix] LeftMultiply with vector is exactly the same as TransposeThi…

```…sAndMultiplty() with vector

Change LeftMultiply to a protected method (from protected abstract) and it now
calls TransposeThisAndMultiply(). TransposeThisAndMultiply has unit tests
so it was chosen as the "main" method. Overrides of LeftMultiply were removed,
because now only TransposeThisAndMultiply() needs to be overriden.

Signed-off-by: Alexander Karatarakis <alex@karatarakis.com>```
1 parent ba4ddfb commit 48037d122a4db2687de5d8801a4fb7af96473df7 committed with cuda Jun 9, 2011
 @@ -380,37 +380,6 @@ protected override void DoMultiply(Vector rightSide, Vector re } /// - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - var denseLeft = leftSide as DenseVector; - var denseResult = result as DenseVector; - - if (denseLeft == null || denseResult == null) - { - base.DoLeftMultiply(leftSide, result); - } - else - { - Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate( - Algorithms.LinearAlgebra.Transpose.DontTranspose, - Algorithms.LinearAlgebra.Transpose.DontTranspose, - 1.0, - denseLeft.Data, - 1, - denseLeft.Count, - Data, - RowCount, - ColumnCount, - 0.0, - denseResult.Data); - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.
 @@ -208,25 +208,6 @@ protected override void DoMultiply(Vector rightSide, Vector re } /// - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - for (var j = 0; j < ColumnCount; j++) - { - var s = Complex.Zero; - for (var i = 0; i != leftSide.Count; i++) - { - s += leftSide[i] * At(i, j); - } - - result[j] = s; - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.
 @@ -380,37 +380,6 @@ protected override void DoMultiply(Vector rightSide, Vector - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - var denseLeft = leftSide as DenseVector; - var denseResult = result as DenseVector; - - if (denseLeft == null || denseResult == null) - { - base.DoLeftMultiply(leftSide, result); - } - else - { - Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate( - Algorithms.LinearAlgebra.Transpose.DontTranspose, - Algorithms.LinearAlgebra.Transpose.DontTranspose, - 1.0f, - denseLeft.Data, - 1, - denseLeft.Count, - Data, - RowCount, - ColumnCount, - 0.0f, - denseResult.Data); - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.
 @@ -218,25 +218,6 @@ protected override void DoDivide(Complex32 scalar, Matrix result) } /// - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - for (var j = 0; j < ColumnCount; j++) - { - var s = Complex32.Zero; - for (var i = 0; i != leftSide.Count; i++) - { - s += leftSide[i] * At(i, j); - } - - result[j] = s; - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.
 @@ -421,37 +421,6 @@ protected override void DoMultiply(Vector rightSide, Vector resu } /// - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - var denseLeft = leftSide as DenseVector; - var denseResult = result as DenseVector; - - if (denseLeft == null || denseResult == null) - { - base.DoLeftMultiply(leftSide, result); - } - else - { - Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate( - Algorithms.LinearAlgebra.Transpose.DontTranspose, - Algorithms.LinearAlgebra.Transpose.DontTranspose, - 1.0, - denseLeft.Data, - 1, - denseLeft.Count, - Data, - RowCount, - ColumnCount, - 0.0, - denseResult.Data); - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.
 @@ -208,25 +208,6 @@ protected override void DoDivide(double scalar, Matrix result) } /// - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - for (var j = 0; j < ColumnCount; j++) - { - var s = 0.0; - for (var i = 0; i != leftSide.Count; i++) - { - s += leftSide[i] * At(i, j); - } - - result[j] = s; - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.
 @@ -420,7 +420,10 @@ public virtual void LeftMultiply(Vector leftSide, Vector result) /// /// The vector to multiply with. /// The result of the multiplication. - protected abstract void DoLeftMultiply(Vector leftSide, Vector result); + protected void DoLeftMultiply(Vector leftSide, Vector result) + { + DoTransposeThisAndMultiply(leftSide, result); + } /// /// Multiplies this matrix with another matrix and places the results into the result matrix.
 @@ -420,37 +420,6 @@ protected override void DoMultiply(Vector rightSide, Vector result } /// - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - var denseLeft = leftSide as DenseVector; - var denseResult = result as DenseVector; - - if (denseLeft == null || denseResult == null) - { - base.DoLeftMultiply(leftSide, result); - } - else - { - Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate( - Algorithms.LinearAlgebra.Transpose.DontTranspose, - Algorithms.LinearAlgebra.Transpose.DontTranspose, - 1.0f, - denseLeft.Data, - 1, - denseLeft.Count, - Data, - RowCount, - ColumnCount, - 0.0f, - denseResult.Data); - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.
 @@ -198,25 +198,6 @@ protected override void DoMultiply(Vector rightSide, Vector result } /// - /// Left multiply a matrix with a vector ( = vector * matrix ) and place the result in the result vector. - /// - /// The vector to multiply with. - /// The result of the multiplication. - protected override void DoLeftMultiply(Vector leftSide, Vector result) - { - for (var j = 0; j < ColumnCount; j++) - { - var s = 0.0f; - for (var i = 0; i != leftSide.Count; i++) - { - s += leftSide[i] * At(i, j); - } - - result[j] = s; - } - } - - /// /// Multiplies this matrix with another matrix and places the results into the result matrix. /// /// The matrix to multiply with.