diff --git a/src/Numerics/LinearAlgebra/Complex/DenseVector.cs b/src/Numerics/LinearAlgebra/Complex/DenseVector.cs index a0b94c59..b6c98443 100644 --- a/src/Numerics/LinearAlgebra/Complex/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex/DenseVector.cs @@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Initializes a new instance of the class for an array. /// /// The array to create this vector from. - /// The vector does not copy the array, but keeps a reference to it. Any + /// The vector does not copy the array, but keeps a reference to it. Any /// changes to the vector will also change the array. public DenseVector(Complex[] array) : this(new DenseVectorStorage(array.Length, array)) @@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } /// - /// Returns a Vector containing the same values of . + /// Returns a Vector containing the same values of . /// /// This method is included for completeness. /// The vector to get the values from. @@ -335,7 +335,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } /// - /// Returns a Vector containing the negated values of . + /// Returns a Vector containing the negated values of . /// /// The vector to get the values from. /// A vector containing the negated values as . @@ -489,7 +489,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns the index of the absolute minimum element. /// - /// The index of absolute minimum element. + /// The index of absolute minimum element. public override int AbsoluteMinimumIndex() { var index = 0; @@ -528,7 +528,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int AbsoluteMaximumIndex() { var index = 0; @@ -625,8 +625,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// First vector /// Second vector /// Matrix M[i,j] = u[i]*v[j] - /// If the u vector is . - /// If the v vector is . + /// If the u vector is . + /// If the v vector is . 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++) diff --git a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs index 1e1180f0..84d0292a 100644 --- a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs @@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex using Storage; /// - /// A matrix type for diagonal matrices. + /// A matrix type for diagonal matrices. /// /// /// Diagonal matrices can be non-square matrices but the diagonal always starts @@ -121,7 +121,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. /// When contains an off-diagonal element. @@ -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 } /// - /// Subtracts another matrix from this matrix. + /// Subtracts another matrix from this matrix. /// /// The matrix to subtract. /// The matrix to store the result of the subtraction. @@ -303,7 +303,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The array to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of 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 /// /// The vector to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of are copied to @@ -355,7 +355,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// The scalar to multiply the matrix with. /// The matrix to store the result of the multiplication. - /// If the result matrix is . + /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. protected override void DoMultiply(Complex scalar, Matrix result) { @@ -440,7 +440,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Multiplies this matrix with another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix Multiply(Matrix other) @@ -614,7 +614,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// Multiplies this matrix with transpose of another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix TransposeAndMultiply(Matrix other) @@ -639,7 +639,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -656,7 +656,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } /// Calculates the L2 norm. - /// The L2 norm of the matrix. + /// The L2 norm of the matrix. 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 } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. public override Complex InfinityNorm() { return L1Norm(); @@ -722,7 +722,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { return Clone(); @@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { return Clone(); @@ -864,10 +864,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// The requested sub-matrix. /// If: is /// negative, or greater than or equal to the number of rows. - /// is negative, or greater than or equal to the number + /// is negative, or greater than or equal to the number /// of columns. /// (columnIndex + columnLength) >= Columns - /// (rowIndex + rowLength) >= Rows + /// (rowIndex + rowLength) >= Rows /// If or /// is not positive. public override Matrix SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount) diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs index f321d76c..07581bff 100644 --- a/src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs +++ b/src/Numerics/LinearAlgebra/Complex/Factorization/Svd.cs @@ -39,13 +39,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization /// /// A class which encapsulates the functionality of the singular value decomposition (SVD). - /// Suppose M is an m-by-n matrix whose entries are real numbers. + /// 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. /// /// diff --git a/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs index 85e24d40..15aca2aa 100644 --- a/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs @@ -135,7 +135,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } /// - /// Initializes a new instance of the class from a one dimensional array. + /// Initializes a new instance of the class from a one dimensional array. /// /// The number of rows. /// The number of columns. @@ -160,7 +160,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. public SparseMatrix(Complex[,] array) @@ -216,7 +216,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -283,7 +283,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -485,7 +485,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -557,7 +557,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. 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 } /// - /// Returns a Matrix containing the same values of . + /// Returns a Matrix containing the same values of . /// /// The matrix to get the values from. /// A matrix containing a the same values as . diff --git a/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs b/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs index d5444ada..084cc5f0 100644 --- a/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/DenseVector.cs @@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Initializes a new instance of the class for an array. /// /// The array to create this vector from. - /// The vector does not copy the array, but keeps a reference to it. Any + /// The vector does not copy the array, but keeps a reference to it. Any /// changes to the vector will also change the array. public DenseVector(Complex32[] array) : this(new DenseVectorStorage(array.Length, array)) @@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// - /// Returns a Vector containing the same values of . + /// Returns a Vector containing the same values of . /// /// This method is included for completeness. /// The vector to get the values from. @@ -333,9 +333,9 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values); } } - + /// - /// Returns a Vector containing the negated values of . + /// Returns a Vector containing the negated values of . /// /// The vector to get the values from. /// A vector containing the negated values as . @@ -489,7 +489,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the index of the absolute minimum element. /// - /// The index of absolute minimum element. + /// The index of absolute minimum element. public override int AbsoluteMinimumIndex() { var index = 0; @@ -528,7 +528,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int AbsoluteMaximumIndex() { var index = 0; @@ -625,8 +625,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// First vector /// Second vector /// Matrix M[i,j] = u[i]*v[j] - /// If the u vector is . - /// If the v vector is . + /// If the u vector is . + /// If the v vector is . 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++) diff --git a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs index aa6152a5..6cab5196 100644 --- a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs @@ -34,7 +34,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 using Storage; /// - /// A matrix type for diagonal matrices. + /// A matrix type for diagonal matrices. /// /// /// Diagonal matrices can be non-square matrices but the diagonal always starts @@ -121,7 +121,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. /// When contains an off-diagonal element. @@ -277,7 +277,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// - /// Subtracts another matrix from this matrix. + /// Subtracts another matrix from this matrix. /// /// The matrix to subtract. /// The matrix to store the result of the subtraction. @@ -303,7 +303,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The array to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of are copied to @@ -328,7 +328,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The vector to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of are copied to @@ -355,7 +355,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// The scalar to multiply the matrix with. /// The matrix to store the result of the multiplication. - /// If the result matrix is . + /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. protected override void DoMultiply(Complex32 scalar, Matrix result) { @@ -440,7 +440,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Multiplies this matrix with another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix Multiply(Matrix other) @@ -614,7 +614,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// Multiplies this matrix with transpose of another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix TransposeAndMultiply(Matrix other) @@ -639,7 +639,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -656,7 +656,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// Calculates the L2 norm. - /// The L2 norm of the matrix. + /// The L2 norm of the matrix. 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 } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. public override Complex32 InfinityNorm() { return L1Norm(); @@ -722,7 +722,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { return Clone(); @@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { return Clone(); @@ -864,10 +864,10 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// The requested sub-matrix. /// If: is /// negative, or greater than or equal to the number of rows. - /// is negative, or greater than or equal to the number + /// is negative, or greater than or equal to the number /// of columns. /// (columnIndex + columnLength) >= Columns - /// (rowIndex + rowLength) >= Rows + /// (rowIndex + rowLength) >= Rows /// If or /// is not positive. public override Matrix SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount) diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs index 27160e65..d1f930e5 100644 --- a/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs @@ -37,7 +37,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 using Properties; using Storage; using Threading; - + /// /// A Matrix class with sparse storage. The underlying storage scheme is 3-array compressed-sparse-row (CSR) Format. /// Wikipedia - CSR. @@ -135,7 +135,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// - /// Initializes a new instance of the class from a one dimensional array. + /// Initializes a new instance of the class from a one dimensional array. /// /// The number of rows. /// The number of columns. @@ -160,7 +160,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. public SparseMatrix(Complex32[,] array) @@ -216,7 +216,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -283,7 +283,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -485,7 +485,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -557,7 +557,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. public override Complex32 InfinityNorm() { var rowPointers = _storage.RowPointers; @@ -1187,7 +1187,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 } /// - /// Returns a Matrix containing the same values of . + /// Returns a Matrix containing the same values of . /// /// The matrix to get the values from. /// A matrix containing a the same values as . diff --git a/src/Numerics/LinearAlgebra/Complex32/Vector.cs b/src/Numerics/LinearAlgebra/Complex32/Vector.cs index 31ba9311..36a45140 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Vector.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Vector.cs @@ -43,7 +43,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 public abstract class Vector : Vector { /// - /// Initializes a new instance of the Vector class. + /// Initializes a new instance of the Vector class. /// protected Vector(VectorStorage storage) : base(storage) @@ -215,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the index of the absolute minimum element. /// - /// The index of absolute minimum element. + /// The index of absolute minimum element. public override int AbsoluteMinimumIndex() { var index = 0; @@ -245,7 +245,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int AbsoluteMaximumIndex() { var index = 0; @@ -353,7 +353,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int MaximumIndex() { throw new NotSupportedException(); @@ -362,7 +362,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// /// Returns the index of the minimum element. /// - /// The index of minimum element. + /// The index of minimum element. public override int MinimumIndex() { throw new NotSupportedException(); diff --git a/src/Numerics/LinearAlgebra/Double/DenseVector.cs b/src/Numerics/LinearAlgebra/Double/DenseVector.cs index 5ec6ca2a..82fdc5b4 100644 --- a/src/Numerics/LinearAlgebra/Double/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Double/DenseVector.cs @@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Initializes a new instance of the class for an array. /// /// The array to create this vector from. - /// The vector does not copy the array, but keeps a reference to it. Any + /// The vector does not copy the array, but keeps a reference to it. Any /// changes to the vector will also change the array. public DenseVector(double[] array) : this(new DenseVectorStorage(array.Length, array)) @@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } /// - /// Returns a Vector containing the same values of . + /// Returns a Vector containing the same values of . /// /// This method is included for completeness. /// The vector to get the values from. @@ -343,9 +343,9 @@ namespace MathNet.Numerics.LinearAlgebra.Double Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values); } } - + /// - /// Returns a Vector containing the negated values of . + /// Returns a Vector containing the negated values of . /// /// The vector to get the values from. /// A vector containing the negated values as . @@ -540,7 +540,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns the index of the absolute minimum element. /// - /// The index of absolute minimum element. + /// The index of absolute minimum element. public override int AbsoluteMinimumIndex() { var index = 0; @@ -579,7 +579,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int AbsoluteMaximumIndex() { var index = 0; @@ -600,7 +600,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int MaximumIndex() { var index = 0; @@ -620,7 +620,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns the index of the minimum element. /// - /// The index of minimum element. + /// The index of minimum element. public override int MinimumIndex() { var index = 0; @@ -716,8 +716,8 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// First vector /// Second vector /// Matrix M[i,j] = u[i]*v[j] - /// If the u vector is . - /// If the v vector is . + /// If the u vector is . + /// If the v vector is . 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 diff --git a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs index 10b64224..e2d51eab 100644 --- a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs @@ -33,7 +33,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double using Storage; /// - /// A matrix type for diagonal matrices. + /// A matrix type for diagonal matrices. /// /// /// Diagonal matrices can be non-square matrices but the diagonal always starts @@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. /// When contains an off-diagonal element. @@ -276,7 +276,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } /// - /// Subtracts another matrix from this matrix. + /// Subtracts another matrix from this matrix. /// /// The matrix to subtract. /// The matrix to store the result of the subtraction. @@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// The array to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of are copied to @@ -327,7 +327,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// The vector to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of are copied to @@ -354,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// The scalar to multiply the matrix with. /// The matrix to store the result of the multiplication. - /// If the result matrix is . + /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. protected override void DoMultiply(double scalar, Matrix result) { @@ -434,7 +434,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Multiplies this matrix with another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix Multiply(Matrix other) @@ -608,7 +608,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// Multiplies this matrix with transpose of another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix TransposeAndMultiply(Matrix other) @@ -633,7 +633,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -650,7 +650,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } /// Calculates the L2 norm. - /// The L2 norm of the matrix. + /// The L2 norm of the matrix. 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 } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. public override double InfinityNorm() { return L1Norm(); @@ -716,7 +716,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { return Clone(); @@ -786,7 +786,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { return Clone(); @@ -858,10 +858,10 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// The requested sub-matrix. /// If: is /// negative, or greater than or equal to the number of rows. - /// is negative, or greater than or equal to the number + /// is negative, or greater than or equal to the number /// of columns. /// (columnIndex + columnLength) >= Columns - /// (rowIndex + rowLength) >= Rows + /// (rowIndex + rowLength) >= Rows /// If or /// is not positive. public override Matrix SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount) diff --git a/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs index 93821d42..972850a8 100644 --- a/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs @@ -36,16 +36,16 @@ namespace MathNet.Numerics.LinearAlgebra.Double using Properties; using Storage; using Threading; - + /// /// A Matrix class with sparse storage. The underlying storage scheme is 3-array compressed-sparse-row (CSR) Format. /// Wikipedia - CSR. /// [Serializable] - public class SparseMatrix : Matrix + public class SparseMatrix : Matrix { readonly SparseCompressedRowMatrixStorage _storage; - + /// /// Gets the number of non zero elements in the matrix. /// @@ -77,7 +77,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double : this(new SparseCompressedRowMatrixStorage(rows, columns)) { } - + /// /// Initializes a new instance of the class. This matrix is square with a given size. /// @@ -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 } /// - /// Initializes a new instance of the class from a one dimensional array. + /// Initializes a new instance of the class from a one dimensional array. /// /// The number of rows. /// The number of columns. @@ -159,7 +159,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. public SparseMatrix(double[,] array) @@ -215,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -282,7 +282,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -484,7 +484,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -555,7 +555,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. 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 } /// - /// Returns a Matrix containing the same values of . + /// Returns a Matrix containing the same values of . /// /// The matrix to get the values from. /// A matrix containing a the same values as . diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs index 3201bbbc..0a9754bc 100644 --- a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs +++ b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs @@ -229,7 +229,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic } /// - /// Subtracts another matrix from this matrix. + /// Subtracts another matrix from this matrix. /// /// The matrix to subtract. /// The matrix to store the result of the subtraction. @@ -287,7 +287,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The scalar to multiply the matrix with. /// The matrix to store the result of the multiplication. - /// If the result matrix is . + /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. public void Multiply(T scalar, Matrix 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 /// /// The scalar to divide the matrix with. /// The matrix to store the result of the division. - /// If the result matrix is . + /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. public void Divide(T scalar, Matrix result) { @@ -567,7 +567,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Multiplies this matrix with another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of the multiplication. public virtual Matrix Multiply(Matrix other) @@ -629,7 +629,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Multiplies this matrix with transpose of another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.ColumnCount. + /// If this.Columns != other.ColumnCount. /// If the other matrix is . /// The result of the multiplication. public virtual Matrix TransposeAndMultiply(Matrix other) @@ -717,7 +717,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic } /// - /// 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. /// /// The matrix to multiply with. /// The result of the multiplication. @@ -758,7 +758,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Multiplies the transpose of this matrix with another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Rows != other.RowCount. + /// If this.Rows != other.RowCount. /// If the other matrix is . /// The result of the multiplication. public Matrix TransposeThisAndMultiply(Matrix other) @@ -843,28 +843,145 @@ namespace MathNet.Numerics.LinearAlgebra.Generic } /// - /// Adds two matrices together and returns the results. + /// Pointwise multiplies this matrix with another matrix. /// - /// This operator will allocate new memory for the result. It will - /// choose the representation of either or depending on which - /// is denser. - /// The left matrix to add. - /// The right matrix to add. - /// The result of the addition. - /// If and don't have the same dimensions. - /// If or is . - public static Matrix operator +(Matrix leftSide, Matrix rightSide) + /// The matrix to pointwise multiply with this one. + /// If the other matrix is . + /// If this matrix and are not the same size. + /// A new matrix that is the pointwise multiplication of this matrix and . + public Matrix PointwiseMultiply(Matrix 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(this, other, "other"); + } + + var result = CreateMatrix(RowCount, ColumnCount); + DoPointwiseMultiply(other, result); + return result; + } + + /// + /// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix. + /// + /// The matrix to pointwise multiply with this one. + /// The matrix to store the result of the pointwise multiplication. + /// If the other matrix is . + /// If the result matrix is . + /// If this matrix and are not the same size. + /// If this matrix and are not the same size. + public void PointwiseMultiply(Matrix other, Matrix 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(this, other, result); + } + + DoPointwiseMultiply(other, result); + } + + /// + /// Pointwise divide this matrix by another matrix. + /// + /// The matrix to pointwise subtract this one by. + /// If the other matrix is . + /// If this matrix and are not the same size. + /// A new matrix that is the pointwise division of this matrix and . + public Matrix PointwiseDivide(Matrix other) + { + if (other == null) + { + throw new ArgumentNullException("other"); + } + + if (ColumnCount != other.ColumnCount || RowCount != other.RowCount) + { + throw DimensionsDontMatch(this, other); + } + + var result = CreateMatrix(RowCount, ColumnCount); + DoPointwiseDivide(other, result); + return result; + } + + /// + /// Pointwise divide this matrix by another matrix and stores the result into the result matrix. + /// + /// The matrix to pointwise divide this one by. + /// The matrix to store the result of the pointwise division. + /// If the other matrix is . + /// If the result matrix is . + /// If this matrix and are not the same size. + /// If this matrix and are not the same size. + public void PointwiseDivide(Matrix other, Matrix 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(this, other, result); + } + + DoPointwiseDivide(other, result); } /// - /// Returns a Matrix containing the same values of . + /// Computes the modulus for each element of the matrix. + /// + /// The divisor to use. + /// A matrix containing the results. + public Matrix Modulus(T divisor) + { + var result = CreateMatrix(RowCount, ColumnCount); + DoModulus(divisor, result); + return result; + } + + /// + /// Computes the modulus for each element of the matrix. + /// + /// The divisor to use. + /// Matrix to store the results in. + public void Modulus(T divisor, Matrix result) + { + if (result == null) + { + throw new ArgumentNullException("result"); + } + + if (ColumnCount != result.ColumnCount || RowCount != result.RowCount) + { + throw DimensionsDontMatch(this, result); + } + + DoModulus(divisor, result); + } + + /// + /// Returns a Matrix containing the same values of . /// /// The matrix to get the values from. /// A matrix containing a the same values as . @@ -880,40 +997,61 @@ namespace MathNet.Numerics.LinearAlgebra.Generic } /// - /// Subtracts two matrices together and returns the results. + /// Negates each element of the matrix. + /// + /// The matrix to negate. + /// A matrix containing the negated values. + /// If is . + public static Matrix operator -(Matrix rightSide) + { + if (rightSide == null) + { + throw new ArgumentNullException("rightSide"); + } + + return rightSide.Negate(); + } + + /// + /// Adds two matrices together and returns the results. /// /// This operator will allocate new memory for the result. It will /// choose the representation of either or depending on which /// is denser. - /// The left matrix to subtract. - /// The right matrix to subtract. + /// The left matrix to add. + /// The right matrix to add. /// The result of the addition. /// If and don't have the same dimensions. /// If or is . - public static Matrix operator -(Matrix leftSide, Matrix rightSide) + public static Matrix operator +(Matrix leftSide, Matrix rightSide) { if (leftSide == null) { throw new ArgumentNullException("leftSide"); } - return leftSide.Subtract(rightSide); + return leftSide.Add(rightSide); } /// - /// Negates each element of the matrix. + /// Subtracts two matrices together and returns the results. /// - /// The matrix to negate. - /// A matrix containing the negated values. - /// If is . - public static Matrix operator -(Matrix rightSide) + /// This operator will allocate new memory for the result. It will + /// choose the representation of either or depending on which + /// is denser. + /// The left matrix to subtract. + /// The right matrix to subtract. + /// The result of the addition. + /// If and don't have the same dimensions. + /// If or is . + public static Matrix operator -(Matrix leftSide, Matrix rightSide) { - if (rightSide == null) + if (leftSide == null) { - throw new ArgumentNullException("rightSide"); + throw new ArgumentNullException("leftSide"); } - return rightSide.Negate(); + return leftSide.Subtract(rightSide); } /// @@ -1005,144 +1143,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic return rightSide.LeftMultiply(leftSide); } - /// - /// Pointwise multiplies this matrix with another matrix. - /// - /// The matrix to pointwise multiply with this one. - /// If the other matrix is . - /// If this matrix and are not the same size. - /// A new matrix that is the pointwise multiplication of this matrix and . - public Matrix PointwiseMultiply(Matrix other) - { - if (other == null) - { - throw new ArgumentNullException("other"); - } - - if (ColumnCount != other.ColumnCount || RowCount != other.RowCount) - { - throw DimensionsDontMatch(this, other, "other"); - } - - var result = CreateMatrix(RowCount, ColumnCount); - DoPointwiseMultiply(other, result); - return result; - } - - /// - /// Pointwise multiplies this matrix with another matrix and stores the result into the result matrix. - /// - /// The matrix to pointwise multiply with this one. - /// The matrix to store the result of the pointwise multiplication. - /// If the other matrix is . - /// If the result matrix is . - /// If this matrix and are not the same size. - /// If this matrix and are not the same size. - public void PointwiseMultiply(Matrix other, Matrix 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(this, other, result); - } - - DoPointwiseMultiply(other, result); - } - - /// - /// Pointwise divide this matrix by another matrix. - /// - /// The matrix to pointwise subtract this one by. - /// If the other matrix is . - /// If this matrix and are not the same size. - /// A new matrix that is the pointwise division of this matrix and . - public Matrix PointwiseDivide(Matrix other) - { - if (other == null) - { - throw new ArgumentNullException("other"); - } - - if (ColumnCount != other.ColumnCount || RowCount != other.RowCount) - { - throw DimensionsDontMatch(this, other); - } - - var result = CreateMatrix(RowCount, ColumnCount); - DoPointwiseDivide(other, result); - return result; - } - - /// - /// Pointwise divide this matrix by another matrix and stores the result into the result matrix. - /// - /// The matrix to pointwise divide this one by. - /// The matrix to store the result of the pointwise division. - /// If the other matrix is . - /// If the result matrix is . - /// If this matrix and are not the same size. - /// If this matrix and are not the same size. - public void PointwiseDivide(Matrix other, Matrix 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(this, other, result); - } - - DoPointwiseDivide(other, result); - } - - /// - /// Computes the modulus for each element of the matrix. - /// - /// The divisor to use. - /// A matrix containing the results. - public Matrix Modulus(T divisor) - { - var result = CreateMatrix(RowCount, ColumnCount); - DoModulus(divisor, result); - return result; - } - - /// - /// Computes the modulus for each element of the matrix. - /// - /// The divisor to use. - /// Matrix to store the results in. - public void Modulus(T divisor, Matrix result) - { - if (result == null) - { - throw new ArgumentNullException("result"); - } - - if (ColumnCount != result.ColumnCount || RowCount != result.RowCount) - { - throw DimensionsDontMatch(this, result); - } - - DoModulus(divisor, result); - } - /// /// Multiplies a Matrix by a constant and returns the result. /// @@ -1310,21 +1310,21 @@ namespace MathNet.Numerics.LinearAlgebra.Generic #region Exceptions - possibly move elsewhere? - public static Exception DimensionsDontMatch(Matrix left, Matrix right, Matrix result, string paramName = null) + public static Exception DimensionsDontMatch(Matrix left, Matrix right, Matrix 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(message, paramName); } - public static Exception DimensionsDontMatch(Matrix left, Matrix right, string paramName = null) + public static Exception DimensionsDontMatch(Matrix left, Matrix 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(message, paramName); } - public static Exception DimensionsDontMatch(Matrix matrix) + public static Exception DimensionsDontMatch(Matrix 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(left, right.ToColumnMatrix(), result.ToColumnMatrix(), paramName); } - public static Exception DimensionsDontMatch(Matrix left, Vector right, string paramName = null) + public static Exception DimensionsDontMatch(Matrix left, Vector right, string paramName = null) where TException : Exception { return DimensionsDontMatch(left, right.ToColumnMatrix(), paramName); } - public static Exception DimensionsDontMatch(Vector left, Matrix right, string paramName = null) + public static Exception DimensionsDontMatch(Vector left, Matrix right, string paramName = null) where TException : Exception { return DimensionsDontMatch(left.ToColumnMatrix(), right, paramName); } - public static Exception DimensionsDontMatch(Vector left, Vector right, string paramName = null) + public static Exception DimensionsDontMatch(Vector left, Vector right, string paramName = null) where TException : Exception { return DimensionsDontMatch(left.ToColumnMatrix(), right.ToColumnMatrix(), paramName); } - private static Exception CreateException(string message, string paramName = null) + private static Exception CreateException(string message, string paramName = null) where TException : Exception { if (typeof(TException) == typeof(ArgumentException)) diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.cs b/src/Numerics/LinearAlgebra/Generic/Vector.cs index e547a34a..b61285a9 100644 --- a/src/Numerics/LinearAlgebra/Generic/Vector.cs +++ b/src/Numerics/LinearAlgebra/Generic/Vector.cs @@ -832,6 +832,22 @@ namespace MathNet.Numerics.LinearAlgebra.Generic return rightSide.Plus(); } + /// + /// Returns a Vector containing the negated values of . + /// + /// The vector to get the values from. + /// A vector containing the negated values as . + /// If is . + public static Vector operator -(Vector rightSide) + { + if (rightSide == null) + { + throw new ArgumentNullException("rightSide"); + } + + return rightSide.Negate(); + } + /// /// Adds two Vectors together and returns the results. /// @@ -884,22 +900,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic return rightSide.Add(leftSide); } - /// - /// Returns a Vector containing the negated values of . - /// - /// The vector to get the values from. - /// A vector containing the negated values as . - /// If is . - public static Vector operator -(Vector rightSide) - { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - return rightSide.Negate(); - } - /// /// Subtracts two Vectors and returns the results. /// diff --git a/src/Numerics/LinearAlgebra/Single/DenseVector.cs b/src/Numerics/LinearAlgebra/Single/DenseVector.cs index b41493b1..8e877062 100644 --- a/src/Numerics/LinearAlgebra/Single/DenseVector.cs +++ b/src/Numerics/LinearAlgebra/Single/DenseVector.cs @@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Initializes a new instance of the class for an array. /// /// The array to create this vector from. - /// The vector does not copy the array, but keeps a reference to it. Any + /// The vector does not copy the array, but keeps a reference to it. Any /// changes to the vector will also change the array. public DenseVector(float[] array) : this(new DenseVectorStorage(array.Length, array)) @@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// - /// Returns a Vector containing the same values of . + /// Returns a Vector containing the same values of . /// /// This method is included for completeness. /// The vector to get the values from. @@ -333,9 +333,9 @@ namespace MathNet.Numerics.LinearAlgebra.Single Control.LinearAlgebraProvider.SubtractArrays(_values, otherDense._values, resultDense._values); } } - + /// - /// Returns a Vector containing the negated values of . + /// Returns a Vector containing the negated values of . /// /// The vector to get the values from. /// A vector containing the negated values as . @@ -530,7 +530,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the absolute minimum element. /// - /// The index of absolute minimum element. + /// The index of absolute minimum element. public override int AbsoluteMinimumIndex() { var index = 0; @@ -569,7 +569,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int AbsoluteMaximumIndex() { var index = 0; @@ -590,7 +590,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int MaximumIndex() { var index = 0; @@ -610,7 +610,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the minimum element. /// - /// The index of minimum element. + /// The index of minimum element. public override int MinimumIndex() { var index = 0; @@ -706,8 +706,8 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// First vector /// Second vector /// Matrix M[i,j] = u[i]*v[j] - /// If the u vector is . - /// If the v vector is . + /// If the u vector is . + /// If the v vector is . 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++) diff --git a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs index f94d23ec..63539a8b 100644 --- a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs +++ b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs @@ -33,7 +33,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single using Storage; /// - /// A matrix type for diagonal matrices. + /// A matrix type for diagonal matrices. /// /// /// Diagonal matrices can be non-square matrices but the diagonal always starts @@ -120,7 +120,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. /// When contains an off-diagonal element. @@ -276,7 +276,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// - /// Subtracts another matrix from this matrix. + /// Subtracts another matrix from this matrix. /// /// The matrix to subtract. /// The matrix to store the result of the subtraction. @@ -302,7 +302,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// The array to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of are copied to @@ -327,7 +327,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// The vector to copy the values from. The length of the vector should be /// Min(Rows, Columns). - /// If is . + /// If is . /// If the length of does not /// equal Min(Rows, Columns). /// For non-square matrices, the elements of are copied to @@ -354,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// The scalar to multiply the matrix with. /// The matrix to store the result of the multiplication. - /// If the result matrix is . + /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. protected override void DoMultiply(float scalar, Matrix result) { @@ -434,7 +434,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Multiplies this matrix with another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix Multiply(Matrix other) @@ -608,7 +608,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// Multiplies this matrix with transpose of another matrix and returns the result. /// /// The matrix to multiply with. - /// If this.Columns != other.Rows. + /// If this.Columns != other.Rows. /// If the other matrix is . /// The result of multiplication. public override Matrix TransposeAndMultiply(Matrix other) @@ -633,7 +633,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -650,7 +650,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// Calculates the L2 norm. - /// The L2 norm of the matrix. + /// The L2 norm of the matrix. 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 } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. public override float InfinityNorm() { return L1Norm(); @@ -716,7 +716,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { return Clone(); @@ -786,7 +786,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { return Clone(); @@ -858,10 +858,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// The requested sub-matrix. /// If: is /// negative, or greater than or equal to the number of rows. - /// is negative, or greater than or equal to the number + /// is negative, or greater than or equal to the number /// of columns. /// (columnIndex + columnLength) >= Columns - /// (rowIndex + rowLength) >= Rows + /// (rowIndex + rowLength) >= Rows /// If or /// is not positive. public override Matrix SubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount) diff --git a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs index 92179658..79e3a1cf 100644 --- a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs +++ b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs @@ -36,7 +36,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single using Properties; using Storage; using Threading; - + /// /// A Matrix class with sparse storage. The underlying storage scheme is 3-array compressed-sparse-row (CSR) Format. /// Wikipedia - CSR. @@ -77,7 +77,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single : this(new SparseCompressedRowMatrixStorage(rows, columns)) { } - + /// /// Initializes a new instance of the class. This matrix is square with a given size. /// @@ -134,7 +134,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// - /// Initializes a new instance of the class from a one dimensional array. + /// Initializes a new instance of the class from a one dimensional array. /// /// The number of rows. /// The number of columns. @@ -159,7 +159,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// - /// Initializes a new instance of the class from a 2D array. + /// Initializes a new instance of the class from a 2D array. /// /// The 2D array to create this matrix from. public SparseMatrix(float[,] array) @@ -215,7 +215,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns a new matrix containing the lower triangle of this matrix. /// - /// The lower triangle of this matrix. + /// The lower triangle of this matrix. public override Matrix LowerTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -282,7 +282,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns a new matrix containing the upper triangle of this matrix. /// - /// The upper triangle of this matrix. + /// The upper triangle of this matrix. public override Matrix UpperTriangle() { var result = CreateMatrix(RowCount, ColumnCount); @@ -484,7 +484,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the transpose of this matrix. - /// + /// /// The transpose of this matrix. public override Matrix Transpose() { @@ -555,7 +555,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// Calculates the infinity norm of this matrix. - /// The infinity norm of this matrix. + /// The infinity norm of this matrix. public override float InfinityNorm() { var rowPointers = _storage.RowPointers; @@ -747,7 +747,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } } } - + /// /// Multiplies each element of the matrix by a scalar and places results into the result matrix. /// @@ -1211,7 +1211,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single } /// - /// Returns a Matrix containing the same values of . + /// Returns a Matrix containing the same values of . /// /// The matrix to get the values from. /// A matrix containing a the same values as . diff --git a/src/Numerics/LinearAlgebra/Single/Vector.cs b/src/Numerics/LinearAlgebra/Single/Vector.cs index 330c43fb..14dab23c 100644 --- a/src/Numerics/LinearAlgebra/Single/Vector.cs +++ b/src/Numerics/LinearAlgebra/Single/Vector.cs @@ -42,7 +42,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single public abstract class Vector : Vector { /// - /// Initializes a new instance of the Vector class. + /// Initializes a new instance of the Vector class. /// protected Vector(VectorStorage storage) : base(storage) @@ -217,7 +217,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the absolute minimum element. /// - /// The index of absolute minimum element. + /// The index of absolute minimum element. public override int AbsoluteMinimumIndex() { var index = 0; @@ -247,7 +247,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int AbsoluteMaximumIndex() { var index = 0; @@ -357,7 +357,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the absolute maximum element. /// - /// The index of absolute maximum element. + /// The index of absolute maximum element. public override int MaximumIndex() { var index = 0; @@ -378,7 +378,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// /// Returns the index of the minimum element. /// - /// The index of minimum element. + /// The index of minimum element. public override int MinimumIndex() { var index = 0; diff --git a/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs b/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs index 79c5c528..229b95f1 100644 --- a/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs @@ -265,7 +265,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage /// Returns a hash code for this instance. /// /// - /// 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. /// 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) {