|
|
|
@ -122,12 +122,19 @@ namespace MathNet.Numerics.LinearAlgebra |
|
|
|
protected abstract void DoMultiply(Matrix<T> other, Matrix<T> result); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies this matrix with transpose of another matrix and places the results into the result matrix.
|
|
|
|
/// Multiplies this matrix with the transpose of another matrix and places the results into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The matrix to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected abstract void DoTransposeAndMultiply(Matrix<T> other, Matrix<T> result); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies this matrix with the conjugate transpose of another matrix and places the results into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The matrix to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected abstract void DoConjugateTransposeAndMultiply(Matrix<T> other, Matrix<T> result); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the transpose of this matrix with a vector and places the results into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
@ -135,6 +142,13 @@ namespace MathNet.Numerics.LinearAlgebra |
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected abstract void DoTransposeThisAndMultiply(Vector<T> rightSide, Vector<T> result); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the conjugate transpose of this matrix with a vector and places the results into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rightSide">The vector to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected abstract void DoConjugateTransposeThisAndMultiply(Vector<T> rightSide, Vector<T> result); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the transpose of this matrix with another matrix and places the results into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
@ -142,6 +156,13 @@ namespace MathNet.Numerics.LinearAlgebra |
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected abstract void DoTransposeThisAndMultiply(Matrix<T> other, Matrix<T> result); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the transpose of this matrix with another matrix and places the results into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The matrix to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
protected abstract void DoConjugateTransposeThisAndMultiply(Matrix<T> other, Matrix<T> result); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Divides each element of the matrix by a scalar and places results into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
@ -807,6 +828,145 @@ namespace MathNet.Numerics.LinearAlgebra |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies this matrix with the conjugate transpose of another matrix and places the results into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The matrix to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
/// <exception cref="ArgumentException">If <strong>this.Columns != other.ColumnCount</strong>.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the this.RowCount x other.RowCount.</exception>
|
|
|
|
public virtual void ConjugateTransposeAndMultiply(Matrix<T> other, Matrix<T> result) |
|
|
|
{ |
|
|
|
if (ColumnCount != other.ColumnCount || result.RowCount != RowCount || result.ColumnCount != other.RowCount) |
|
|
|
{ |
|
|
|
throw DimensionsDontMatch<ArgumentException>(this, other, result); |
|
|
|
} |
|
|
|
|
|
|
|
if (ReferenceEquals(this, result) || ReferenceEquals(other, result)) |
|
|
|
{ |
|
|
|
var tmp = Build.SameAs(result); |
|
|
|
DoConjugateTransposeAndMultiply(other, tmp); |
|
|
|
tmp.CopyTo(result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DoConjugateTransposeAndMultiply(other, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies this matrix with the conjugate transpose of another matrix and returns the result.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The matrix to multiply with.</param>
|
|
|
|
/// <exception cref="ArgumentException">If <strong>this.Columns != other.ColumnCount</strong>.</exception>
|
|
|
|
/// <returns>The result of the multiplication.</returns>
|
|
|
|
public Matrix<T> ConjugateTransposeAndMultiply(Matrix<T> other) |
|
|
|
{ |
|
|
|
if (ColumnCount != other.ColumnCount) |
|
|
|
{ |
|
|
|
throw DimensionsDontMatch<ArgumentException>(this, other); |
|
|
|
} |
|
|
|
|
|
|
|
var result = Build.SameAs(this, other, RowCount, other.RowCount); |
|
|
|
DoConjugateTransposeAndMultiply(other, result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the conjugate transpose of this matrix by a vector and returns the result.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rightSide">The vector to multiply with.</param>
|
|
|
|
/// <returns>The result of the multiplication.</returns>
|
|
|
|
/// <exception cref="ArgumentException">If <c>this.RowCount != rightSide.Count</c>.</exception>
|
|
|
|
public Vector<T> ConjugateTransposeThisAndMultiply(Vector<T> rightSide) |
|
|
|
{ |
|
|
|
if (RowCount != rightSide.Count) |
|
|
|
{ |
|
|
|
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide"); |
|
|
|
} |
|
|
|
|
|
|
|
var result = Vector<T>.Build.SameAs(this, rightSide, ColumnCount); |
|
|
|
DoConjugateTransposeThisAndMultiply(rightSide, result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the conjugate transpose of this matrix with a vector and places the results into the result vector.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="rightSide">The vector to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
/// <exception cref="ArgumentException">If <strong>result.Count != this.ColumnCount</strong>.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If <strong>this.RowCount != <paramref name="rightSide"/>.Count</strong>.</exception>
|
|
|
|
public void ConjugateTransposeThisAndMultiply(Vector<T> rightSide, Vector<T> result) |
|
|
|
{ |
|
|
|
if (RowCount != rightSide.Count) |
|
|
|
{ |
|
|
|
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide"); |
|
|
|
} |
|
|
|
|
|
|
|
if (ColumnCount != result.Count) |
|
|
|
{ |
|
|
|
throw DimensionsDontMatch<ArgumentException>(this, result, "result"); |
|
|
|
} |
|
|
|
|
|
|
|
if (ReferenceEquals(rightSide, result)) |
|
|
|
{ |
|
|
|
var tmp = Vector<T>.Build.SameAs(result); |
|
|
|
DoConjugateTransposeThisAndMultiply(rightSide, tmp); |
|
|
|
tmp.CopyTo(result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DoConjugateTransposeThisAndMultiply(rightSide, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the conjugate transpose of this matrix with another matrix and places the results into the result matrix.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The matrix to multiply with.</param>
|
|
|
|
/// <param name="result">The result of the multiplication.</param>
|
|
|
|
/// <exception cref="ArgumentException">If <strong>this.Rows != other.RowCount</strong>.</exception>
|
|
|
|
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the this.ColumnCount x other.ColumnCount.</exception>
|
|
|
|
public void ConjugateTransposeThisAndMultiply(Matrix<T> other, Matrix<T> result) |
|
|
|
{ |
|
|
|
if (RowCount != other.RowCount || result.RowCount != ColumnCount || result.ColumnCount != other.ColumnCount) |
|
|
|
{ |
|
|
|
throw DimensionsDontMatch<ArgumentException>(this, other, result); |
|
|
|
} |
|
|
|
|
|
|
|
if (ReferenceEquals(this, result) || ReferenceEquals(other, result)) |
|
|
|
{ |
|
|
|
var tmp = Build.SameAs(result); |
|
|
|
DoConjugateTransposeThisAndMultiply(other, tmp); |
|
|
|
tmp.CopyTo(result); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
DoConjugateTransposeThisAndMultiply(other, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Multiplies the conjugate transpose of this matrix with another matrix and returns the result.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The matrix to multiply with.</param>
|
|
|
|
/// <exception cref="ArgumentException">If <strong>this.Rows != other.RowCount</strong>.</exception>
|
|
|
|
/// <returns>The result of the multiplication.</returns>
|
|
|
|
public Matrix<T> ConjugateTransposeThisAndMultiply(Matrix<T> other) |
|
|
|
{ |
|
|
|
if (RowCount != other.RowCount) |
|
|
|
{ |
|
|
|
throw DimensionsDontMatch<ArgumentException>(this, other); |
|
|
|
} |
|
|
|
|
|
|
|
var result = Build.SameAs(this, other, ColumnCount, other.ColumnCount); |
|
|
|
DoConjugateTransposeThisAndMultiply(other, result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Negate each element of this matrix.
|
|
|
|
/// </summary>
|
|
|
|
|