Browse Source

LA: drop pointless null-checks around operators; drop their tests

pull/163/head
Christoph Ruegg 13 years ago
parent
commit
261bac8e3e
  1. 276
      src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
  2. 90
      src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs
  3. 154
      src/Numerics/LinearAlgebra/Generic/Vector.Arithmetic.cs
  4. 85
      src/Numerics/LinearAlgebra/Generic/Vector.Operators.cs
  5. 12
      src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs
  6. 222
      src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs
  7. 12
      src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs
  8. 273
      src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs
  9. 12
      src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs
  10. 222
      src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs
  11. 12
      src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs
  12. 273
      src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs
  13. 12
      src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs
  14. 222
      src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs
  15. 12
      src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs
  16. 273
      src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs
  17. 12
      src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs
  18. 222
      src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs
  19. 12
      src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs
  20. 273
      src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs

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

@ -73,7 +73,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to add to this matrix.</param>
/// <param name="result">The matrix to store the result of the addition.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
protected abstract void DoAdd(Matrix<T> other, Matrix<T> result);
@ -198,7 +197,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to add.</param>
/// <returns>The result of the addition.</returns>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
public Matrix<T> Add(T scalar)
{
@ -217,15 +215,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to add.</param>
/// <param name="result">The matrix to store the result of the addition.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
public void Add(T scalar, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
@ -245,15 +237,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to add to this matrix.</param>
/// <returns>The result of the addition.</returns>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
public virtual Matrix<T> Add(Matrix<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other);
@ -269,20 +255,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to add to this matrix.</param>
/// <param name="result">The matrix to store the result of the addition.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
public void Add(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
@ -318,15 +293,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to subtract.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void Subtract(T scalar, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
@ -358,15 +327,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to subtract from.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void SubtractFrom(T scalar, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
@ -380,15 +343,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to subtract.</param>
/// <returns>The result of the subtraction.</returns>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
public virtual Matrix<T> Subtract(Matrix<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other);
@ -404,20 +361,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to subtract.</param>
/// <param name="result">The matrix to store the result of the subtraction.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">If the two matrices don't have the same dimensions.</exception>
public void Subtract(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
@ -458,15 +404,9 @@ 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="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
public void Multiply(T scalar, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "result");
@ -519,15 +459,9 @@ 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="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
public void Divide(T scalar, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "result");
@ -569,15 +503,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to divide.</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="ArgumentException">If the result matrix's dimensions are not the same as this matrix.</exception>
public void DivideByThis(T scalar, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "result");
@ -596,15 +524,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="rightSide">The vector to multiply with.</param>
/// <returns>The result of the multiplication.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If <c>this.ColumnCount != rightSide.Count</c>.</exception>
public Vector<T> Multiply(Vector<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
if (ColumnCount != rightSide.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
@ -620,27 +542,15 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="rightSide">The vector to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="result"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If <strong>result.Count != this.RowCount</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.ColumnCount != <paramref name="rightSide"/>.Count</strong>.</exception>
public virtual void Multiply(Vector<T> rightSide, Vector<T> result)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
if (ColumnCount != rightSide.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (RowCount != result.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
@ -663,15 +573,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="leftSide">The vector to multiply with.</param>
/// <returns>The result of the multiplication.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If <strong>this.RowCount != <paramref name="leftSide"/>.Count</strong>.</exception>
public Vector<T> LeftMultiply(Vector<T> leftSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
if (RowCount != leftSide.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, leftSide, "leftSide");
@ -687,27 +591,15 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="leftSide">The vector to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If <strong>result.Count != this.ColumnCount</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.RowCount != <paramref name="leftSide"/>.Count</strong>.</exception>
public virtual void LeftMultiply(Vector<T> leftSide, Vector<T> result)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
if (RowCount != leftSide.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, leftSide, "leftSide");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
@ -740,22 +632,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the 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 <strong>this.Columns != other.Rows</strong>.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the this.Rows x other.Columns.</exception>
public virtual void Multiply(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != other.RowCount || result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
@ -778,15 +658,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <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)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (ColumnCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other);
@ -802,22 +676,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the 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 <strong>this.Columns != other.ColumnCount</strong>.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the this.RowCount x other.RowCount.</exception>
public virtual void TransposeAndMultiply(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
{
if (ColumnCount != other.ColumnCount || result.RowCount != RowCount || result.ColumnCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
@ -840,15 +702,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <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)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (ColumnCount != other.ColumnCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other);
@ -864,15 +720,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="rightSide">The vector to multiply with.</param>
/// <returns>The result of the multiplication.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If <c>this.RowCount != rightSide.Count</c>.</exception>
public Vector<T> TransposeThisAndMultiply(Vector<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
if (RowCount != rightSide.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
@ -888,22 +738,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="rightSide">The vector to multiply with.</param>
/// <param name="result">The result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="result"/> is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If <strong>result.Count != this.ColumnCount</strong>.</exception>
/// <exception cref="ArgumentException">If <strong>this.RowCount != <paramref name="rightSide"/>.Count</strong>.</exception>
public void TransposeThisAndMultiply(Vector<T> rightSide, Vector<T> result)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (RowCount != rightSide.Count)
{
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
@ -931,22 +769,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <param name="result">The result of the 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 <strong>this.Rows != other.RowCount</strong>.</exception>
/// <exception cref="ArgumentException">If the result matrix's dimensions are not the this.ColumnCount x other.ColumnCount.</exception>
public void TransposeThisAndMultiply(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (RowCount != other.RowCount || result.RowCount != ColumnCount || result.ColumnCount != other.ColumnCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other, result);
@ -969,15 +795,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The matrix to multiply with.</param>
/// <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)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (RowCount != other.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, other);
@ -1003,15 +823,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Negate each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the negation.</param>
/// <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 Negate(Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
@ -1035,15 +849,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Complex conjugate each element of this matrix and place the results into the result matrix.
/// </summary>
/// <param name="result">The result of the conjugation.</param>
/// <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 Conjugate(Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
@ -1071,11 +879,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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);
@ -1103,11 +906,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <param name="result">Matrix to store the results in.</param>
public void ModulusByThis(T dividend, Matrix<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, result);
@ -1120,16 +918,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// 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");
@ -1145,22 +937,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </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);
@ -1173,16 +953,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Pointwise divide this matrix by another matrix.
/// </summary>
/// <param name="divisor">The pointwise denominator matrix to use.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="divisor"/> are not the same size.</exception>
/// <returns>A new matrix that is the pointwise division of this matrix and <paramref name="divisor"/>.</returns>
public Matrix<T> PointwiseDivide(Matrix<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (ColumnCount != divisor.ColumnCount || RowCount != divisor.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, divisor);
@ -1198,22 +972,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="divisor">The pointwise denominator matrix to use.</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="divisor"/> 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> divisor, Matrix<T> result)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != divisor.ColumnCount || RowCount != divisor.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, divisor, result);
@ -1226,16 +988,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// Pointwise modulus this matrix by another matrix.
/// </summary>
/// <param name="divisor">The pointwise denominator matrix to use.</param>
/// <exception cref="ArgumentNullException">If the other matrix is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="divisor"/> are not the same size.</exception>
/// <returns>A new matrix that is the pointwise modulus of this matrix and <paramref name="divisor"/>.</returns>
public Matrix<T> PointwiseModulus(Matrix<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (ColumnCount != divisor.ColumnCount || RowCount != divisor.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, divisor);
@ -1251,22 +1007,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="divisor">The pointwise denominator matrix to use.</param>
/// <param name="result">The matrix to store the result of the pointwise modulus.</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="divisor"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this matrix and <paramref name="result"/> are not the same size.</exception>
public void PointwiseModulus(Matrix<T> divisor, Matrix<T> result)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != divisor.ColumnCount || RowCount != divisor.RowCount)
{
throw DimensionsDontMatch<ArgumentException>(this, divisor, result);
@ -1328,15 +1072,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// with M = this.Rows * lower.Rows and N = this.Columns * lower.Columns.
/// </summary>
/// <param name="other">The other matrix.</param>
/// <exception cref="ArgumentNullException">If other is <see langword="null" />.</exception>
/// <returns>The kronecker product of the two matrices.</returns>
public virtual Matrix<T> KroneckerProduct(Matrix<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
var result = CreateMatrix(RowCount * other.RowCount, ColumnCount * other.ColumnCount);
KroneckerProduct(other, result);
return result;
@ -1348,21 +1086,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The other matrix.</param>
/// <param name="result">The kronecker product of the two matrices.</param>
/// <exception cref="ArgumentNullException">If other 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 (this.Rows * lower.rows) x (this.Columns * lower.Columns).</exception>
public virtual void KroneckerProduct(Matrix<T> other, Matrix<T> result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (result == null)
{
throw new ArgumentNullException("result");
}
if (result.RowCount != (RowCount * other.RowCount) || result.ColumnCount != (ColumnCount * other.ColumnCount))
{
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, result);

90
src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs

@ -46,11 +46,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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.Clone();
}
@ -62,11 +57,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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();
}
@ -83,11 +73,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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 (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Add(rightSide);
}
@ -102,11 +87,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator +(Matrix<T> leftSide, T rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Add(rightSide);
}
@ -121,11 +101,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator +(T leftSide, Matrix<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Add(leftSide);
}
@ -142,11 +117,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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 (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Subtract(rightSide);
}
@ -162,11 +132,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator -(Matrix<T> leftSide, T rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Subtract(rightSide);
}
@ -182,11 +147,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator -(T leftSide, Matrix<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.SubtractFrom(leftSide);
}
@ -199,11 +159,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator *(Matrix<T> leftSide, T rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Multiply(rightSide);
}
@ -216,11 +171,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Matrix<T> operator *(T leftSide, Matrix<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Multiply(leftSide);
}
@ -237,11 +187,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentException">If the dimensions of <paramref name="leftSide"/> or <paramref name="rightSide"/> don't conform.</exception>
public static Matrix<T> operator *(Matrix<T> leftSide, Matrix<T> rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Multiply(rightSide);
}
@ -254,11 +199,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator *(Matrix<T> leftSide, Vector<T> rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Multiply(rightSide);
}
@ -271,11 +211,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator *(Vector<T> leftSide, Matrix<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.LeftMultiply(leftSide);
}
@ -288,11 +223,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="divisor"/> is <see langword="null" />.</exception>
public static Matrix<T> operator /(T dividend, Matrix<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
return divisor.DivideByThis(dividend);
}
@ -305,11 +235,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Matrix<T> operator /(Matrix<T> dividend, T divisor)
{
if (dividend == null)
{
throw new ArgumentNullException("dividend");
}
return dividend.Divide(divisor);
}
@ -322,11 +247,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Matrix<T> operator %(Matrix<T> dividend, T divisor)
{
if (dividend == null)
{
throw new ArgumentNullException("dividend");
}
return dividend.Modulus(divisor);
}
@ -339,11 +259,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="divisor"/> is <see langword="null" />.</exception>
public static Matrix<T> operator %(T dividend, Matrix<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("dividend");
}
return divisor.ModulusByThis(dividend);
}
@ -357,11 +272,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Matrix<T> operator %(Matrix<T> dividend, Matrix<T> divisor)
{
if (dividend == null)
{
throw new ArgumentNullException("dividend");
}
return dividend.PointwiseModulus(divisor);
}

154
src/Numerics/LinearAlgebra/Generic/Vector.Arithmetic.cs

@ -171,15 +171,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to add.</param>
/// <param name="result">The vector to store the result of the addition.</param>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void Add(T scalar, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -199,15 +193,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The vector to add to this one.</param>
/// <returns>A new vector containing the sum of both vectors.</returns>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
public Vector<T> Add(Vector<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (Count != other.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other");
@ -223,17 +211,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The vector to add to this one.</param>
/// <param name="result">The vector to store the result of the addition.</param>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void Add(Vector<T> other, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -264,15 +245,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to subtract.</param>
/// <param name="result">The vector to store the result of the subtraction.</param>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void Subtract(T scalar, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -304,15 +279,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to subtract from.</param>
/// <param name="result">The vector to store the result of the subtraction.</param>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void SubtractFrom(T scalar, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -339,11 +308,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <param name="result">Target vector</param>
public void Negate(Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -357,15 +321,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The vector to subtract from this one.</param>
/// <returns>A new vector containing the subtraction of the the two vectors.</returns>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
public Vector<T> Subtract(Vector<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (Count != other.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other");
@ -381,17 +339,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The vector to subtract from this one.</param>
/// <param name="result">The vector to store the result of the subtraction.</param>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void Subtract(Vector<T> other, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -417,11 +368,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <param name="result">Target vector</param>
public void Conjugate(Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -457,15 +403,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to multiply.</param>
/// <param name="result">The vector to store the result of the multiplication.</param>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void Multiply(T scalar, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -492,14 +432,8 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <param name="other">The other vector to add.</param>
/// <returns>The result of the addition.</returns>
/// <exception cref="ArgumentException">If <paramref name="other"/> is not of the same size.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="other"/> is <see langword="null"/>.</exception>
public T DotProduct(Vector<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (Count != other.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other");
@ -530,15 +464,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to divide with.</param>
/// <param name="result">The vector to store the result of the division.</param>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void Divide(T scalar, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -570,15 +498,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="scalar">The scalar to divide.</param>
/// <param name="result">The vector to store the result of the division.</param>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void DivideByThis(T scalar, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -606,11 +528,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <param name="result">A vector to store the results in.</param>
public void Modulus(T divisor, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -638,11 +555,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <param name="result">A vector to store the results in.</param>
public void ModulusByThis(T dividend, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "result");
@ -656,15 +568,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The vector to pointwise multiply with this one.</param>
/// <returns>A new vector which is the pointwise multiplication of the two vectors.</returns>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
public Vector<T> PointwiseMultiply(Vector<T> other)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
if (Count != other.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other");
@ -680,22 +586,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="other">The vector to pointwise multiply with this one.</param>
/// <param name="result">The vector to store the result of the pointwise multiplication.</param>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="other"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwiseMultiply(Vector<T> other, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (other == null)
{
throw new ArgumentNullException("other");
}
if (Count != other.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "other");
@ -714,15 +608,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="divisor">The pointwise denominator vector to use.</param>
/// <returns>A new vector which is the pointwise division of the two vectors.</returns>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="divisor"/> are not the same size.</exception>
public Vector<T> PointwiseDivide(Vector<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (Count != divisor.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "divisor");
@ -738,22 +626,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="divisor">The pointwise denominator vector to use.</param>
/// <param name="result">The vector to store the result of the pointwise division.</param>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="divisor"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwiseDivide(Vector<T> divisor, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (Count != divisor.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "divisor");
@ -772,15 +648,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="divisor">The pointwise denominator vector to use.</param>
/// <returns>A new vector which is the pointwise modulus of the two vectors.</returns>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="divisor"/> are not the same size.</exception>
public Vector<T> PointwiseModulus(Vector<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (Count != divisor.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "divisor");
@ -796,22 +666,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// </summary>
/// <param name="divisor">The pointwise denominator vector to use.</param>
/// <param name="result">The vector to store the result of the pointwise modulus.</param>
/// <exception cref="ArgumentNullException">If the other vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentNullException">If the result vector is <see langword="null" />.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="divisor"/> are not the same size.</exception>
/// <exception cref="ArgumentException">If this vector and <paramref name="result"/> are not the same size.</exception>
public void PointwiseModulus(Vector<T> divisor, Vector<T> result)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
if (Count != divisor.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength, "divisor");
@ -831,20 +689,8 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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>
public static Matrix<T> OuterProduct(Vector<T> u, Vector<T> v)
{
if (u == null)
{
throw new ArgumentNullException("u");
}
if (v == null)
{
throw new ArgumentNullException("v");
}
var matrix = u.CreateMatrix(u.Count, v.Count);
for (var i = 0; i < u.Count; i++)

85
src/Numerics/LinearAlgebra/Generic/Vector.Operators.cs

@ -44,11 +44,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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.Clone();
}
@ -60,11 +55,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <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();
}
@ -78,11 +68,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator +(Vector<T> leftSide, Vector<T> rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Add(rightSide);
}
@ -95,11 +80,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator +(Vector<T> leftSide, T rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Add(rightSide);
}
@ -112,11 +92,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator +(T leftSide, Vector<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Add(leftSide);
}
@ -130,11 +105,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator -(Vector<T> leftSide, Vector<T> rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Subtract(rightSide);
}
@ -147,11 +117,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator -(Vector<T> leftSide, T rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Subtract(rightSide);
}
@ -164,11 +129,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator -(T leftSide, Vector<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.SubtractFrom(leftSide);
}
@ -181,11 +141,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator *(Vector<T> leftSide, T rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.Multiply(rightSide);
}
@ -198,11 +153,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static Vector<T> operator *(T leftSide, Vector<T> rightSide)
{
if (rightSide == null)
{
throw new ArgumentNullException("rightSide");
}
return rightSide.Multiply(leftSide);
}
@ -216,11 +166,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="leftSide"/> or <paramref name="rightSide"/> is <see langword="null" />.</exception>
public static T operator *(Vector<T> leftSide, Vector<T> rightSide)
{
if (leftSide == null)
{
throw new ArgumentNullException("leftSide");
}
return leftSide.DotProduct(rightSide);
}
@ -233,11 +178,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="divisor"/> is <see langword="null" />.</exception>
public static Vector<T> operator /(T dividend, Vector<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
return divisor.DevideByThis(dividend);
}
@ -250,11 +190,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Vector<T> operator /(Vector<T> dividend, T divisor)
{
if (dividend == null)
{
throw new ArgumentNullException("dividend");
}
return dividend.Divide(divisor);
}
@ -268,11 +203,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Vector<T> operator /(Vector<T> dividend, Vector<T> divisor)
{
if (dividend == null)
{
throw new ArgumentNullException("dividend");
}
return dividend.PointwiseDivide(divisor);
}
@ -285,11 +215,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Vector<T> operator %(Vector<T> dividend, T divisor)
{
if (dividend == null)
{
throw new ArgumentNullException("dividend");
}
return dividend.Modulus(divisor);
}
@ -302,11 +227,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Vector<T> operator %(T dividend, Vector<T> divisor)
{
if (divisor == null)
{
throw new ArgumentNullException("divisor");
}
return divisor.ModulusByThis(dividend);
}
@ -320,11 +240,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// <exception cref="ArgumentNullException">If <paramref name="dividend"/> is <see langword="null" />.</exception>
public static Vector<T> operator %(Vector<T> dividend, Vector<T> divisor)
{
if (dividend == null)
{
throw new ArgumentNullException("dividend");
}
return dividend.PointwiseModulus(divisor);
}

12
src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs

@ -320,17 +320,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
}
/// <summary>
/// Outer product for <c>null</c> dense vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullDenseVectorsThrowsArgumentNullException()
{
DenseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<Complex>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<Complex>.OuterProduct(vector2, vector1));
}
}
}

222
src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs

@ -122,18 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Multiply with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void MultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1) });
Vector<Complex> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(x, y));
}
/// <summary>
/// Multiply with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -213,17 +201,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Multiply with a scalar into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex> result = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(2.3, result));
}
/// <summary>
/// Multiply with a scalar when result has more rows throws <c>ArgumentException</c>.
/// </summary>
@ -246,26 +223,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3, result));
}
/// <summary>
/// Operator left multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<Complex> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = 2.3 * matrix; });
}
/// <summary>
/// Operator right multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<Complex> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * 2.3; });
}
/// <summary>
/// Can add a matrix.
/// </summary>
@ -289,17 +246,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Adding a matrix when argument is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Add(other));
}
/// <summary>
/// Adding a matrix with fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -344,28 +290,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Add operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<Complex> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -411,17 +335,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Subtract <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Subtract(other));
}
/// <summary>
/// Subtract a matrix when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -466,28 +379,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Subtract operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<Complex> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>
/// </summary>
@ -609,17 +500,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Transpose and multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Can transpose and multiply a matrix with matrix into a result matrix.
/// </summary>
@ -658,28 +538,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply <c>null</c> matrix with matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException()
{
Matrix<Complex> matrix = null;
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Can multiply a matrix with matrix into a result matrix.
/// </summary>
@ -770,18 +628,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Multiply transposed matrix with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1) });
Vector<Complex> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(x, y));
}
/// <summary>
/// Multiply transposed matrix with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -831,17 +677,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply the transpose of matrix with another matrix <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply transpose of this matrix with another matrix into a result matrix.
/// </summary>
@ -919,17 +754,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Negate into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void NegateIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex> copy = null;
Assert.Throws<ArgumentNullException>(() => matrix.Negate(copy));
}
/// <summary>
/// Negate into a result matrix with more rows throws <c>ArgumentException</c>.
/// </summary>
@ -1086,29 +910,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Pointwise multiply <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, result));
}
/// <summary>
/// Pointwise multiply matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, null));
}
/// <summary>
/// Pointwise multiply matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>
@ -1161,29 +962,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Pointwise divide <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, result));
}
/// <summary>
/// Pointwise divide matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, null));
}
/// <summary>
/// Pointwise divide matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>

12
src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs

@ -242,18 +242,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Outer product for <c>null</c> sparse vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullSparseVectorsThrowsArgumentNullException()
{
SparseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<Complex>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<Complex>.OuterProduct(vector2, vector1));
}
/// <summary>
/// Check sparse mechanism by setting values.
/// </summary>

273
src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs

@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex> vector = null;
Vector<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => other = +vector);
}
/// <summary>
/// Can call unary "+" operator.
/// </summary>
@ -99,16 +88,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
CollectionAssert.AreEqual(Data, result);
}
/// <summary>
/// Adding scalar to a vector when result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Add(0.0, null));
}
/// <summary>
/// Adding scalar to a vector using result vector with wrong size throws an exception.
/// </summary>
@ -120,16 +99,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => vector.Add(0.0, result));
}
/// <summary>
/// Adding two vectors when one is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Add(null));
}
/// <summary>
/// Adding two vectors of different size throws an exception.
/// </summary>
@ -141,17 +110,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => vector.Add(other));
}
/// <summary>
/// Adding two vectors when a result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Add(other, null));
}
/// <summary>
/// Adding two vectors when a result vector is different size throws an exception.
/// </summary>
@ -164,21 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => vector.Add(other, result));
}
/// <summary>
/// Addition operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<Complex> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a += b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a += b);
}
/// <summary>
/// Addition operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -306,17 +249,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Negate operator throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex> vector = null;
Vector<Complex> other = null;
Assert.Throws<ArgumentNullException>(() => other = -vector);
}
/// <summary>
/// Can call unary negation operator.
/// </summary>
@ -376,16 +308,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Subtracting a scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(0.0, null));
}
/// <summary>
/// Subtracting a scalar with wrong size result vector throws <c>ArgumentException</c>.
/// </summary>
@ -397,16 +319,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => vector.Subtract(0.0, result));
}
/// <summary>
/// Subtracting two vectors when one is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(null));
}
/// <summary>
/// Subtracting two vectors of differing size throws <c>ArgumentException</c>.
/// </summary>
@ -418,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => vector.Subtract(other));
}
/// <summary>
/// Subtracting two vectors when a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(other, null));
}
/// <summary>
/// Subtracting two vectors when a result vector is different size throws <c>ArgumentException</c>.
/// </summary>
@ -441,21 +342,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.Throws<ArgumentException>(() => vector.Subtract(other, result));
}
/// <summary>
/// Subtraction operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<Complex> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a -= b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a -= b);
}
/// <summary>
/// Subtraction operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -657,26 +543,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Multiplying by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Multiply(1.0, null));
}
/// <summary>
/// Dividing by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void DividingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Divide(1.0, null));
}
/// <summary>
/// Multiplying by scalar with wrong result vector size throws <c>ArgumentException</c>.
/// </summary>
@ -755,28 +621,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Operator multiply throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex> vector = null;
Vector<Complex> result = null;
Assert.Throws<ArgumentNullException>(() => result = vector * 2.0);
Assert.Throws<ArgumentNullException>(() => result = 2.0 * vector);
}
/// <summary>
/// Operator divide throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex> vector = null;
Assert.Throws<ArgumentNullException>(() => vector = vector / 2.0);
}
/// <summary>
/// Can calculate the dot product
/// </summary>
@ -789,18 +633,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.AreEqual(new Complex(50, 30), dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentNullException</c> when an argument is null
/// </summary>
[Test]
public void DotProductWhenArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<Complex> dataB = null;
Assert.Throws<ArgumentNullException>(() => dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentException</c> when an argument has different size
/// </summary>
@ -825,30 +657,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.AreEqual(new Complex(50, 30), dataA * dataB);
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the left argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<Complex> dataB = null;
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the right argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException()
{
Vector<Complex> dataA = null;
var dataB = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentException</c> when the argument has different size.
/// </summary>
@ -892,30 +700,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Pointwise multiply with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<Complex> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -959,30 +743,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Pointwise divide with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<Complex> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -1013,28 +773,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
/// <summary>
/// Outer product with <c>null</c> first parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenFirstIsNullThrowsArgumentNullException()
{
Vector<Complex> vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<Complex>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Outer product with <c>null</c> second parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenSecondIsNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex> vector2 = null;
Assert.Throws<ArgumentNullException>(() => Vector<Complex>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Can calculate the tensor multiply.
/// </summary>
@ -1052,16 +790,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
}
/// <summary>
/// Tensor multiply with <c>null</c> parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TensorMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex> vector2 = null;
Assert.Throws<ArgumentNullException>(() => vector1.OuterProduct(vector2));
}
}
}

12
src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs

@ -320,17 +320,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
}
/// <summary>
/// Outer product for <c>null</c> dense vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullDenseVectorsThrowsArgumentNullException()
{
DenseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<Complex32>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<Complex32>.OuterProduct(vector2, vector1));
}
}
}

222
src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs

@ -122,18 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Multiply with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void MultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1) });
Vector<Complex32> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(x, y));
}
/// <summary>
/// Multiply with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -213,17 +201,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Multiply with a scalar into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex32> result = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(2.3f, result));
}
/// <summary>
/// Multiply with a scalar when result has more rows throws <c>ArgumentException</c>.
/// </summary>
@ -246,26 +223,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3f, result));
}
/// <summary>
/// Operator left multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<Complex32> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = 2.3f * matrix; });
}
/// <summary>
/// Operator right multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<Complex32> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * 2.3f; });
}
/// <summary>
/// Can add a matrix.
/// </summary>
@ -289,17 +246,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Adding a matrix when argument is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Add(other));
}
/// <summary>
/// Adding a matrix with fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -344,28 +290,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Add operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<Complex32> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -411,17 +335,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Subtract <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Subtract(other));
}
/// <summary>
/// Subtract a matrix when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -466,28 +379,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Subtract operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<Complex32> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>
/// </summary>
@ -609,17 +500,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Transpose and multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Can transpose and multiply a matrix with matrix into a result matrix.
/// </summary>
@ -658,28 +538,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply <c>null</c> matrix with matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException()
{
Matrix<Complex32> matrix = null;
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Can multiply a matrix with matrix into a result matrix.
/// </summary>
@ -770,18 +628,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Multiply transposed matrix with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1) });
Vector<Complex32> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(x, y));
}
/// <summary>
/// Multiply transposed matrix with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -831,17 +677,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply the transpose of matrix with another matrix <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply transpose of this matrix with another matrix into a result matrix.
/// </summary>
@ -919,17 +754,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Negate into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void NegateIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<Complex32> copy = null;
Assert.Throws<ArgumentNullException>(() => matrix.Negate(copy));
}
/// <summary>
/// Negate into a result matrix with more rows throws <c>ArgumentException</c>.
/// </summary>
@ -1082,29 +906,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Pointwise multiply <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex32> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, result));
}
/// <summary>
/// Pointwise multiply matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, null));
}
/// <summary>
/// Pointwise multiply matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>
@ -1157,29 +958,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Pointwise divide <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<Complex32> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, result));
}
/// <summary>
/// Pointwise divide matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, null));
}
/// <summary>
/// Pointwise divide matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>

12
src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs

@ -242,18 +242,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Outer product for <c>null</c> sparse vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullSparseVectorsThrowsArgumentNullException()
{
SparseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<Complex32>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<Complex32>.OuterProduct(vector2, vector1));
}
/// <summary>
/// Check sparse mechanism by setting values.
/// </summary>

273
src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs

@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex32> vector = null;
Vector<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => other = +vector);
}
/// <summary>
/// Can call unary "+" operator.
/// </summary>
@ -99,16 +88,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
CollectionAssert.AreEqual(Data, result);
}
/// <summary>
/// Adding scalar to a vector when result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Add(0.0f, null));
}
/// <summary>
/// Adding scalar to a vector using result vector with wrong size throws an exception.
/// </summary>
@ -120,16 +99,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => vector.Add(0.0f, result));
}
/// <summary>
/// Adding two vectors when one is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Add(null));
}
/// <summary>
/// Adding two vectors of different size throws an exception.
/// </summary>
@ -141,17 +110,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => vector.Add(other));
}
/// <summary>
/// Adding two vectors when a result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Add(other, null));
}
/// <summary>
/// Adding two vectors when a result vector is different size throws an exception.
/// </summary>
@ -164,21 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => vector.Add(other, result));
}
/// <summary>
/// Addition operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<Complex32> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a += b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a += b);
}
/// <summary>
/// Addition operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -306,17 +249,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Negate operator throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex32> vector = null;
Vector<Complex32> other = null;
Assert.Throws<ArgumentNullException>(() => other = -vector);
}
/// <summary>
/// Can call unary negation operator.
/// </summary>
@ -376,16 +308,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Subtracting a scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(0.0f, null));
}
/// <summary>
/// Subtracting a scalar with wrong size result vector throws <c>ArgumentException</c>.
/// </summary>
@ -397,16 +319,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => vector.Subtract(0.0f, result));
}
/// <summary>
/// Subtracting two vectors when one is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(null));
}
/// <summary>
/// Subtracting two vectors of differing size throws <c>ArgumentException</c>.
/// </summary>
@ -418,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => vector.Subtract(other));
}
/// <summary>
/// Subtracting two vectors when a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(other, null));
}
/// <summary>
/// Subtracting two vectors when a result vector is different size throws <c>ArgumentException</c>.
/// </summary>
@ -441,21 +342,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.Throws<ArgumentException>(() => vector.Subtract(other, result));
}
/// <summary>
/// Subtraction operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<Complex32> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a -= b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a -= b);
}
/// <summary>
/// Subtraction operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -657,26 +543,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Multiplying by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Multiply(1.0f, null));
}
/// <summary>
/// Dividing by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void DividingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Divide(1.0f, null));
}
/// <summary>
/// Multiplying by scalar with wrong result vector size throws <c>ArgumentException</c>.
/// </summary>
@ -755,28 +621,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Operator multiply throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex32> vector = null;
Vector<Complex32> result = null;
Assert.Throws<ArgumentNullException>(() => result = vector * 2.0f);
Assert.Throws<ArgumentNullException>(() => result = 2.0f * vector);
}
/// <summary>
/// Operator divide throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException()
{
Vector<Complex32> vector = null;
Assert.Throws<ArgumentNullException>(() => vector = vector / 2.0f);
}
/// <summary>
/// Can calculate the dot product
/// </summary>
@ -789,18 +633,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.AreEqual(new Complex32(50, 30), dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentNullException</c> when an argument is null
/// </summary>
[Test]
public void DotProductWhenArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<Complex32> dataB = null;
Assert.Throws<ArgumentNullException>(() => dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentException</c> when an argument has different size
/// </summary>
@ -825,30 +657,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.AreEqual(new Complex32(50, 30), dataA * dataB);
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the left argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<Complex32> dataB = null;
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the right argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException()
{
Vector<Complex32> dataA = null;
var dataB = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentException</c> when the argument has different size.
/// </summary>
@ -892,30 +700,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Pointwise multiply with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex32> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<Complex32> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -959,30 +743,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Pointwise divide with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex32> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<Complex32> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -1013,28 +773,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
/// <summary>
/// Outer product with <c>null</c> first parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenFirstIsNullThrowsArgumentNullException()
{
Vector<Complex32> vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<Complex32>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Outer product with <c>null</c> second parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenSecondIsNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex32> vector2 = null;
Assert.Throws<ArgumentNullException>(() => Vector<Complex32>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Can calculate the tensor multiply.
/// </summary>
@ -1052,16 +790,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
}
/// <summary>
/// Tensor multiply with <c>null</c> parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TensorMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<Complex32> vector2 = null;
Assert.Throws<ArgumentNullException>(() => vector1.OuterProduct(vector2));
}
}
}

12
src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs

@ -319,17 +319,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
}
/// <summary>
/// Outer product for <c>null</c> dense vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullDenseVectorsThrowsArgumentNullException()
{
DenseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<double>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<double>.OuterProduct(vector2, vector1));
}
}
}

222
src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs

@ -120,18 +120,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Multiply with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void MultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { 1.0, 2.0, 3.0 });
Vector<double> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(x, y));
}
/// <summary>
/// Multiply with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -208,17 +196,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Multiply with a scalar into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<double> result = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(2.3, result));
}
/// <summary>
/// Multiply with a scalar when result has more rows throws <c>ArgumentException</c>.
/// </summary>
@ -241,26 +218,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3, result));
}
/// <summary>
/// Operator left multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<double> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = 2.3 * matrix; });
}
/// <summary>
/// Operator right multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<double> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * 2.3; });
}
/// <summary>
/// Can add a matrix.
/// </summary>
@ -284,17 +241,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Adding a matrix when argument is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<double> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Add(other));
}
/// <summary>
/// Adding a matrix with fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -339,28 +285,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Add operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<double> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<double> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -406,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Subtract <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<double> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Subtract(other));
}
/// <summary>
/// Subtract a matrix when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -461,28 +374,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Subtract operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<double> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<double> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>
/// </summary>
@ -604,17 +495,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Transpose and multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<double> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Can transpose and multiply a matrix with matrix into a result matrix.
/// </summary>
@ -653,28 +533,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply <c>null</c> matrix with matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException()
{
Matrix<double> matrix = null;
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<double> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Can multiply a matrix with matrix into a result matrix.
/// </summary>
@ -765,18 +623,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Multiply transposed matrix with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { 1.0, 2.0, 3.0 });
Vector<double> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(x, y));
}
/// <summary>
/// Multiply transposed matrix with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -826,17 +672,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply the transpose of matrix with another matrix <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<double> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply transpose of this matrix with another matrix into a result matrix.
/// </summary>
@ -914,17 +749,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Negate into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void NegateIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<double> copy = null;
Assert.Throws<ArgumentNullException>(() => matrix.Negate(copy));
}
/// <summary>
/// Negate into a result matrix with more rows throws <c>ArgumentException</c>.
/// </summary>
@ -1077,29 +901,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Pointwise multiply <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<double> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, result));
}
/// <summary>
/// Pointwise multiply matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, null));
}
/// <summary>
/// Pointwise multiply matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>
@ -1152,29 +953,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Pointwise divide <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<double> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, result));
}
/// <summary>
/// Pointwise divide matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, null));
}
/// <summary>
/// Pointwise divide matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>

12
src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs

@ -241,18 +241,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Outer product for <c>null</c> sparse vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullSparseVectorsThrowsArgumentNullException()
{
SparseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<double>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<double>.OuterProduct(vector2, vector1));
}
/// <summary>
/// Check sparse mechanism by setting values.
/// </summary>

273
src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs

@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException()
{
Vector<double> vector = null;
Vector<double> other = null;
Assert.Throws<ArgumentNullException>(() => other = +vector);
}
/// <summary>
/// Can call unary "+" operator.
/// </summary>
@ -98,16 +87,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
CollectionAssert.AreEqual(Data, result);
}
/// <summary>
/// Adding scalar to a vector when result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Add(0.0, null));
}
/// <summary>
/// Adding scalar to a vector using result vector with wrong size throws an exception.
/// </summary>
@ -119,16 +98,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => vector.Add(0.0, result));
}
/// <summary>
/// Adding two vectors when one is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Add(null));
}
/// <summary>
/// Adding two vectors of different size throws an exception.
/// </summary>
@ -140,17 +109,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => vector.Add(other));
}
/// <summary>
/// Adding two vectors when a result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Add(other, null));
}
/// <summary>
/// Adding two vectors when a result vector is different size throws an exception.
/// </summary>
@ -163,21 +121,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => vector.Add(other, result));
}
/// <summary>
/// Addition operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<double> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a += b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a += b);
}
/// <summary>
/// Addition operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -305,17 +248,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Negate operator throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException()
{
Vector<double> vector = null;
Vector<double> other = null;
Assert.Throws<ArgumentNullException>(() => other = -vector);
}
/// <summary>
/// Can call unary negation operator.
/// </summary>
@ -375,16 +307,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Subtracting a scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(0.0, null));
}
/// <summary>
/// Subtracting a scalar with wrong size result vector throws <c>ArgumentException</c>.
/// </summary>
@ -396,16 +318,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => vector.Subtract(0.0, result));
}
/// <summary>
/// Subtracting two vectors when one is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(null));
}
/// <summary>
/// Subtracting two vectors of differing size throws <c>ArgumentException</c>.
/// </summary>
@ -417,17 +329,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => vector.Subtract(other));
}
/// <summary>
/// Subtracting two vectors when a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(other, null));
}
/// <summary>
/// Subtracting two vectors when a result vector is different size throws <c>ArgumentException</c>.
/// </summary>
@ -440,21 +341,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.Throws<ArgumentException>(() => vector.Subtract(other, result));
}
/// <summary>
/// Subtraction operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<double> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a -= b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a -= b);
}
/// <summary>
/// Subtraction operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -656,26 +542,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Multiplying by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Multiply(1.0, null));
}
/// <summary>
/// Dividing by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void DividingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Divide(1.0, null));
}
/// <summary>
/// Multiplying by scalar with wrong result vector size throws <c>ArgumentException</c>.
/// </summary>
@ -754,28 +620,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Operator multiply throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException()
{
Vector<double> vector = null;
Vector<double> result = null;
Assert.Throws<ArgumentNullException>(() => result = vector * 2.0);
Assert.Throws<ArgumentNullException>(() => result = 2.0 * vector);
}
/// <summary>
/// Operator divide throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException()
{
Vector<double> vector = null;
Assert.Throws<ArgumentNullException>(() => vector = vector / 2.0);
}
/// <summary>
/// Can calculate the dot product
/// </summary>
@ -788,18 +632,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.AreEqual(55.0, dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentNullException</c> when an argument is null
/// </summary>
[Test]
public void DotProductWhenArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<double> dataB = null;
Assert.Throws<ArgumentNullException>(() => dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentException</c> when an argument has different size
/// </summary>
@ -824,30 +656,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.AreEqual(55.0, dataA * dataB);
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the left argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<double> dataB = null;
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the right argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException()
{
Vector<double> dataA = null;
var dataB = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentException</c> when the argument has different size.
/// </summary>
@ -891,30 +699,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Pointwise multiply with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<double> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<double> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -958,30 +742,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Pointwise divide with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<double> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<double> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -1012,28 +772,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Outer product with <c>null</c> first parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenFirstIsNullThrowsArgumentNullException()
{
Vector<double> vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<double>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Outer product with <c>null</c> second parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenSecondIsNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<double> vector2 = null;
Assert.Throws<ArgumentNullException>(() => Vector<double>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Can calculate the tensor multiply.
/// </summary>
@ -1052,17 +790,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
/// <summary>
/// Tensor multiply with <c>null</c> parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TensorMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<double> vector2 = null;
Assert.Throws<ArgumentNullException>(() => vector1.OuterProduct(vector2));
}
/// <summary>
/// Can compute the modules of each element of vector.
/// </summary>

12
src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs

@ -319,17 +319,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
}
/// <summary>
/// Outer product for <c>null</c> dense vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullDenseVectorsThrowsArgumentNullException()
{
DenseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<float>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<float>.OuterProduct(vector2, vector1));
}
}
}

222
src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs

@ -120,18 +120,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Multiply with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void MultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { 1.0f, 2.0f, 3.0f });
Vector<float> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(x, y));
}
/// <summary>
/// Multiply with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -208,17 +196,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Multiply with a scalar into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<float> result = null;
Assert.Throws<ArgumentNullException>(() => matrix.Multiply(2.3f, result));
}
/// <summary>
/// Multiply with a scalar when result has more rows throws <c>ArgumentException</c>.
/// </summary>
@ -241,26 +218,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => matrix.Multiply(2.3f, result));
}
/// <summary>
/// Operator left multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<float> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = 2.3f * matrix; });
}
/// <summary>
/// Operator right multiply with a scalar when matrix is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException()
{
Matrix<float> matrix = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * 2.3f; });
}
/// <summary>
/// Can add a matrix.
/// </summary>
@ -284,17 +241,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Adding a matrix when argument is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<float> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Add(other));
}
/// <summary>
/// Adding a matrix with fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -339,28 +285,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Add operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<float> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<float> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix + other; });
}
/// <summary>
/// Add operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -406,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Subtract <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular4x4"];
Matrix<float> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.Subtract(other));
}
/// <summary>
/// Subtract a matrix when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>.
/// </summary>
@ -461,28 +374,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Subtract operator when left side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException()
{
Matrix<float> matrix = null;
var other = TestMatrices["Singular3x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<float> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix - other; });
}
/// <summary>
/// Subtract operator when right side has fewer columns throws <c>ArgumentOutOfRangeException</c>
/// </summary>
@ -604,17 +495,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Transpose and multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<float> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeAndMultiply(other));
}
/// <summary>
/// Can transpose and multiply a matrix with matrix into a result matrix.
/// </summary>
@ -653,28 +533,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply <c>null</c> matrix with matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException()
{
Matrix<float> matrix = null;
var other = TestMatrices["Wide2x3"];
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Multiply a matrix with <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<float> other = null;
Assert.Throws<ArgumentNullException>(() => { var result = matrix * other; });
}
/// <summary>
/// Can multiply a matrix with matrix into a result matrix.
/// </summary>
@ -759,18 +617,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Multiply transposed matrix with vector into result fails when result is <c>null</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyWithVectorIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
var x = new DenseVector(new[] { 1.0f, 2.0f, 3.0f });
Vector<float> y = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(x, y));
}
/// <summary>
/// Multiply transposed matrix with a vector into too large result throws <c>ArgumentException</c>.
/// </summary>
@ -820,17 +666,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply the transpose of matrix with another matrix <c>null</c> matrix throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<float> other = null;
Assert.Throws<ArgumentNullException>(() => matrix.TransposeThisAndMultiply(other));
}
/// <summary>
/// Multiply transpose of this matrix with another matrix into a result matrix.
/// </summary>
@ -908,17 +743,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Negate into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void NegateIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Singular3x3"];
Matrix<float> copy = null;
Assert.Throws<ArgumentNullException>(() => matrix.Negate(copy));
}
/// <summary>
/// Negate into a result matrix with more rows throws <c>ArgumentException</c>.
/// </summary>
@ -1071,29 +895,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Pointwise multiply <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<float> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, result));
}
/// <summary>
/// Pointwise multiply matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseMultiply(other, null));
}
/// <summary>
/// Pointwise multiply matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>
@ -1146,29 +947,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Pointwise divide <c>null</c> matrices into a result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideNullIntoResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
Matrix<float> other = null;
var result = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, result));
}
/// <summary>
/// Pointwise divide matrices into <c>null</c> result throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideIntoNullResultThrowsArgumentNullException()
{
var matrix = TestMatrices["Wide2x3"];
var other = matrix.Clone();
Assert.Throws<ArgumentNullException>(() => matrix.PointwiseDivide(other, null));
}
/// <summary>
/// Pointwise divide matrices with invalid dimensions into a result throws <c>ArgumentException</c>.
/// </summary>

12
src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs

@ -242,18 +242,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Outer product for <c>null</c> sparse vectors throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductForNullSparseVectorsThrowsArgumentNullException()
{
SparseVector vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<float>.OuterProduct(vector1, vector2));
Assert.Throws<ArgumentNullException>(() => Vector<float>.OuterProduct(vector2, vector1));
}
/// <summary>
/// Check sparse mechanism by setting values.
/// </summary>

273
src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs

@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
public abstract partial class VectorTests
{
/// <summary>
/// Operator "+" throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException()
{
Vector<float> vector = null;
Vector<float> other = null;
Assert.Throws<ArgumentNullException>(() => other = +vector);
}
/// <summary>
/// Can call unary "+" operator.
/// </summary>
@ -98,16 +87,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
CollectionAssert.AreEqual(Data, result);
}
/// <summary>
/// Adding scalar to a vector when result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Add(0.0f, null));
}
/// <summary>
/// Adding scalar to a vector using result vector with wrong size throws an exception.
/// </summary>
@ -119,16 +98,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => vector.Add(0.0f, result));
}
/// <summary>
/// Adding two vectors when one is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Add(null));
}
/// <summary>
/// Adding two vectors of different size throws an exception.
/// </summary>
@ -140,17 +109,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => vector.Add(other));
}
/// <summary>
/// Adding two vectors when a result vector is <c>null</c> throws an exception.
/// </summary>
[Test]
public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Add(other, null));
}
/// <summary>
/// Adding two vectors when a result vector is different size throws an exception.
/// </summary>
@ -163,21 +121,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => vector.Add(other, result));
}
/// <summary>
/// Addition operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<float> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a += b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a += b);
}
/// <summary>
/// Addition operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -305,17 +248,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Negate operator throws <c>ArgumentNullException</c> when call on <c>null</c> vector.
/// </summary>
[Test]
public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException()
{
Vector<float> vector = null;
Vector<float> other = null;
Assert.Throws<ArgumentNullException>(() => other = -vector);
}
/// <summary>
/// Can call unary negation operator.
/// </summary>
@ -375,16 +307,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Subtracting a scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(0.0f, null));
}
/// <summary>
/// Subtracting a scalar with wrong size result vector throws <c>ArgumentException</c>.
/// </summary>
@ -396,16 +318,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => vector.Subtract(0.0f, result));
}
/// <summary>
/// Subtracting two vectors when one is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(null));
}
/// <summary>
/// Subtracting two vectors of differing size throws <c>ArgumentException</c>.
/// </summary>
@ -417,17 +329,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => vector.Subtract(other));
}
/// <summary>
/// Subtracting two vectors when a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
var other = CreateVector(Data.Length + 1);
Assert.Throws<ArgumentNullException>(() => vector.Subtract(other, null));
}
/// <summary>
/// Subtracting two vectors when a result vector is different size throws <c>ArgumentException</c>.
/// </summary>
@ -440,21 +341,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.Throws<ArgumentException>(() => vector.Subtract(other, result));
}
/// <summary>
/// Subtraction operator throws <c>ArgumentNullException</c> if a vector is <c>null</c>.
/// </summary>
[Test]
public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException()
{
Vector<float> a = null;
var b = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => a -= b);
a = b;
b = null;
Assert.Throws<ArgumentNullException>(() => a -= b);
}
/// <summary>
/// Subtraction operator throws <c>ArgumentException</c> if vectors are different size.
/// </summary>
@ -656,26 +542,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Multiplying by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Multiply(1.0f, null));
}
/// <summary>
/// Dividing by scalar with <c>null</c> result vector throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void DividingScalarWithNullResultVectorThrowsArgumentNullException()
{
var vector = CreateVector(Data.Length);
Assert.Throws<ArgumentNullException>(() => vector.Divide(1.0f, null));
}
/// <summary>
/// Multiplying by scalar with wrong result vector size throws <c>ArgumentException</c>.
/// </summary>
@ -754,28 +620,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Operator multiply throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException()
{
Vector<float> vector = null;
Vector<float> result = null;
Assert.Throws<ArgumentNullException>(() => result = vector * 2.0f);
Assert.Throws<ArgumentNullException>(() => result = 2.0f * vector);
}
/// <summary>
/// Operator divide throws <c>ArgumentNullException</c> when a vector is <c>null</c>.
/// </summary>
[Test]
public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException()
{
Vector<float> vector = null;
Assert.Throws<ArgumentNullException>(() => vector = vector / 2.0f);
}
/// <summary>
/// Can calculate the dot product
/// </summary>
@ -788,18 +632,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.AreEqual(55.0f, dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentNullException</c> when an argument is <c>null</c>.
/// </summary>
[Test]
public void DotProductWhenArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<float> dataB = null;
Assert.Throws<ArgumentNullException>(() => dataA.DotProduct(dataB));
}
/// <summary>
/// Dot product throws <c>ArgumentException</c> when an argument has different size
/// </summary>
@ -824,30 +656,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.AreEqual(55.0f, dataA * dataB);
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the left argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException()
{
var dataA = CreateVector(Data);
Vector<float> dataB = null;
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentNullException</c> when the right argument is <c>null</c>.
/// </summary>
[Test]
public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException()
{
Vector<float> dataA = null;
var dataB = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => { var d = dataA * dataB; });
}
/// <summary>
/// Operator "*" throws <c>ArgumentException</c> when the argument has different size.
/// </summary>
@ -891,30 +699,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Pointwise multiply with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<float> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseMultiplyWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<float> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseMultiply(vector2, result));
}
/// <summary>
/// Pointwise multiply with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -958,30 +742,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Pointwise divide with <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<float> vector2 = null;
var result = CreateVector(vector1.Count);
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector is <c>null</c> throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void PointwiseDivideWithResultNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
var vector2 = vector1.Clone();
Vector<float> result = null;
Assert.Throws<ArgumentNullException>(() => vector1.PointwiseDivide(vector2, result));
}
/// <summary>
/// Pointwise divide with a result vector wrong size throws <c>ArgumentException</c>.
/// </summary>
@ -1012,28 +772,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Outer product with <c>null</c> first parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenFirstIsNullThrowsArgumentNullException()
{
Vector<float> vector1 = null;
var vector2 = CreateVector(Data);
Assert.Throws<ArgumentNullException>(() => Vector<float>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Outer product with <c>null</c> second parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void OuterProductWhenSecondIsNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<float> vector2 = null;
Assert.Throws<ArgumentNullException>(() => Vector<float>.OuterProduct(vector1, vector2));
}
/// <summary>
/// Can calculate the tensor multiply.
/// </summary>
@ -1052,17 +790,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
/// <summary>
/// Tensor multiply with <c>null</c> parameter throws <c>ArgumentNullException</c>.
/// </summary>
[Test]
public void TensorMultiplyWithNullThrowsArgumentNullException()
{
var vector1 = CreateVector(Data);
Vector<float> vector2 = null;
Assert.Throws<ArgumentNullException>(() => vector1.OuterProduct(vector2));
}
/// <summary>
/// Can compute the modules of each element of vector.
/// </summary>

Loading…
Cancel
Save