diff --git a/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs index 6073a8d5..8c73f41c 100644 --- a/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs @@ -444,6 +444,47 @@ namespace MathNet.Numerics.LinearAlgebra.Double } } + /// + /// Multiplies the transpose of this matrix with a vector and places the results into the result vector. + /// + /// The vector to multiply with. + /// The result of the multiplication. + protected override void DoTransposeThisAndMultiply(Vector rightSide, Vector result) + { + var denseRight = rightSide as DenseVector; + var denseResult = result as DenseVector; + + if (denseRight == null || denseResult == null) + { + base.DoTransposeThisAndMultiply(rightSide, result); + } + else + { + Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate( + Algorithms.LinearAlgebra.Transpose.DontTranspose, + Algorithms.LinearAlgebra.Transpose.DontTranspose, + 1.0, + Data, + RowCount, + ColumnCount, + denseRight.Data, + denseRight.Count, + 1, + 0.0, + denseResult.Data); + } + } + + /// + /// Multiplies the transpose of this matrix with another matrix and places the results into the result matrix. + /// + /// The matrix to multiply with. + /// The result of the multiplication. + protected override void DoTransposeThisAndMultiply(Matrix other, Matrix result) + { + throw new NotImplementedException(); + } + /// /// Negate each element of this matrix and place the results into the result matrix. /// diff --git a/src/Numerics/LinearAlgebra/Double/Matrix.cs b/src/Numerics/LinearAlgebra/Double/Matrix.cs index bb599220..26b0ceb6 100644 --- a/src/Numerics/LinearAlgebra/Double/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Double/Matrix.cs @@ -269,6 +269,24 @@ namespace MathNet.Numerics.LinearAlgebra.Double } } + /// + /// Multiplies the transpose of this matrix with a vector and places the results into the result vector. + /// + /// The vector to multiply with. + /// The result of the multiplication. + protected override void DoTransposeThisAndMultiply(Vector rightSide, Vector result) + { + for (var i = 0; i < ColumnCount; i++) + { + var s = 0.0; + for (var j = 0; j != RowCount; j++) + { + s += At(j, i) * rightSide[j]; + } + result[i] = s; + } + } + /// /// Negate each element of this matrix and place the results into the result matrix. ///