Browse Source

LA: Matrix group operators together, some eol whitespaces fixes

pull/103/head
Christoph Ruegg 13 years ago
parent
commit
2cb8a2a0a7
  1. 18
      src/Numerics/LinearAlgebra/Complex/DenseVector.cs
  2. 34
      src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
  3. 8
      src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs
  4. 16
      src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
  5. 20
      src/Numerics/LinearAlgebra/Complex32/DenseVector.cs
  6. 30
      src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
  7. 16
      src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
  8. 10
      src/Numerics/LinearAlgebra/Complex32/Vector.cs
  9. 26
      src/Numerics/LinearAlgebra/Double/DenseVector.cs
  10. 30
      src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
  11. 26
      src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
  12. 362
      src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
  13. 32
      src/Numerics/LinearAlgebra/Generic/Vector.cs
  14. 24
      src/Numerics/LinearAlgebra/Single/DenseVector.cs
  15. 30
      src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
  16. 20
      src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
  17. 10
      src/Numerics/LinearAlgebra/Single/Vector.cs
  18. 6
      src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs

18
src/Numerics/LinearAlgebra/Complex/DenseVector.cs

@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// Initializes a new instance of the <see cref="DenseVector"/> class for an array.
/// </summary>
/// <param name="array">The array to create this vector from.</param>
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// changes to the vector will also change the array.</remarks>
public DenseVector(Complex[] array)
: this(new DenseVectorStorage<Complex>(array.Length, array))
@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
@ -335,7 +335,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing the negated values as <paramref name="rightSide"/>.</returns>
@ -489,7 +489,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns the index of the absolute minimum element.
/// </summary>
/// <returns>The index of absolute minimum element.</returns>
/// <returns>The index of absolute minimum element.</returns>
public override int AbsoluteMinimumIndex()
{
var index = 0;
@ -528,7 +528,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int AbsoluteMaximumIndex()
{
var index = 0;
@ -625,8 +625,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <param name="u">First vector</param>
/// <param name="v">Second vector</param>
/// <returns>Matrix M[i,j] = u[i]*v[j] </returns>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
public static DenseMatrix OuterProduct(DenseVector u, DenseVector v)
{
if (u == null)
@ -641,8 +641,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
var matrix = new DenseMatrix(u.Count, v.Count);
CommonParallel.For(
0,
u.Count,
0,
u.Count,
i =>
{
for (var j = 0; j < v.Count; j++)

34
src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs

@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
using Storage;
/// <summary>
/// A matrix type for diagonal matrices.
/// A matrix type for diagonal matrices.
/// </summary>
/// <remarks>
/// Diagonal matrices can be non-square matrices but the diagonal always starts
@ -121,7 +121,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
/// <exception cref="IndexOutOfRangeException">When <paramref name="array"/> contains an off-diagonal element.</exception>
@ -239,7 +239,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
else
{
Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
}
}
@ -277,7 +277,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Subtracts another matrix from this matrix.
/// Subtracts another matrix from this matrix.
/// </summary>
/// <param name="other">The matrix to subtract.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
@ -303,7 +303,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// </summary>
/// <param name="source">The array to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -319,7 +319,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{
throw new ArgumentException(Resources.ArgumentArraysSameLength, "source");
}
Array.Copy(source, _data, source.Length);
}
@ -328,7 +328,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// </summary>
/// <param name="source">The vector to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -355,7 +355,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// </summary>
/// <param name="scalar">The scalar to multiply the matrix with.</param>
/// <param name="result">The matrix to store the result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
protected override void DoMultiply(Complex scalar, Matrix<Complex> result)
{
@ -440,7 +440,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// Multiplies 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.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<Complex> Multiply(Matrix<Complex> other)
@ -614,7 +614,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// Multiplies this matrix with 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.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<Complex> TransposeAndMultiply(Matrix<Complex> other)
@ -639,7 +639,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<Complex> Transpose()
{
@ -656,7 +656,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>Calculates the L2 norm.</summary>
/// <returns>The L2 norm of the matrix.</returns>
/// <returns>The L2 norm of the matrix.</returns>
public override Complex L2Norm()
{
return _data.Aggregate(double.NegativeInfinity, (current, t) => Math.Max(current, t.Magnitude));
@ -671,7 +671,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override Complex InfinityNorm()
{
return L1Norm();
@ -722,7 +722,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<Complex> LowerTriangle()
{
return Clone();
@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<Complex> UpperTriangle()
{
return Clone();
@ -864,10 +864,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <returns>The requested sub-matrix.</returns>
/// <exception cref="ArgumentOutOfRangeException">If: <list><item><paramref name="rowIndex"/> is
/// negative, or greater than or equal to the number of rows.</item>
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// of columns.</item>
/// <item><c>(columnIndex + columnLength) &gt;= Columns</c></item>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="rowCount"/> or <paramref name="columnCount"/>
/// is not positive.</exception>
public override Matrix<Complex> SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount)

8
src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs

@ -39,13 +39,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
/// <summary>
/// <para>A class which encapsulates the functionality of the singular value decomposition (SVD).</para>
/// <para>Suppose M is an m-by-n matrix whose entries are real numbers.
/// <para>Suppose M is an m-by-n matrix whose entries are real numbers.
/// Then there exists a factorization of the form M = UΣVT where:
/// - U is an m-by-m unitary matrix;
/// - Σ is m-by-n diagonal matrix with nonnegative real numbers on the diagonal;
/// - VT denotes transpose of V, an n-by-n unitary matrix;
/// Such a factorization is called a singular-value decomposition of M. A common convention is to order the diagonal
/// entries Σ(i,i) in descending order. In this case, the diagonal matrix Σ is uniquely determined
/// - VT denotes transpose of V, an n-by-n unitary matrix;
/// Such a factorization is called a singular-value decomposition of M. A common convention is to order the diagonal
/// entries Σ(i,i) in descending order. In this case, the diagonal matrix Σ is uniquely determined
/// by M (though the matrices U and V are not). The diagonal entries of Σ are known as the singular values of M.</para>
/// </summary>
/// <remarks>

16
src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs

@ -135,7 +135,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// </summary>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
@ -160,7 +160,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
public SparseMatrix(Complex[,] array)
@ -216,7 +216,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<Complex> LowerTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -283,7 +283,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<Complex> UpperTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -485,7 +485,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<Complex> Transpose()
{
@ -557,7 +557,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override Complex InfinityNorm()
{
var rowPointers = _storage.RowPointers;
@ -875,7 +875,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{
sum += values[index] * rightSide[columnIndices[index]];
}
result[row] = sum;
}
}
@ -1188,7 +1188,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
/// <summary>
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The matrix to get the values from.</param>
/// <returns>A matrix containing a the same values as <paramref name="rightSide"/>.</returns>

20
src/Numerics/LinearAlgebra/Complex32/DenseVector.cs

@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// Initializes a new instance of the <see cref="DenseVector"/> class for an array.
/// </summary>
/// <param name="array">The array to create this vector from.</param>
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// changes to the vector will also change the array.</remarks>
public DenseVector(Complex32[] array)
: this(new DenseVectorStorage<Complex32>(array.Length, array))
@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
@ -333,9 +333,9 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values);
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing the negated values as <paramref name="rightSide"/>.</returns>
@ -489,7 +489,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the index of the absolute minimum element.
/// </summary>
/// <returns>The index of absolute minimum element.</returns>
/// <returns>The index of absolute minimum element.</returns>
public override int AbsoluteMinimumIndex()
{
var index = 0;
@ -528,7 +528,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int AbsoluteMaximumIndex()
{
var index = 0;
@ -625,8 +625,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <param name="u">First vector</param>
/// <param name="v">Second vector</param>
/// <returns>Matrix M[i,j] = u[i]*v[j] </returns>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
public static DenseMatrix OuterProduct(DenseVector u, DenseVector v)
{
if (u == null)
@ -641,8 +641,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
var matrix = new DenseMatrix(u.Count, v.Count);
CommonParallel.For(
0,
u.Count,
0,
u.Count,
i =>
{
for (var j = 0; j < v.Count; j++)

30
src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs

@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
using Storage;
/// <summary>
/// A matrix type for diagonal matrices.
/// A matrix type for diagonal matrices.
/// </summary>
/// <remarks>
/// Diagonal matrices can be non-square matrices but the diagonal always starts
@ -121,7 +121,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
/// <exception cref="IndexOutOfRangeException">When <paramref name="array"/> contains an off-diagonal element.</exception>
@ -277,7 +277,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>
/// Subtracts another matrix from this matrix.
/// Subtracts another matrix from this matrix.
/// </summary>
/// <param name="other">The matrix to subtract.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
@ -303,7 +303,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// </summary>
/// <param name="source">The array to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -328,7 +328,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// </summary>
/// <param name="source">The vector to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -355,7 +355,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// </summary>
/// <param name="scalar">The scalar to multiply the matrix with.</param>
/// <param name="result">The matrix to store the result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
protected override void DoMultiply(Complex32 scalar, Matrix<Complex32> result)
{
@ -440,7 +440,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// Multiplies 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.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<Complex32> Multiply(Matrix<Complex32> other)
@ -614,7 +614,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// Multiplies this matrix with 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.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<Complex32> TransposeAndMultiply(Matrix<Complex32> other)
@ -639,7 +639,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<Complex32> Transpose()
{
@ -656,7 +656,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>Calculates the L2 norm.</summary>
/// <returns>The L2 norm of the matrix.</returns>
/// <returns>The L2 norm of the matrix.</returns>
public override Complex32 L2Norm()
{
return _data.Aggregate(float.NegativeInfinity, (current, t) => Math.Max(current, t.Magnitude));
@ -671,7 +671,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override Complex32 InfinityNorm()
{
return L1Norm();
@ -722,7 +722,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<Complex32> LowerTriangle()
{
return Clone();
@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<Complex32> UpperTriangle()
{
return Clone();
@ -864,10 +864,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <returns>The requested sub-matrix.</returns>
/// <exception cref="ArgumentOutOfRangeException">If: <list><item><paramref name="rowIndex"/> is
/// negative, or greater than or equal to the number of rows.</item>
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// of columns.</item>
/// <item><c>(columnIndex + columnLength) &gt;= Columns</c></item>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="rowCount"/> or <paramref name="columnCount"/>
/// is not positive.</exception>
public override Matrix<Complex32> SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount)

16
src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs

@ -37,7 +37,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
using Properties;
using Storage;
using Threading;
/// <summary>
/// A Matrix class with sparse storage. The underlying storage scheme is 3-array compressed-sparse-row (CSR) Format.
/// <a href="http://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR_or_CRS.29">Wikipedia - CSR</a>.
@ -135,7 +135,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// </summary>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
@ -160,7 +160,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
public SparseMatrix(Complex32[,] array)
@ -216,7 +216,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<Complex32> LowerTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -283,7 +283,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<Complex32> UpperTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -485,7 +485,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<Complex32> Transpose()
{
@ -557,7 +557,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override Complex32 InfinityNorm()
{
var rowPointers = _storage.RowPointers;
@ -1187,7 +1187,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
/// <summary>
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The matrix to get the values from.</param>
/// <returns>A matrix containing a the same values as <paramref name="rightSide"/>.</returns>

10
src/Numerics/LinearAlgebra/Complex32/Vector.cs

@ -43,7 +43,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
public abstract class Vector : Vector<Complex32>
{
/// <summary>
/// Initializes a new instance of the Vector class.
/// Initializes a new instance of the Vector class.
/// </summary>
protected Vector(VectorStorage<Complex32> storage)
: base(storage)
@ -215,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the index of the absolute minimum element.
/// </summary>
/// <returns>The index of absolute minimum element.</returns>
/// <returns>The index of absolute minimum element.</returns>
public override int AbsoluteMinimumIndex()
{
var index = 0;
@ -245,7 +245,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int AbsoluteMaximumIndex()
{
var index = 0;
@ -353,7 +353,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int MaximumIndex()
{
throw new NotSupportedException();
@ -362,7 +362,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// <summary>
/// Returns the index of the minimum element.
/// </summary>
/// <returns>The index of minimum element.</returns>
/// <returns>The index of minimum element.</returns>
public override int MinimumIndex()
{
throw new NotSupportedException();

26
src/Numerics/LinearAlgebra/Double/DenseVector.cs

@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// Initializes a new instance of the <see cref="DenseVector"/> class for an array.
/// </summary>
/// <param name="array">The array to create this vector from.</param>
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// changes to the vector will also change the array.</remarks>
public DenseVector(double[] array)
: this(new DenseVectorStorage<double>(array.Length, array))
@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
@ -343,9 +343,9 @@ namespace MathNet.Numerics.LinearAlgebra.Double
Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values);
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing the negated values as <paramref name="rightSide"/>.</returns>
@ -540,7 +540,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns the index of the absolute minimum element.
/// </summary>
/// <returns>The index of absolute minimum element.</returns>
/// <returns>The index of absolute minimum element.</returns>
public override int AbsoluteMinimumIndex()
{
var index = 0;
@ -579,7 +579,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int AbsoluteMaximumIndex()
{
var index = 0;
@ -600,7 +600,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int MaximumIndex()
{
var index = 0;
@ -620,7 +620,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns the index of the minimum element.
/// </summary>
/// <returns>The index of minimum element.</returns>
/// <returns>The index of minimum element.</returns>
public override int MinimumIndex()
{
var index = 0;
@ -716,8 +716,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <param name="u">First vector</param>
/// <param name="v">Second vector</param>
/// <returns>Matrix M[i,j] = u[i]*v[j] </returns>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
public static DenseMatrix OuterProduct(DenseVector u, DenseVector v)
{
if (u == null)
@ -732,8 +732,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double
var matrix = new DenseMatrix(u.Count, v.Count);
CommonParallel.For(
0,
u.Count,
0,
u.Count,
i =>
{
for (var j = 0; j < v.Count; j++)
@ -794,7 +794,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return Math.Pow(sum, 1.0 / p);
}
#endregion
#region Parse Functions

30
src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs

@ -33,7 +33,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
using Storage;
/// <summary>
/// A matrix type for diagonal matrices.
/// A matrix type for diagonal matrices.
/// </summary>
/// <remarks>
/// Diagonal matrices can be non-square matrices but the diagonal always starts
@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
/// <exception cref="IndexOutOfRangeException">When <paramref name="array"/> contains an off-diagonal element.</exception>
@ -276,7 +276,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>
/// Subtracts another matrix from this matrix.
/// Subtracts another matrix from this matrix.
/// </summary>
/// <param name="other">The matrix to subtract.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// </summary>
/// <param name="source">The array to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -327,7 +327,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// </summary>
/// <param name="source">The vector to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -354,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// </summary>
/// <param name="scalar">The scalar to multiply the matrix with.</param>
/// <param name="result">The matrix to store the result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
protected override void DoMultiply(double scalar, Matrix<double> result)
{
@ -434,7 +434,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// Multiplies 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.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<double> Multiply(Matrix<double> other)
@ -608,7 +608,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// Multiplies this matrix with 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.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<double> TransposeAndMultiply(Matrix<double> other)
@ -633,7 +633,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<double> Transpose()
{
@ -650,7 +650,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>Calculates the L2 norm.</summary>
/// <returns>The L2 norm of the matrix.</returns>
/// <returns>The L2 norm of the matrix.</returns>
public override double L2Norm()
{
return _data.Aggregate(double.NegativeInfinity, (current, t) => Math.Max(current, Math.Abs(t)));
@ -665,7 +665,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override double InfinityNorm()
{
return L1Norm();
@ -716,7 +716,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<double> LowerTriangle()
{
return Clone();
@ -786,7 +786,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<double> UpperTriangle()
{
return Clone();
@ -858,10 +858,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <returns>The requested sub-matrix.</returns>
/// <exception cref="ArgumentOutOfRangeException">If: <list><item><paramref name="rowIndex"/> is
/// negative, or greater than or equal to the number of rows.</item>
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// of columns.</item>
/// <item><c>(columnIndex + columnLength) &gt;= Columns</c></item>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="rowCount"/> or <paramref name="columnCount"/>
/// is not positive.</exception>
public override Matrix<double> SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount)

26
src/Numerics/LinearAlgebra/Double/SparseMatrix.cs

@ -36,16 +36,16 @@ namespace MathNet.Numerics.LinearAlgebra.Double
using Properties;
using Storage;
using Threading;
/// <summary>
/// A Matrix class with sparse storage. The underlying storage scheme is 3-array compressed-sparse-row (CSR) Format.
/// <a href="http://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR_or_CRS.29">Wikipedia - CSR</a>.
/// </summary>
[Serializable]
public class SparseMatrix : Matrix
public class SparseMatrix : Matrix
{
readonly SparseCompressedRowMatrixStorage<double> _storage;
/// <summary>
/// Gets the number of non zero elements in the matrix.
/// </summary>
@ -77,7 +77,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
: this(new SparseCompressedRowMatrixStorage<double>(rows, columns))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class. This matrix is square with a given size.
/// </summary>
@ -125,7 +125,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
values[i] = value;
columnIndices[i] = j;
}
// Set proper row pointers
for (var i = 0; i < rowPointers.Length; i++)
{
@ -134,7 +134,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// </summary>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
@ -159,7 +159,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
public SparseMatrix(double[,] array)
@ -215,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<double> LowerTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -282,7 +282,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<double> UpperTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -484,7 +484,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<double> Transpose()
{
@ -555,7 +555,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override double InfinityNorm()
{
var rowPointers = _storage.RowPointers;
@ -1088,7 +1088,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{
var start = rowPointers[row];
var end = rowPointers[row + 1];
if (start == end)
{
continue;
@ -1212,7 +1212,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
/// <summary>
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The matrix to get the values from.</param>
/// <returns>A matrix containing a the same values as <paramref name="rightSide"/>.</returns>

362
src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs

@ -229,7 +229,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
}
/// <summary>
/// Subtracts another matrix from this matrix.
/// Subtracts another matrix from this matrix.
/// </summary>
/// <param name="other">The matrix to subtract.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
@ -287,7 +287,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to multiply the matrix with.</param>
/// <param name="result">The matrix to store the result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
public void Multiply(T scalar, Matrix<T> result)
{
@ -305,13 +305,13 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
{
throw new ArgumentException(Resources.ArgumentMatrixSameColumnDimension, "result");
}
if (scalar.Equals(One))
{
CopyTo(result);
return;
}
if (scalar.Equals(Zero))
{
result.Clear();
@ -348,7 +348,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to divide the matrix with.</param>
/// <param name="result">The matrix to store the result of the division.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
public void Divide(T scalar, Matrix<T> result)
{
@ -567,7 +567,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Multiplies 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.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of the multiplication.</returns>
public virtual Matrix<T> Multiply(Matrix<T> other)
@ -629,7 +629,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Multiplies this matrix with 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>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.ColumnCount</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of the multiplication.</returns>
public virtual Matrix<T> TransposeAndMultiply(Matrix<T> other)
@ -717,7 +717,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
}
/// <summary>
/// Multiplies the transpose of this matrix with another matrix and places the results into the result matrix.
/// 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>
@ -758,7 +758,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Multiplies the 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>
/// <exception cref="ArgumentException">If <strong>this.Rows != other.RowCount</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of the multiplication.</returns>
public Matrix<T> TransposeThisAndMultiply(Matrix<T> other)
@ -843,28 +843,145 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
}
/// <summary>
/// Adds two matrices together and returns the results.
/// Pointwise multiplies this matrix with another matrix.
/// </summary>
/// <remarks>This operator will allocate new memory for the result. It will
/// choose the representation of either <paramref name="leftSide"/> or <paramref name="rightSide"/> depending on which
/// is denser.</remarks>
/// <param name="leftSide">The left matrix to add.</param>
/// <param name="rightSide">The right matrix to add.</param>
/// <returns>The result of the addition.</returns>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="leftSide"/> and <paramref name="rightSide"/> don't have the same dimensions.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator +(Matrix<T> leftSide, Matrix<T> rightSide)
/// <param name="other">The matrix to pointwise multiply with this one.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <returns>A new matrix that is the pointwise multiplication of this matrix and <paramref name="other"/>.</returns>
public Matrix<T> PointwiseMultiply(Matrix<T> other)
{
if (leftSide == null)
if (other == null)
{
throw new ArgumentNullException("leftSide");
throw new ArgumentNullException("other");
}
return leftSide.Add(rightSide);
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, "other");
}
var result = CreateMatrix(RowCount, ColumnCount);
DoPointwiseMultiply(other, result);
return result;
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>
/// <param name="other">The matrix to pointwise multiply with this one.</param>
/// <param name="result">The matrix to store the result of the pointwise multiplication.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseMultiply(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
DoPointwiseMultiply(other, result);
}
/// <summary>
/// Pointwise divide this matrix by another matrix.
/// </summary>
/// <param name="other">The matrix to pointwise subtract this one by.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <returns>A new matrix that is the pointwise division of this matrix and <paramref name="other"/>.</returns>
public Matrix<T> PointwiseDivide(Matrix<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var result = CreateMatrix(RowCount, ColumnCount);
DoPointwiseDivide(other, result);
return result;
}
/// <summary>
/// Pointwise divide this matrix by another matrix and stores the result into the result matrix.
/// </summary>
/// <param name="other">The matrix to pointwise divide this one by.</param>
/// <param name="result">The matrix to store the result of the pointwise division.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseDivide(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
DoPointwiseDivide(other, result);
}
/// <summary>
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// Computes the modulus for each element of the matrix.
/// </summary>
/// <param name="divisor">The divisor to use.</param>
/// <returns>A matrix containing the results.</returns>
public Matrix<T> Modulus(T divisor)
{
var result = CreateMatrix(RowCount, ColumnCount);
DoModulus(divisor, result);
return result;
}
/// <summary>
/// Computes the modulus for each element of the matrix.
/// </summary>
/// <param name="divisor">The divisor to use.</param>
/// <param name="result">Matrix to store the results in.</param>
public void Modulus(T divisor, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
}
DoModulus(divisor, result);
}
/// <summary>
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The matrix to get the values from.</param>
/// <returns>A matrix containing a the same values as <paramref name="rightSide"/>.</returns>
@ -880,40 +997,61 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
}
/// <summary>
/// Subtracts two matrices together and returns the results.
/// Negates each element of the matrix.
/// </summary>
/// <param name="rightSide">The matrix to negate.</param>
/// <returns>A matrix containing the negated values.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator -(Matrix<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Negate();
}
/// <summary>
/// Adds two matrices together and returns the results.
/// </summary>
/// <remarks>This operator will allocate new memory for the result. It will
/// choose the representation of either <paramref name="leftSide"/> or <paramref name="rightSide"/> depending on which
/// is denser.</remarks>
/// <param name="leftSide">The left matrix to subtract.</param>
/// <param name="rightSide">The right matrix to subtract.</param>
/// <param name="leftSide">The left matrix to add.</param>
/// <param name="rightSide">The right matrix to add.</param>
/// <returns>The result of the addition.</returns>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="leftSide"/> and <paramref name="rightSide"/> don't have the same dimensions.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator -(Matrix<T> leftSide, Matrix<T> rightSide)
public static Matrix<T> operator +(Matrix<T> leftSide, Matrix<T> rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Subtract(rightSide);
return leftSide.Add(rightSide);
}
/// <summary>
/// Negates each element of the matrix.
/// Subtracts two matrices together and returns the results.
/// </summary>
/// <param name="rightSide">The matrix to negate.</param>
/// <returns>A matrix containing the negated values.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator -(Matrix<T> rightSide)
/// <remarks>This operator will allocate new memory for the result. It will
/// choose the representation of either <paramref name="leftSide"/> or <paramref name="rightSide"/> depending on which
/// is denser.</remarks>
/// <param name="leftSide">The left matrix to subtract.</param>
/// <param name="rightSide">The right matrix to subtract.</param>
/// <returns>The result of the addition.</returns>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="leftSide"/> and <paramref name="rightSide"/> don't have the same dimensions.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator -(Matrix<T> leftSide, Matrix<T> rightSide)
{
if (rightSide == null)
if (leftSide == null)
{
throw new ArgumentNullException("rightSide");
throw new ArgumentNullException("leftSide");
}
return rightSide.Negate();
return leftSide.Subtract(rightSide);
}
/// <summary>
@ -1005,144 +1143,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return rightSide.LeftMultiply(leftSide);
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix.
/// </summary>
/// <param name="other">The matrix to pointwise multiply with this one.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <returns>A new matrix that is the pointwise multiplication of this matrix and <paramref name="other"/>.</returns>
public Matrix<T> PointwiseMultiply(Matrix<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, "other");
}
var result = CreateMatrix(RowCount, ColumnCount);
DoPointwiseMultiply(other, result);
return result;
}
/// <summary>
/// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix.
/// </summary>
/// <param name="other">The matrix to pointwise multiply with this one.</param>
/// <param name="result">The matrix to store the result of the pointwise multiplication.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseMultiply(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
DoPointwiseMultiply(other, result);
}
/// <summary>
/// Pointwise divide this matrix by another matrix.
/// </summary>
/// <param name="other">The matrix to pointwise subtract this one by.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <returns>A new matrix that is the pointwise division of this matrix and <paramref name="other"/>.</returns>
public Matrix<T> PointwiseDivide(Matrix<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var result = CreateMatrix(RowCount, ColumnCount);
DoPointwiseDivide(other, result);
return result;
}
/// <summary>
/// Pointwise divide this matrix by another matrix and stores the result into the result matrix.
/// </summary>
/// <param name="other">The matrix to pointwise divide this one by.</param>
/// <param name="result">The matrix to store the result of the pointwise division.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="other"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseDivide(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
DoPointwiseDivide(other, result);
}
/// <summary>
/// Computes the modulus for each element of the matrix.
/// </summary>
/// <param name="divisor">The divisor to use.</param>
/// <returns>A matrix containing the results.</returns>
public Matrix<T> Modulus(T divisor)
{
var result = CreateMatrix(RowCount, ColumnCount);
DoModulus(divisor, result);
return result;
}
/// <summary>
/// Computes the modulus for each element of the matrix.
/// </summary>
/// <param name="divisor">The divisor to use.</param>
/// <param name="result">Matrix to store the results in.</param>
public void Modulus(T divisor, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
}
DoModulus(divisor, result);
}
/// <summary>
/// Multiplies a <strong>Matrix</strong> by a constant and returns the result.
/// </summary>
@ -1310,21 +1310,21 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
#region Exceptions - possibly move elsewhere?
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Matrix<T> right, Matrix<T> result, string paramName = null)
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Matrix<T> right, Matrix<T> result, string paramName = null)
where TException : Exception
{
var message = string.Format(Resources.ArgumentMatrixDimensions3, left.RowCount + "x" + left.ColumnCount, right.RowCount + "x" + right.ColumnCount, result.RowCount + "x" + result.ColumnCount);
return CreateException<TException>(message, paramName);
}
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Matrix<T> right, string paramName = null)
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Matrix<T> right, string paramName = null)
where TException : Exception
{
var message = string.Format(Resources.ArgumentMatrixDimensions2, left.RowCount + "x" + left.ColumnCount, right.RowCount + "x" + right.ColumnCount);
return CreateException<TException>(message, paramName);
}
public static Exception DimensionsDontMatch<TException>(Matrix<T> matrix)
public static Exception DimensionsDontMatch<TException>(Matrix<T> matrix)
where TException : Exception
{
var message = string.Format(Resources.ArgumentMatrixDimensions1, matrix.RowCount + "x" + matrix.ColumnCount);
@ -1337,25 +1337,25 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return DimensionsDontMatch<TException>(left, right.ToColumnMatrix(), result.ToColumnMatrix(), paramName);
}
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Vector<T> right, string paramName = null)
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Vector<T> right, string paramName = null)
where TException : Exception
{
return DimensionsDontMatch<TException>(left, right.ToColumnMatrix(), paramName);
}
public static Exception DimensionsDontMatch<TException>(Vector<T> left, Matrix<T> right, string paramName = null)
public static Exception DimensionsDontMatch<TException>(Vector<T> left, Matrix<T> right, string paramName = null)
where TException : Exception
{
return DimensionsDontMatch<TException>(left.ToColumnMatrix(), right, paramName);
}
public static Exception DimensionsDontMatch<TException>(Vector<T> left, Vector<T> right, string paramName = null)
public static Exception DimensionsDontMatch<TException>(Vector<T> left, Vector<T> right, string paramName = null)
where TException : Exception
{
return DimensionsDontMatch<TException>(left.ToColumnMatrix(), right.ToColumnMatrix(), paramName);
}
private static Exception CreateException<TException>(string message, string paramName = null)
private static Exception CreateException<TException>(string message, string paramName = null)
where TException : Exception
{
if (typeof(TException) == typeof(ArgumentException))

32
src/Numerics/LinearAlgebra/Generic/Vector.cs

@ -832,6 +832,22 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return rightSide.Plus();
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing the negated values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator -(Vector<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Negate();
}
/// <summary>
/// Adds two <strong>Vectors</strong> together and returns the results.
/// </summary>
@ -884,22 +900,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return rightSide.Add(leftSide);
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing the negated values as <paramref name="rightSide"/>.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator -(Vector<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Negate();
}
/// <summary>
/// Subtracts two <strong>Vectors</strong> and returns the results.
/// </summary>

24
src/Numerics/LinearAlgebra/Single/DenseVector.cs

@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// Initializes a new instance of the <see cref="DenseVector"/> class for an array.
/// </summary>
/// <param name="array">The array to create this vector from.</param>
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// <remarks>The vector does not copy the array, but keeps a reference to it. Any
/// changes to the vector will also change the array.</remarks>
public DenseVector(float[] array)
: this(new DenseVectorStorage<float>(array.Length, array))
@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <remarks>This method is included for completeness.</remarks>
/// <param name="rightSide">The vector to get the values from.</param>
@ -333,9 +333,9 @@ namespace MathNet.Numerics.LinearAlgebra.Single
Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values);
}
}
/// <summary>
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// Returns a <strong>Vector</strong> containing the negated values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The vector to get the values from.</param>
/// <returns>A vector containing the negated values as <paramref name="rightSide"/>.</returns>
@ -530,7 +530,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the absolute minimum element.
/// </summary>
/// <returns>The index of absolute minimum element.</returns>
/// <returns>The index of absolute minimum element.</returns>
public override int AbsoluteMinimumIndex()
{
var index = 0;
@ -569,7 +569,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int AbsoluteMaximumIndex()
{
var index = 0;
@ -590,7 +590,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int MaximumIndex()
{
var index = 0;
@ -610,7 +610,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the minimum element.
/// </summary>
/// <returns>The index of minimum element.</returns>
/// <returns>The index of minimum element.</returns>
public override int MinimumIndex()
{
var index = 0;
@ -706,8 +706,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <param name="u">First vector</param>
/// <param name="v">Second vector</param>
/// <returns>Matrix M[i,j] = u[i]*v[j] </returns>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the u vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the v vector is <see langword="null" />.</exception>
public static DenseMatrix OuterProduct(DenseVector u, DenseVector v)
{
if (u == null)
@ -722,8 +722,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single
var matrix = new DenseMatrix(u.Count, v.Count);
CommonParallel.For(
0,
u.Count,
0,
u.Count,
i =>
{
for (var j = 0; j < v.Count; j++)

30
src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs

@ -33,7 +33,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
using Storage;
/// <summary>
/// A matrix type for diagonal matrices.
/// A matrix type for diagonal matrices.
/// </summary>
/// <remarks>
/// Diagonal matrices can be non-square matrices but the diagonal always starts
@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="DiagonalMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
/// <exception cref="IndexOutOfRangeException">When <paramref name="array"/> contains an off-diagonal element.</exception>
@ -276,7 +276,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>
/// Subtracts another matrix from this matrix.
/// Subtracts another matrix from this matrix.
/// </summary>
/// <param name="other">The matrix to subtract.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// </summary>
/// <param name="source">The array to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -327,7 +327,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// </summary>
/// <param name="source">The vector to copy the values from. The length of the vector should be
/// Min(Rows, Columns).</param>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="source"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the length of <paramref name="source"/> does not
/// equal Min(Rows, Columns).</exception>
/// <remarks>For non-square matrices, the elements of <paramref name="source"/> are copied to
@ -354,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// </summary>
/// <param name="scalar">The scalar to multiply the matrix with.</param>
/// <param name="result">The matrix to store the result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
protected override void DoMultiply(float scalar, Matrix<float> result)
{
@ -434,7 +434,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// Multiplies 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.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<float> Multiply(Matrix<float> other)
@ -608,7 +608,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// Multiplies this matrix with 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.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <returns>The result of multiplication.</returns>
public override Matrix<float> TransposeAndMultiply(Matrix<float> other)
@ -633,7 +633,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<float> Transpose()
{
@ -650,7 +650,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>Calculates the L2 norm.</summary>
/// <returns>The L2 norm of the matrix.</returns>
/// <returns>The L2 norm of the matrix.</returns>
public override float L2Norm()
{
return _data.Aggregate(float.NegativeInfinity, (current, t) => Math.Max(current, Math.Abs(t)));
@ -665,7 +665,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override float InfinityNorm()
{
return L1Norm();
@ -716,7 +716,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<float> LowerTriangle()
{
return Clone();
@ -786,7 +786,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<float> UpperTriangle()
{
return Clone();
@ -858,10 +858,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <returns>The requested sub-matrix.</returns>
/// <exception cref="ArgumentOutOfRangeException">If: <list><item><paramref name="rowIndex"/> is
/// negative, or greater than or equal to the number of rows.</item>
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// <item><paramref name="columnIndex"/> is negative, or greater than or equal to the number
/// of columns.</item>
/// <item><c>(columnIndex + columnLength) &gt;= Columns</c></item>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <item><c>(rowIndex + rowLength) &gt;= Rows</c></item></list></exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="rowCount"/> or <paramref name="columnCount"/>
/// is not positive.</exception>
public override Matrix<float> SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount)

20
src/Numerics/LinearAlgebra/Single/SparseMatrix.cs

@ -36,7 +36,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
using Properties;
using Storage;
using Threading;
/// <summary>
/// A Matrix class with sparse storage. The underlying storage scheme is 3-array compressed-sparse-row (CSR) Format.
/// <a href="http://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR_or_CRS.29">Wikipedia - CSR</a>.
@ -77,7 +77,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
: this(new SparseCompressedRowMatrixStorage<float>(rows, columns))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class. This matrix is square with a given size.
/// </summary>
@ -134,7 +134,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a one dimensional array.
/// </summary>
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
@ -159,7 +159,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// Initializes a new instance of the <see cref="SparseMatrix"/> class from a 2D array.
/// </summary>
/// <param name="array">The 2D array to create this matrix from.</param>
public SparseMatrix(float[,] array)
@ -215,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns a new matrix containing the lower triangle of this matrix.
/// </summary>
/// <returns>The lower triangle of this matrix.</returns>
/// <returns>The lower triangle of this matrix.</returns>
public override Matrix<float> LowerTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -282,7 +282,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns a new matrix containing the upper triangle of this matrix.
/// </summary>
/// <returns>The upper triangle of this matrix.</returns>
/// <returns>The upper triangle of this matrix.</returns>
public override Matrix<float> UpperTriangle()
{
var result = CreateMatrix(RowCount, ColumnCount);
@ -484,7 +484,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the transpose of this matrix.
/// </summary>
/// </summary>
/// <returns>The transpose of this matrix.</returns>
public override Matrix<float> Transpose()
{
@ -555,7 +555,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>Calculates the infinity norm of this matrix.</summary>
/// <returns>The infinity norm of this matrix.</returns>
/// <returns>The infinity norm of this matrix.</returns>
public override float InfinityNorm()
{
var rowPointers = _storage.RowPointers;
@ -747,7 +747,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
}
/// <summary>
/// Multiplies each element of the matrix by a scalar and places results into the result matrix.
/// </summary>
@ -1211,7 +1211,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
/// <summary>
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// Returns a <strong>Matrix</strong> containing the same values of <paramref name="rightSide"/>.
/// </summary>
/// <param name="rightSide">The matrix to get the values from.</param>
/// <returns>A matrix containing a the same values as <paramref name="rightSide"/>.</returns>

10
src/Numerics/LinearAlgebra/Single/Vector.cs

@ -42,7 +42,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
public abstract class Vector : Vector<float>
{
/// <summary>
/// Initializes a new instance of the Vector class.
/// Initializes a new instance of the Vector class.
/// </summary>
protected Vector(VectorStorage<float> storage)
: base(storage)
@ -217,7 +217,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the absolute minimum element.
/// </summary>
/// <returns>The index of absolute minimum element.</returns>
/// <returns>The index of absolute minimum element.</returns>
public override int AbsoluteMinimumIndex()
{
var index = 0;
@ -247,7 +247,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int AbsoluteMaximumIndex()
{
var index = 0;
@ -357,7 +357,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the absolute maximum element.
/// </summary>
/// <returns>The index of absolute maximum element.</returns>
/// <returns>The index of absolute maximum element.</returns>
public override int MaximumIndex()
{
var index = 0;
@ -378,7 +378,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// <summary>
/// Returns the index of the minimum element.
/// </summary>
/// <returns>The index of minimum element.</returns>
/// <returns>The index of minimum element.</returns>
public override int MinimumIndex()
{
var index = 0;

6
src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs

@ -265,7 +265,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
@ -390,7 +390,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
{
return;
}
for (int i = 0; i < ValueCount; i++)
{
target.At(Indices[i], columnIndex, Values[i]);
@ -466,7 +466,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
return;
}
// special case for empty target - much faster
if (target.ValueCount == 0)
{

Loading…
Cancel
Save