diff --git a/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs index 8c73f41c..43ea3959 100644 --- a/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs @@ -461,7 +461,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double else { Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate( - Algorithms.LinearAlgebra.Transpose.DontTranspose, + Algorithms.LinearAlgebra.Transpose.Transpose, Algorithms.LinearAlgebra.Transpose.DontTranspose, 1.0, Data, @@ -482,7 +482,28 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// The result of the multiplication. protected override void DoTransposeThisAndMultiply(Matrix other, Matrix result) { - throw new NotImplementedException(); + var denseOther = other as DenseMatrix; + var denseResult = result as DenseMatrix; + + if (denseOther == null || denseResult == null) + { + base.DoTransposeThisAndMultiply(other, result); + } + else + { + Control.LinearAlgebraProvider.MatrixMultiplyWithUpdate( + Algorithms.LinearAlgebra.Transpose.Transpose, + Algorithms.LinearAlgebra.Transpose.DontTranspose, + 1.0, + Data, + RowCount, + ColumnCount, + denseOther.Data, + denseOther.RowCount, + denseOther.ColumnCount, + 0.0, + denseResult.Data); + } } /// diff --git a/src/Numerics/LinearAlgebra/Double/Matrix.cs b/src/Numerics/LinearAlgebra/Double/Matrix.cs index 26b0ceb6..71760c38 100644 --- a/src/Numerics/LinearAlgebra/Double/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Double/Matrix.cs @@ -269,6 +269,28 @@ namespace MathNet.Numerics.LinearAlgebra.Double } } + /// + /// 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) + { + for (var j = 0; j < other.ColumnCount; j++) + { + for (var i = 0; i < ColumnCount; i++) + { + var s = 0.0; + for (var l = 0; l < RowCount; l++) + { + s += At(l, i) * other.At(l, j); + } + + result.At(i, j, s); + } + } + } + /// /// Multiplies the transpose of this matrix with a vector and places the results into the result vector. ///