diff --git a/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs index f2d28138..cc19f226 100644 --- a/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs @@ -404,6 +404,68 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } } + /// + /// 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.Transpose, + Algorithms.LinearAlgebra.Transpose.DontTranspose, + 1.0f, + Data, + RowCount, + ColumnCount, + denseRight.Data, + denseRight.Count, + 1, + 0.0f, + 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) + { + 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.0f, + Data, + RowCount, + ColumnCount, + denseOther.Data, + denseOther.RowCount, + denseOther.ColumnCount, + 0.0f, + denseResult.Data); + } + } + /// /// Negate each element of this matrix and place the results into the result matrix. /// diff --git a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs index 03f0a0b2..e301daba 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Matrix.cs @@ -279,6 +279,46 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } } + /// + /// 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 = Complex32.Zero; + 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. + /// + /// 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 = Complex32.Zero; + 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. ///