diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs index d9c31895..ea23a0ce 100644 --- a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs +++ b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs @@ -570,6 +570,73 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// The result of the multiplication. protected abstract void DoTransposeAndMultiply(Matrix other, Matrix result); + + /// + /// Multiplies the transpose of this matrix by a vector and returns the result. + /// + /// The vector to multiply with. + /// The result of the multiplication. + /// If is . + /// If this.RowCount != rightSide.Count. + public virtual Vector TransposeThisAndMultiply(Vector rightSide) + { + var ret = CreateVector(RowCount); + TransposeThisAndMultiply(rightSide, ret); + return ret; + } + + /// + /// 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. + /// If is . + /// If is . + /// If result.Count != this.ColumnCount. + /// If this.RowCount != .Count. + public virtual void TransposeThisAndMultiply(Vector rightSide, Vector result) + { + if (rightSide == null) + { + throw new ArgumentNullException("rightSide"); + } + + if (RowCount != rightSide.Count) + { + throw new ArgumentException(Resources.ArgumentMatrixDimensions, "rightSide"); + } + + if (result == null) + { + throw new ArgumentNullException("result"); + } + + if (ColumnCount != result.Count) + { + throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result"); + } + + if (ReferenceEquals(rightSide, result)) + { + var tmp = result.CreateVector(result.Count); + TransposeThisAndMultiply(rightSide, tmp); + tmp.CopyTo(result); + } + else + { + DoTransposeThisAndMultiply(rightSide, result); + } + } + + /// + /// 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 abstract void DoTransposeThisAndMultiply(Vector rightSide, Vector result); + + + /// /// Multiplies the transpose of this matrix with another matrix and places the results into the result matrix. ///