diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs index 48734d47..d93b8ec9 100644 --- a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs +++ b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs @@ -73,7 +73,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to add to this matrix. /// The matrix to store the result of the addition. - /// If the other matrix is . /// If the two matrices don't have the same dimensions. protected abstract void DoAdd(Matrix other, Matrix result); @@ -198,7 +197,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The scalar to add. /// The result of the addition. - /// If the other matrix is . /// If the two matrices don't have the same dimensions. public Matrix Add(T scalar) { @@ -217,15 +215,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The scalar to add. /// The matrix to store the result of the addition. - /// If the other matrix is . /// If the two matrices don't have the same dimensions. public void Add(T scalar, Matrix result) { - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (result.RowCount != RowCount || result.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, result, "result"); @@ -245,15 +237,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to add to this matrix. /// The result of the addition. - /// If the other matrix is . /// If the two matrices don't have the same dimensions. public virtual Matrix Add(Matrix other) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - if (other.RowCount != RowCount || other.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, other); @@ -269,20 +255,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to add to this matrix. /// The matrix to store the result of the addition. - /// If the other matrix is . /// If the two matrices don't have the same dimensions. public void Add(Matrix other, Matrix result) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (other.RowCount != RowCount || other.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, other, "other"); @@ -318,15 +293,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The scalar to subtract. /// The matrix to store the result of the subtraction. - /// If the result matrix is . /// If this matrix and are not the same size. public void Subtract(T scalar, Matrix result) { - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (result.RowCount != RowCount || result.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, result, "result"); @@ -358,15 +327,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The scalar to subtract from. /// The matrix to store the result of the subtraction. - /// If the result matrix is . /// If this matrix and are not the same size. public void SubtractFrom(T scalar, Matrix result) { - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (result.RowCount != RowCount || result.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, result, "result"); @@ -380,15 +343,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to subtract. /// The result of the subtraction. - /// If the other matrix is . /// If the two matrices don't have the same dimensions. public virtual Matrix Subtract(Matrix other) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - if (other.RowCount != RowCount || other.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, other); @@ -404,20 +361,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to subtract. /// The matrix to store the result of the subtraction. - /// If the other matrix is . /// If the two matrices don't have the same dimensions. public void Subtract(Matrix other, Matrix result) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (other.RowCount != RowCount || other.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, other, "other"); @@ -458,15 +404,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The scalar to multiply the matrix with. /// The matrix to store the result of the multiplication. - /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. public void Multiply(T scalar, Matrix 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 /// /// The scalar to divide the matrix with. /// The matrix to store the result of the division. - /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. public void Divide(T scalar, Matrix 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 /// /// The scalar to divide. /// The matrix to store the result of the division. - /// If the result matrix is . /// If the result matrix's dimensions are not the same as this matrix. public void DivideByThis(T scalar, Matrix 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 /// /// The vector to multiply with. /// The result of the multiplication. - /// If is . /// If this.ColumnCount != rightSide.Count. public Vector Multiply(Vector rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - if (ColumnCount != rightSide.Count) { throw DimensionsDontMatch(this, rightSide, "rightSide"); @@ -620,27 +542,15 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The vector to multiply with. /// The result of the multiplication. - /// If is . - /// If is . /// If result.Count != this.RowCount. /// If this.ColumnCount != .Count. public virtual void Multiply(Vector rightSide, Vector result) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - if (ColumnCount != rightSide.Count) { throw DimensionsDontMatch(this, rightSide, "rightSide"); } - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (RowCount != result.Count) { throw DimensionsDontMatch(this, result, "result"); @@ -663,15 +573,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The vector to multiply with. /// The result of the multiplication. - /// If is . /// If this.RowCount != .Count. public Vector LeftMultiply(Vector leftSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - if (RowCount != leftSide.Count) { throw DimensionsDontMatch(this, leftSide, "leftSide"); @@ -687,27 +591,15 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The vector to multiply with. /// The result of the multiplication. - /// If is . - /// If the result matrix is . /// If result.Count != this.ColumnCount. /// If this.RowCount != .Count. public virtual void LeftMultiply(Vector leftSide, Vector result) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - if (RowCount != leftSide.Count) { throw DimensionsDontMatch(this, leftSide, "leftSide"); } - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (ColumnCount != result.Count) { throw DimensionsDontMatch(this, result, "result"); @@ -740,22 +632,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to multiply with. /// The result of the multiplication. - /// If the other matrix is . - /// If the result matrix is . /// If this.Columns != other.Rows. /// If the result matrix's dimensions are not the this.Rows x other.Columns. public virtual void Multiply(Matrix other, Matrix 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(this, other, result); @@ -778,15 +658,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to multiply with. /// If this.Columns != other.Rows. - /// If the other matrix is . /// The result of the multiplication. public virtual Matrix Multiply(Matrix other) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - if (ColumnCount != other.RowCount) { throw DimensionsDontMatch(this, other); @@ -802,22 +676,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to multiply with. /// The result of the multiplication. - /// If the other matrix is . - /// If the result matrix is . /// If this.Columns != other.ColumnCount. /// If the result matrix's dimensions are not the this.RowCount x other.RowCount. public virtual void TransposeAndMultiply(Matrix other, Matrix 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(this, other, result); @@ -840,15 +702,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to multiply with. /// If this.Columns != other.ColumnCount. - /// If the other matrix is . /// The result of the multiplication. public virtual Matrix TransposeAndMultiply(Matrix other) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - if (ColumnCount != other.ColumnCount) { throw DimensionsDontMatch(this, other); @@ -864,15 +720,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The vector to multiply with. /// The result of the multiplication. - /// If is . /// If this.RowCount != rightSide.Count. public Vector TransposeThisAndMultiply(Vector rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - if (RowCount != rightSide.Count) { throw DimensionsDontMatch(this, rightSide, "rightSide"); @@ -888,22 +738,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The vector to multiply with. /// The result of the multiplication. - /// If is . - /// If is . /// If result.Count != this.ColumnCount. /// If this.RowCount != .Count. public void TransposeThisAndMultiply(Vector rightSide, Vector result) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (RowCount != rightSide.Count) { throw DimensionsDontMatch(this, rightSide, "rightSide"); @@ -931,22 +769,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to multiply with. /// The result of the multiplication. - /// If the other matrix is . - /// If the result matrix is . /// If this.Rows != other.RowCount. /// If the result matrix's dimensions are not the this.ColumnCount x other.ColumnCount. public void TransposeThisAndMultiply(Matrix other, Matrix 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(this, other, result); @@ -969,15 +795,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to multiply with. /// If this.Rows != other.RowCount. - /// If the other matrix is . /// The result of the multiplication. public Matrix TransposeThisAndMultiply(Matrix other) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - if (RowCount != other.RowCount) { throw DimensionsDontMatch(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. /// /// The result of the negation. - /// If the result matrix is . /// if the result matrix's dimensions are not the same as this matrix. public void Negate(Matrix result) { - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (result.RowCount != RowCount || result.ColumnCount != ColumnCount) { throw DimensionsDontMatch(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. /// /// The result of the conjugation. - /// If the result matrix is . /// if the result matrix's dimensions are not the same as this matrix. public void Conjugate(Matrix result) { - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (result.RowCount != RowCount || result.ColumnCount != ColumnCount) { throw DimensionsDontMatch(this, result); @@ -1071,11 +879,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Matrix to store the results in. public void Modulus(T divisor, Matrix result) { - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (ColumnCount != result.ColumnCount || RowCount != result.RowCount) { throw DimensionsDontMatch(this, result); @@ -1103,11 +906,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Matrix to store the results in. public void ModulusByThis(T dividend, Matrix result) { - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (ColumnCount != result.ColumnCount || RowCount != result.RowCount) { throw DimensionsDontMatch(this, result); @@ -1120,16 +918,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Pointwise multiplies this matrix with another matrix. /// /// The matrix to pointwise multiply with this one. - /// If the other matrix is . /// If this matrix and are not the same size. /// A new matrix that is the pointwise multiplication of this matrix and . public Matrix PointwiseMultiply(Matrix other) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - if (ColumnCount != other.ColumnCount || RowCount != other.RowCount) { throw DimensionsDontMatch(this, other, "other"); @@ -1145,22 +937,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The matrix to pointwise multiply with this one. /// The matrix to store the result of the pointwise multiplication. - /// If the other matrix is . - /// If the result matrix is . /// If this matrix and are not the same size. /// If this matrix and are not the same size. public void PointwiseMultiply(Matrix other, Matrix result) { - if (other == null) - { - throw new ArgumentNullException("other"); - } - - if (result == null) - { - throw new ArgumentNullException("result"); - } - if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount) { throw DimensionsDontMatch(this, other, result); @@ -1173,16 +953,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Pointwise divide this matrix by another matrix. /// /// The pointwise denominator matrix to use. - /// If the other matrix is . /// If this matrix and are not the same size. /// A new matrix that is the pointwise division of this matrix and . public Matrix PointwiseDivide(Matrix divisor) { - if (divisor == null) - { - throw new ArgumentNullException("divisor"); - } - if (ColumnCount != divisor.ColumnCount || RowCount != divisor.RowCount) { throw DimensionsDontMatch(this, divisor); @@ -1198,22 +972,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The pointwise denominator matrix to use. /// The matrix to store the result of the pointwise division. - /// If the other matrix is . - /// If the result matrix is . /// If this matrix and are not the same size. /// If this matrix and are not the same size. public void PointwiseDivide(Matrix divisor, Matrix 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(this, divisor, result); @@ -1226,16 +988,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// Pointwise modulus this matrix by another matrix. /// /// The pointwise denominator matrix to use. - /// If the other matrix is . /// If this matrix and are not the same size. /// A new matrix that is the pointwise modulus of this matrix and . public Matrix PointwiseModulus(Matrix divisor) { - if (divisor == null) - { - throw new ArgumentNullException("divisor"); - } - if (ColumnCount != divisor.ColumnCount || RowCount != divisor.RowCount) { throw DimensionsDontMatch(this, divisor); @@ -1251,22 +1007,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The pointwise denominator matrix to use. /// The matrix to store the result of the pointwise modulus. - /// If the other matrix is . - /// If the result matrix is . /// If this matrix and are not the same size. /// If this matrix and are not the same size. public void PointwiseModulus(Matrix divisor, Matrix 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(this, divisor, result); @@ -1328,15 +1072,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// with M = this.Rows * lower.Rows and N = this.Columns * lower.Columns. /// /// The other matrix. - /// If other is . /// The kronecker product of the two matrices. public virtual Matrix KroneckerProduct(Matrix 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 /// /// The other matrix. /// The kronecker product of the two matrices. - /// If other is . - /// If the result matrix is . /// If the result matrix's dimensions are not (this.Rows * lower.rows) x (this.Columns * lower.Columns). public virtual void KroneckerProduct(Matrix other, Matrix 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(this, other, result); diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs index 73c779b3..d5fde258 100644 --- a/src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs +++ b/src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs @@ -46,11 +46,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator +(Matrix rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Clone(); } @@ -62,11 +57,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator -(Matrix rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Negate(); } @@ -83,11 +73,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Matrix operator +(Matrix leftSide, Matrix rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Add(rightSide); } @@ -102,11 +87,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator +(Matrix leftSide, T rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Add(rightSide); } @@ -121,11 +101,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator +(T leftSide, Matrix rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Add(leftSide); } @@ -142,11 +117,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Matrix operator -(Matrix leftSide, Matrix rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Subtract(rightSide); } @@ -162,11 +132,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Matrix operator -(Matrix leftSide, T rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Subtract(rightSide); } @@ -182,11 +147,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Matrix operator -(T leftSide, Matrix rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.SubtractFrom(leftSide); } @@ -199,11 +159,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator *(Matrix leftSide, T rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Multiply(rightSide); } @@ -216,11 +171,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator *(T leftSide, Matrix rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Multiply(leftSide); } @@ -237,11 +187,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If the dimensions of or don't conform. public static Matrix operator *(Matrix leftSide, Matrix rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Multiply(rightSide); } @@ -254,11 +199,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Vector operator *(Matrix leftSide, Vector rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Multiply(rightSide); } @@ -271,11 +211,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Vector operator *(Vector leftSide, Matrix rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.LeftMultiply(leftSide); } @@ -288,11 +223,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator /(T dividend, Matrix divisor) { - if (divisor == null) - { - throw new ArgumentNullException("divisor"); - } - return divisor.DivideByThis(dividend); } @@ -305,11 +235,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator /(Matrix dividend, T divisor) { - if (dividend == null) - { - throw new ArgumentNullException("dividend"); - } - return dividend.Divide(divisor); } @@ -322,11 +247,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator %(Matrix dividend, T divisor) { - if (dividend == null) - { - throw new ArgumentNullException("dividend"); - } - return dividend.Modulus(divisor); } @@ -339,11 +259,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator %(T dividend, Matrix divisor) { - if (divisor == null) - { - throw new ArgumentNullException("dividend"); - } - return divisor.ModulusByThis(dividend); } @@ -357,11 +272,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Matrix operator %(Matrix dividend, Matrix divisor) { - if (dividend == null) - { - throw new ArgumentNullException("dividend"); - } - return dividend.PointwiseModulus(divisor); } diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.Arithmetic.cs b/src/Numerics/LinearAlgebra/Generic/Vector.Arithmetic.cs index 116fcbcd..121ce867 100644 --- a/src/Numerics/LinearAlgebra/Generic/Vector.Arithmetic.cs +++ b/src/Numerics/LinearAlgebra/Generic/Vector.Arithmetic.cs @@ -171,15 +171,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// /// The scalar to add. /// The vector to store the result of the addition. - /// If the result vector is . /// If this vector and are not the same size. public void Add(T scalar, Vector 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 /// /// The vector to add to this one. /// A new vector containing the sum of both vectors. - /// If the other vector is . /// If this vector and are not the same size. public Vector Add(Vector 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 /// /// The vector to add to this one. /// The vector to store the result of the addition. - /// If the other vector is . - /// If the result vector is . /// If this vector and are not the same size. /// If this vector and are not the same size. public void Add(Vector other, Vector 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 /// /// The scalar to subtract. /// The vector to store the result of the subtraction. - /// If the result vector is . /// If this vector and are not the same size. public void Subtract(T scalar, Vector 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 /// /// The scalar to subtract from. /// The vector to store the result of the subtraction. - /// If the result vector is . /// If this vector and are not the same size. public void SubtractFrom(T scalar, Vector 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 /// Target vector public void Negate(Vector 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 /// /// The vector to subtract from this one. /// A new vector containing the subtraction of the the two vectors. - /// If the other vector is . /// If this vector and are not the same size. public Vector Subtract(Vector 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 /// /// The vector to subtract from this one. /// The vector to store the result of the subtraction. - /// If the other vector is . - /// If the result vector is . /// If this vector and are not the same size. /// If this vector and are not the same size. public void Subtract(Vector other, Vector 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 /// Target vector public void Conjugate(Vector 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 /// /// The scalar to multiply. /// The vector to store the result of the multiplication. - /// If the result vector is . /// If this vector and are not the same size. public void Multiply(T scalar, Vector 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 /// The other vector to add. /// The result of the addition. /// If is not of the same size. - /// If is . public T DotProduct(Vector 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 /// /// The scalar to divide with. /// The vector to store the result of the division. - /// If the result vector is . /// If this vector and are not the same size. public void Divide(T scalar, Vector 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 /// /// The scalar to divide. /// The vector to store the result of the division. - /// If the result vector is . /// If this vector and are not the same size. public void DivideByThis(T scalar, Vector 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 /// A vector to store the results in. public void Modulus(T divisor, Vector 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 /// A vector to store the results in. public void ModulusByThis(T dividend, Vector 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 /// /// The vector to pointwise multiply with this one. /// A new vector which is the pointwise multiplication of the two vectors. - /// If the other vector is . /// If this vector and are not the same size. public Vector PointwiseMultiply(Vector 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 /// /// The vector to pointwise multiply with this one. /// The vector to store the result of the pointwise multiplication. - /// If the other vector is . - /// If the result vector is . /// If this vector and are not the same size. /// If this vector and are not the same size. public void PointwiseMultiply(Vector other, Vector 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 /// /// The pointwise denominator vector to use. /// A new vector which is the pointwise division of the two vectors. - /// If the other vector is . /// If this vector and are not the same size. public Vector PointwiseDivide(Vector 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 /// /// The pointwise denominator vector to use. /// The vector to store the result of the pointwise division. - /// If the other vector is . - /// If the result vector is . /// If this vector and are not the same size. /// If this vector and are not the same size. public void PointwiseDivide(Vector divisor, Vector 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 /// /// The pointwise denominator vector to use. /// A new vector which is the pointwise modulus of the two vectors. - /// If the other vector is . /// If this vector and are not the same size. public Vector PointwiseModulus(Vector 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 /// /// The pointwise denominator vector to use. /// The vector to store the result of the pointwise modulus. - /// If the other vector is . - /// If the result vector is . /// If this vector and are not the same size. /// If this vector and are not the same size. public void PointwiseModulus(Vector divisor, Vector 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 /// First vector /// Second vector /// Matrix M[i,j] = u[i]*v[j] - /// If the u vector is . - /// If the v vector is . public static Matrix OuterProduct(Vector u, Vector 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++) diff --git a/src/Numerics/LinearAlgebra/Generic/Vector.Operators.cs b/src/Numerics/LinearAlgebra/Generic/Vector.Operators.cs index 275d397c..701aa422 100644 --- a/src/Numerics/LinearAlgebra/Generic/Vector.Operators.cs +++ b/src/Numerics/LinearAlgebra/Generic/Vector.Operators.cs @@ -44,11 +44,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator +(Vector rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Clone(); } @@ -60,11 +55,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator -(Vector rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Negate(); } @@ -78,11 +68,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Vector operator +(Vector leftSide, Vector rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Add(rightSide); } @@ -95,11 +80,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator +(Vector leftSide, T rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Add(rightSide); } @@ -112,11 +92,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator +(T leftSide, Vector rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Add(leftSide); } @@ -130,11 +105,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static Vector operator -(Vector leftSide, Vector rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Subtract(rightSide); } @@ -147,11 +117,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator -(Vector leftSide, T rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Subtract(rightSide); } @@ -164,11 +129,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator -(T leftSide, Vector rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.SubtractFrom(leftSide); } @@ -181,11 +141,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator *(Vector leftSide, T rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.Multiply(rightSide); } @@ -198,11 +153,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator *(T leftSide, Vector rightSide) { - if (rightSide == null) - { - throw new ArgumentNullException("rightSide"); - } - return rightSide.Multiply(leftSide); } @@ -216,11 +166,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If or is . public static T operator *(Vector leftSide, Vector rightSide) { - if (leftSide == null) - { - throw new ArgumentNullException("leftSide"); - } - return leftSide.DotProduct(rightSide); } @@ -233,11 +178,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator /(T dividend, Vector divisor) { - if (divisor == null) - { - throw new ArgumentNullException("divisor"); - } - return divisor.DevideByThis(dividend); } @@ -250,11 +190,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator /(Vector dividend, T divisor) { - if (dividend == null) - { - throw new ArgumentNullException("dividend"); - } - return dividend.Divide(divisor); } @@ -268,11 +203,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator /(Vector dividend, Vector divisor) { - if (dividend == null) - { - throw new ArgumentNullException("dividend"); - } - return dividend.PointwiseDivide(divisor); } @@ -285,11 +215,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator %(Vector dividend, T divisor) { - if (dividend == null) - { - throw new ArgumentNullException("dividend"); - } - return dividend.Modulus(divisor); } @@ -302,11 +227,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator %(T dividend, Vector divisor) { - if (divisor == null) - { - throw new ArgumentNullException("divisor"); - } - return divisor.ModulusByThis(dividend); } @@ -320,11 +240,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic /// If is . public static Vector operator %(Vector dividend, Vector divisor) { - if (dividend == null) - { - throw new ArgumentNullException("dividend"); - } - return dividend.PointwiseModulus(divisor); } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs index 1c104339..6bdf2ed0 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/DenseVectorTests.cs @@ -320,17 +320,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } } - - /// - /// Outer product for null dense vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullDenseVectorsThrowsArgumentNullException() - { - DenseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs index e1117706..1d848d1c 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/MatrixTests.Arithmetic.cs @@ -122,18 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Multiply with vector into result fails when result is null. - /// - [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 y = null; - Assert.Throws(() => matrix.Multiply(x, y)); - } - /// /// Multiply with a vector into too large result throws ArgumentException. /// @@ -213,17 +201,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Multiply with a scalar into null result throws ArgumentNullException. - /// - [Test] - public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix result = null; - Assert.Throws(() => matrix.Multiply(2.3, result)); - } - /// /// Multiply with a scalar when result has more rows throws ArgumentException. /// @@ -246,26 +223,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => matrix.Multiply(2.3, result)); } - /// - /// Operator left multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = 2.3 * matrix; }); - } - - /// - /// Operator right multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = matrix * 2.3; }); - } - /// /// Can add a matrix. /// @@ -289,17 +246,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Adding a matrix when argument is null throws ArgumentNullException. - /// - [Test] - public void AddNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Add(other)); - } - /// /// Adding a matrix with fewer columns throws ArgumentOutOfRangeException. /// @@ -344,28 +290,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Add operator when left side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix + other; }); - } - - /// - /// Add operator when right side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix + other; }); - } - /// /// Add operator when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -411,17 +335,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Subtract null matrix throws ArgumentNullException. - /// - [Test] - public void SubtractNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Subtract(other)); - } - /// /// Subtract a matrix when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -466,28 +379,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Subtract operator when left side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix - other; }); - } - - /// - /// Subtract operator when right side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix - other; }); - } - /// /// Subtract operator when right side has fewer columns throws ArgumentOutOfRangeException /// @@ -609,17 +500,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => matrix.TransposeAndMultiply(other)); } - /// - /// Transpose and multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); - } - /// /// Can transpose and multiply a matrix with matrix into a result matrix. /// @@ -658,28 +538,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => { var result = matrix * other; }); } - /// - /// Multiply null matrix with matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => { var result = matrix * other; }); - } - - /// - /// Multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix * other; }); - } - /// /// Can multiply a matrix with matrix into a result matrix. /// @@ -770,18 +628,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Multiply transposed matrix with vector into result fails when result is null. - /// - [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 y = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); - } - /// /// Multiply transposed matrix with a vector into too large result throws ArgumentException. /// @@ -831,17 +677,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); } - /// - /// Multiply the transpose of matrix with another matrix null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); - } - /// /// Multiply transpose of this matrix with another matrix into a result matrix. /// @@ -919,17 +754,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Negate into null result throws ArgumentNullException. - /// - [Test] - public void NegateIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix copy = null; - Assert.Throws(() => matrix.Negate(copy)); - } - /// /// Negate into a result matrix with more rows throws ArgumentException. /// @@ -1086,29 +910,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Pointwise multiply null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, result)); - } - - /// - /// Pointwise multiply matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, null)); - } - /// /// Pointwise multiply matrices with invalid dimensions into a result throws ArgumentException. /// @@ -1161,29 +962,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Pointwise divide null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, result)); - } - - /// - /// Pointwise divide matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, null)); - } - /// /// Pointwise divide matrices with invalid dimensions into a result throws ArgumentException. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs index 5a4c3e63..c17ffbd1 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/SparseVectorTest.cs @@ -242,18 +242,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Outer product for null sparse vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullSparseVectorsThrowsArgumentNullException() - { - SparseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } - /// /// Check sparse mechanism by setting values. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs index ac962875..4ad88c78 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorTests.Arithmetic.cs @@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// public abstract partial class VectorTests { - /// - /// Operator "+" throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = +vector); - } - /// /// Can call unary "+" operator. /// @@ -99,16 +88,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex CollectionAssert.AreEqual(Data, result); } - /// - /// Adding scalar to a vector when result vector is null throws an exception. - /// - [Test] - public void AddingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Add(0.0, null)); - } - /// /// Adding scalar to a vector using result vector with wrong size throws an exception. /// @@ -120,16 +99,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => vector.Add(0.0, result)); } - /// - /// Adding two vectors when one is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Add(null)); - } - /// /// Adding two vectors of different size throws an exception. /// @@ -141,17 +110,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => vector.Add(other)); } - /// - /// Adding two vectors when a result vector is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other, null)); - } - /// /// Adding two vectors when a result vector is different size throws an exception. /// @@ -164,21 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => vector.Add(other, result)); } - /// - /// Addition operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a += b); - - a = b; - b = null; - Assert.Throws(() => a += b); - } - /// /// Addition operator throws ArgumentException if vectors are different size. /// @@ -306,17 +249,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Negate operator throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = -vector); - } - /// /// Can call unary negation operator. /// @@ -376,16 +308,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Subtracting a scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Subtract(0.0, null)); - } - /// /// Subtracting a scalar with wrong size result vector throws ArgumentException. /// @@ -397,16 +319,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => vector.Subtract(0.0, result)); } - /// - /// Subtracting two vectors when one is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Subtract(null)); - } - /// /// Subtracting two vectors of differing size throws ArgumentException. /// @@ -418,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => vector.Subtract(other)); } - /// - /// Subtracting two vectors when a result vector is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other, null)); - } - /// /// Subtracting two vectors when a result vector is different size throws ArgumentException. /// @@ -441,21 +342,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.Throws(() => vector.Subtract(other, result)); } - /// - /// Subtraction operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a -= b); - - a = b; - b = null; - Assert.Throws(() => a -= b); - } - /// /// Subtraction operator throws ArgumentException if vectors are different size. /// @@ -657,26 +543,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Multiplying by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Multiply(1.0, null)); - } - - /// - /// Dividing by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void DividingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Divide(1.0, null)); - } - /// /// Multiplying by scalar with wrong result vector size throws ArgumentException. /// @@ -755,28 +621,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Operator multiply throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector result = null; - Assert.Throws(() => result = vector * 2.0); - Assert.Throws(() => result = 2.0 * vector); - } - - /// - /// Operator divide throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Assert.Throws(() => vector = vector / 2.0); - } - /// /// Can calculate the dot product /// @@ -789,18 +633,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.AreEqual(new Complex(50, 30), dataA.DotProduct(dataB)); } - /// - /// Dot product throws ArgumentNullException when an argument is null - /// - [Test] - public void DotProductWhenArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => dataA.DotProduct(dataB)); - } - /// /// Dot product throws ArgumentException when an argument has different size /// @@ -825,30 +657,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex Assert.AreEqual(new Complex(50, 30), dataA * dataB); } - /// - /// Operator "*" throws ArgumentNullException when the left argument is null. - /// - [Test] - public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => { var d = dataA * dataB; }); - } - - /// - /// Operator "*" throws ArgumentNullException when the right argument is null. - /// - [Test] - public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException() - { - Vector dataA = null; - var dataB = CreateVector(Data); - - Assert.Throws(() => { var d = dataA * dataB; }); - } - /// /// Operator "*" throws ArgumentException when the argument has different size. /// @@ -892,30 +700,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Pointwise multiply with null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - - /// - /// Pointwise multiply with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - /// /// Pointwise multiply with a result vector wrong size throws ArgumentException. /// @@ -959,30 +743,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Pointwise divide with null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - - /// - /// Pointwise divide with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - /// /// Pointwise divide with a result vector wrong size throws ArgumentException. /// @@ -1013,28 +773,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } - /// - /// Outer product with null first parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenFirstIsNullThrowsArgumentNullException() - { - Vector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - - /// - /// Outer product with null second parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenSecondIsNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - /// /// Can calculate the tensor multiply. /// @@ -1052,16 +790,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } } } - - /// - /// Tensor multiply with null parameter throws ArgumentNullException. - /// - [Test] - public void TensorMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => vector1.OuterProduct(vector2)); - } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs index 7f16d42a..d08a4e4e 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/DenseVectorTests.cs @@ -320,17 +320,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } } - - /// - /// Outer product for null dense vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullDenseVectorsThrowsArgumentNullException() - { - DenseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs index cfc83158..0080f507 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixTests.Arithmetic.cs @@ -122,18 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Multiply with vector into result fails when result is null. - /// - [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 y = null; - Assert.Throws(() => matrix.Multiply(x, y)); - } - /// /// Multiply with a vector into too large result throws ArgumentException. /// @@ -213,17 +201,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Multiply with a scalar into null result throws ArgumentNullException. - /// - [Test] - public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix result = null; - Assert.Throws(() => matrix.Multiply(2.3f, result)); - } - /// /// Multiply with a scalar when result has more rows throws ArgumentException. /// @@ -246,26 +223,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => matrix.Multiply(2.3f, result)); } - /// - /// Operator left multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = 2.3f * matrix; }); - } - - /// - /// Operator right multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = matrix * 2.3f; }); - } - /// /// Can add a matrix. /// @@ -289,17 +246,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Adding a matrix when argument is null throws ArgumentNullException. - /// - [Test] - public void AddNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Add(other)); - } - /// /// Adding a matrix with fewer columns throws ArgumentOutOfRangeException. /// @@ -344,28 +290,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Add operator when left side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix + other; }); - } - - /// - /// Add operator when right side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix + other; }); - } - /// /// Add operator when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -411,17 +335,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Subtract null matrix throws ArgumentNullException. - /// - [Test] - public void SubtractNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Subtract(other)); - } - /// /// Subtract a matrix when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -466,28 +379,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Subtract operator when left side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix - other; }); - } - - /// - /// Subtract operator when right side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix - other; }); - } - /// /// Subtract operator when right side has fewer columns throws ArgumentOutOfRangeException /// @@ -609,17 +500,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => matrix.TransposeAndMultiply(other)); } - /// - /// Transpose and multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); - } - /// /// Can transpose and multiply a matrix with matrix into a result matrix. /// @@ -658,28 +538,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => { var result = matrix * other; }); } - /// - /// Multiply null matrix with matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => { var result = matrix * other; }); - } - - /// - /// Multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix * other; }); - } - /// /// Can multiply a matrix with matrix into a result matrix. /// @@ -770,18 +628,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Multiply transposed matrix with vector into result fails when result is null. - /// - [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 y = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); - } - /// /// Multiply transposed matrix with a vector into too large result throws ArgumentException. /// @@ -831,17 +677,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); } - /// - /// Multiply the transpose of matrix with another matrix null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); - } - /// /// Multiply transpose of this matrix with another matrix into a result matrix. /// @@ -919,17 +754,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Negate into null result throws ArgumentNullException. - /// - [Test] - public void NegateIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix copy = null; - Assert.Throws(() => matrix.Negate(copy)); - } - /// /// Negate into a result matrix with more rows throws ArgumentException. /// @@ -1082,29 +906,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Pointwise multiply null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, result)); - } - - /// - /// Pointwise multiply matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, null)); - } - /// /// Pointwise multiply matrices with invalid dimensions into a result throws ArgumentException. /// @@ -1157,29 +958,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Pointwise divide null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, result)); - } - - /// - /// Pointwise divide matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, null)); - } - /// /// Pointwise divide matrices with invalid dimensions into a result throws ArgumentException. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs index b1cc4a3b..f8cd256a 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/SparseVectorTest.cs @@ -242,18 +242,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Outer product for null sparse vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullSparseVectorsThrowsArgumentNullException() - { - SparseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } - /// /// Check sparse mechanism by setting values. /// diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs index 37b71479..aa3ce429 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorTests.Arithmetic.cs @@ -36,17 +36,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// public abstract partial class VectorTests { - /// - /// Operator "+" throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = +vector); - } - /// /// Can call unary "+" operator. /// @@ -99,16 +88,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 CollectionAssert.AreEqual(Data, result); } - /// - /// Adding scalar to a vector when result vector is null throws an exception. - /// - [Test] - public void AddingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Add(0.0f, null)); - } - /// /// Adding scalar to a vector using result vector with wrong size throws an exception. /// @@ -120,16 +99,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => vector.Add(0.0f, result)); } - /// - /// Adding two vectors when one is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Add(null)); - } - /// /// Adding two vectors of different size throws an exception. /// @@ -141,17 +110,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => vector.Add(other)); } - /// - /// Adding two vectors when a result vector is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other, null)); - } - /// /// Adding two vectors when a result vector is different size throws an exception. /// @@ -164,21 +122,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => vector.Add(other, result)); } - /// - /// Addition operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a += b); - - a = b; - b = null; - Assert.Throws(() => a += b); - } - /// /// Addition operator throws ArgumentException if vectors are different size. /// @@ -306,17 +249,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Negate operator throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = -vector); - } - /// /// Can call unary negation operator. /// @@ -376,16 +308,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Subtracting a scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Subtract(0.0f, null)); - } - /// /// Subtracting a scalar with wrong size result vector throws ArgumentException. /// @@ -397,16 +319,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => vector.Subtract(0.0f, result)); } - /// - /// Subtracting two vectors when one is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Subtract(null)); - } - /// /// Subtracting two vectors of differing size throws ArgumentException. /// @@ -418,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => vector.Subtract(other)); } - /// - /// Subtracting two vectors when a result vector is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other, null)); - } - /// /// Subtracting two vectors when a result vector is different size throws ArgumentException. /// @@ -441,21 +342,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.Throws(() => vector.Subtract(other, result)); } - /// - /// Subtraction operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a -= b); - - a = b; - b = null; - Assert.Throws(() => a -= b); - } - /// /// Subtraction operator throws ArgumentException if vectors are different size. /// @@ -657,26 +543,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Multiplying by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Multiply(1.0f, null)); - } - - /// - /// Dividing by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void DividingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Divide(1.0f, null)); - } - /// /// Multiplying by scalar with wrong result vector size throws ArgumentException. /// @@ -755,28 +621,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Operator multiply throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector result = null; - Assert.Throws(() => result = vector * 2.0f); - Assert.Throws(() => result = 2.0f * vector); - } - - /// - /// Operator divide throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Assert.Throws(() => vector = vector / 2.0f); - } - /// /// Can calculate the dot product /// @@ -789,18 +633,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.AreEqual(new Complex32(50, 30), dataA.DotProduct(dataB)); } - /// - /// Dot product throws ArgumentNullException when an argument is null - /// - [Test] - public void DotProductWhenArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => dataA.DotProduct(dataB)); - } - /// /// Dot product throws ArgumentException when an argument has different size /// @@ -825,30 +657,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 Assert.AreEqual(new Complex32(50, 30), dataA * dataB); } - /// - /// Operator "*" throws ArgumentNullException when the left argument is null. - /// - [Test] - public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => { var d = dataA * dataB; }); - } - - /// - /// Operator "*" throws ArgumentNullException when the right argument is null. - /// - [Test] - public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException() - { - Vector dataA = null; - var dataB = CreateVector(Data); - - Assert.Throws(() => { var d = dataA * dataB; }); - } - /// /// Operator "*" throws ArgumentException when the argument has different size. /// @@ -892,30 +700,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Pointwise multiply with null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - - /// - /// Pointwise multiply with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - /// /// Pointwise multiply with a result vector wrong size throws ArgumentException. /// @@ -959,30 +743,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Pointwise divide with null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - - /// - /// Pointwise divide with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - /// /// Pointwise divide with a result vector wrong size throws ArgumentException. /// @@ -1013,28 +773,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } - /// - /// Outer product with null first parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenFirstIsNullThrowsArgumentNullException() - { - Vector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - - /// - /// Outer product with null second parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenSecondIsNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - /// /// Can calculate the tensor multiply. /// @@ -1052,16 +790,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 } } } - - /// - /// Tensor multiply with null parameter throws ArgumentNullException. - /// - [Test] - public void TensorMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => vector1.OuterProduct(vector2)); - } } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs index fe817b8a..a6c2621e 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/DenseVectorTests.cs @@ -319,17 +319,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } } - - /// - /// Outer product for null dense vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullDenseVectorsThrowsArgumentNullException() - { - DenseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } } } diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs index b4354ebe..bf1f6e91 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/MatrixTests.Arithmetic.cs @@ -120,18 +120,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Multiply with vector into result fails when result is null. - /// - [Test] - public void MultiplyWithVectorIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - var x = new DenseVector(new[] { 1.0, 2.0, 3.0 }); - Vector y = null; - Assert.Throws(() => matrix.Multiply(x, y)); - } - /// /// Multiply with a vector into too large result throws ArgumentException. /// @@ -208,17 +196,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Multiply with a scalar into null result throws ArgumentNullException. - /// - [Test] - public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix result = null; - Assert.Throws(() => matrix.Multiply(2.3, result)); - } - /// /// Multiply with a scalar when result has more rows throws ArgumentException. /// @@ -241,26 +218,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => matrix.Multiply(2.3, result)); } - /// - /// Operator left multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = 2.3 * matrix; }); - } - - /// - /// Operator right multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = matrix * 2.3; }); - } - /// /// Can add a matrix. /// @@ -284,17 +241,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Adding a matrix when argument is null throws ArgumentNullException. - /// - [Test] - public void AddNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Add(other)); - } - /// /// Adding a matrix with fewer columns throws ArgumentOutOfRangeException. /// @@ -339,28 +285,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Add operator when left side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix + other; }); - } - - /// - /// Add operator when right side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix + other; }); - } - /// /// Add operator when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -406,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Subtract null matrix throws ArgumentNullException. - /// - [Test] - public void SubtractNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Subtract(other)); - } - /// /// Subtract a matrix when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -461,28 +374,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Subtract operator when left side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix - other; }); - } - - /// - /// Subtract operator when right side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix - other; }); - } - /// /// Subtract operator when right side has fewer columns throws ArgumentOutOfRangeException /// @@ -604,17 +495,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => matrix.TransposeAndMultiply(other)); } - /// - /// Transpose and multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); - } - /// /// Can transpose and multiply a matrix with matrix into a result matrix. /// @@ -653,28 +533,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => { var result = matrix * other; }); } - /// - /// Multiply null matrix with matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => { var result = matrix * other; }); - } - - /// - /// Multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix * other; }); - } - /// /// Can multiply a matrix with matrix into a result matrix. /// @@ -765,18 +623,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Multiply transposed matrix with vector into result fails when result is null. - /// - [Test] - public void TransposeThisAndMultiplyWithVectorIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - var x = new DenseVector(new[] { 1.0, 2.0, 3.0 }); - Vector y = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); - } - /// /// Multiply transposed matrix with a vector into too large result throws ArgumentException. /// @@ -826,17 +672,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); } - /// - /// Multiply the transpose of matrix with another matrix null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); - } - /// /// Multiply transpose of this matrix with another matrix into a result matrix. /// @@ -914,17 +749,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Negate into null result throws ArgumentNullException. - /// - [Test] - public void NegateIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix copy = null; - Assert.Throws(() => matrix.Negate(copy)); - } - /// /// Negate into a result matrix with more rows throws ArgumentException. /// @@ -1077,29 +901,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Pointwise multiply null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, result)); - } - - /// - /// Pointwise multiply matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, null)); - } - /// /// Pointwise multiply matrices with invalid dimensions into a result throws ArgumentException. /// @@ -1152,29 +953,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Pointwise divide null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, result)); - } - - /// - /// Pointwise divide matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, null)); - } - /// /// Pointwise divide matrices with invalid dimensions into a result throws ArgumentException. /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs index 8fc08096..10e1de3d 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/SparseVectorTest.cs @@ -241,18 +241,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Outer product for null sparse vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullSparseVectorsThrowsArgumentNullException() - { - SparseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } - /// /// Check sparse mechanism by setting values. /// diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs index 46d00758..a7d10265 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/VectorTests.Arithmetic.cs @@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// public abstract partial class VectorTests { - /// - /// Operator "+" throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = +vector); - } - /// /// Can call unary "+" operator. /// @@ -98,16 +87,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double CollectionAssert.AreEqual(Data, result); } - /// - /// Adding scalar to a vector when result vector is null throws an exception. - /// - [Test] - public void AddingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Add(0.0, null)); - } - /// /// Adding scalar to a vector using result vector with wrong size throws an exception. /// @@ -119,16 +98,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => vector.Add(0.0, result)); } - /// - /// Adding two vectors when one is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Add(null)); - } - /// /// Adding two vectors of different size throws an exception. /// @@ -140,17 +109,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => vector.Add(other)); } - /// - /// Adding two vectors when a result vector is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other, null)); - } - /// /// Adding two vectors when a result vector is different size throws an exception. /// @@ -163,21 +121,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => vector.Add(other, result)); } - /// - /// Addition operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a += b); - - a = b; - b = null; - Assert.Throws(() => a += b); - } - /// /// Addition operator throws ArgumentException if vectors are different size. /// @@ -305,17 +248,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Negate operator throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = -vector); - } - /// /// Can call unary negation operator. /// @@ -375,16 +307,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Subtracting a scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Subtract(0.0, null)); - } - /// /// Subtracting a scalar with wrong size result vector throws ArgumentException. /// @@ -396,16 +318,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => vector.Subtract(0.0, result)); } - /// - /// Subtracting two vectors when one is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Subtract(null)); - } - /// /// Subtracting two vectors of differing size throws ArgumentException. /// @@ -417,17 +329,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => vector.Subtract(other)); } - /// - /// Subtracting two vectors when a result vector is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other, null)); - } - /// /// Subtracting two vectors when a result vector is different size throws ArgumentException. /// @@ -440,21 +341,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.Throws(() => vector.Subtract(other, result)); } - /// - /// Subtraction operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a -= b); - - a = b; - b = null; - Assert.Throws(() => a -= b); - } - /// /// Subtraction operator throws ArgumentException if vectors are different size. /// @@ -656,26 +542,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Multiplying by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Multiply(1.0, null)); - } - - /// - /// Dividing by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void DividingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Divide(1.0, null)); - } - /// /// Multiplying by scalar with wrong result vector size throws ArgumentException. /// @@ -754,28 +620,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Operator multiply throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector result = null; - Assert.Throws(() => result = vector * 2.0); - Assert.Throws(() => result = 2.0 * vector); - } - - /// - /// Operator divide throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Assert.Throws(() => vector = vector / 2.0); - } - /// /// Can calculate the dot product /// @@ -788,18 +632,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.AreEqual(55.0, dataA.DotProduct(dataB)); } - /// - /// Dot product throws ArgumentNullException when an argument is null - /// - [Test] - public void DotProductWhenArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => dataA.DotProduct(dataB)); - } - /// /// Dot product throws ArgumentException when an argument has different size /// @@ -824,30 +656,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double Assert.AreEqual(55.0, dataA * dataB); } - /// - /// Operator "*" throws ArgumentNullException when the left argument is null. - /// - [Test] - public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => { var d = dataA * dataB; }); - } - - /// - /// Operator "*" throws ArgumentNullException when the right argument is null. - /// - [Test] - public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException() - { - Vector dataA = null; - var dataB = CreateVector(Data); - - Assert.Throws(() => { var d = dataA * dataB; }); - } - /// /// Operator "*" throws ArgumentException when the argument has different size. /// @@ -891,30 +699,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Pointwise multiply with null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - - /// - /// Pointwise multiply with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - /// /// Pointwise multiply with a result vector wrong size throws ArgumentException. /// @@ -958,30 +742,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Pointwise divide with null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - - /// - /// Pointwise divide with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - /// /// Pointwise divide with a result vector wrong size throws ArgumentException. /// @@ -1012,28 +772,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Outer product with null first parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenFirstIsNullThrowsArgumentNullException() - { - Vector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - - /// - /// Outer product with null second parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenSecondIsNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - /// /// Can calculate the tensor multiply. /// @@ -1052,17 +790,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } } - /// - /// Tensor multiply with null parameter throws ArgumentNullException. - /// - [Test] - public void TensorMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => vector1.OuterProduct(vector2)); - } - /// /// Can compute the modules of each element of vector. /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs index 3dd5a687..77d289a3 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/DenseVectorTests.cs @@ -319,17 +319,5 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } } - - /// - /// Outer product for null dense vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullDenseVectorsThrowsArgumentNullException() - { - DenseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } } } diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs index bf4f08bc..c115908e 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixTests.Arithmetic.cs @@ -120,18 +120,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Multiply with vector into result fails when result is null. - /// - [Test] - public void MultiplyWithVectorIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - var x = new DenseVector(new[] { 1.0f, 2.0f, 3.0f }); - Vector y = null; - Assert.Throws(() => matrix.Multiply(x, y)); - } - /// /// Multiply with a vector into too large result throws ArgumentException. /// @@ -208,17 +196,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Multiply with a scalar into null result throws ArgumentNullException. - /// - [Test] - public void MultiplyWithScalarIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix result = null; - Assert.Throws(() => matrix.Multiply(2.3f, result)); - } - /// /// Multiply with a scalar when result has more rows throws ArgumentException. /// @@ -241,26 +218,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => matrix.Multiply(2.3f, result)); } - /// - /// Operator left multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorLeftMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = 2.3f * matrix; }); - } - - /// - /// Operator right multiply with a scalar when matrix is null throws ArgumentNullException. - /// - [Test] - public void OperatorRightMultiplyWithScalarWhenMatrixIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - Assert.Throws(() => { var result = matrix * 2.3f; }); - } - /// /// Can add a matrix. /// @@ -284,17 +241,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Adding a matrix when argument is null throws ArgumentNullException. - /// - [Test] - public void AddNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Add(other)); - } - /// /// Adding a matrix with fewer columns throws ArgumentOutOfRangeException. /// @@ -339,28 +285,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Add operator when left side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix + other; }); - } - - /// - /// Add operator when right side is null throws ArgumentNullException. - /// - [Test] - public void AddOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix + other; }); - } - /// /// Add operator when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -406,17 +330,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Subtract null matrix throws ArgumentNullException. - /// - [Test] - public void SubtractNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular4x4"]; - Matrix other = null; - Assert.Throws(() => matrix.Subtract(other)); - } - /// /// Subtract a matrix when right side has fewer columns throws ArgumentOutOfRangeException. /// @@ -461,28 +374,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Subtract operator when left side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenLeftSideIsNullThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Singular3x3"]; - Assert.Throws(() => { var result = matrix - other; }); - } - - /// - /// Subtract operator when right side is null throws ArgumentNullException. - /// - [Test] - public void SubtractOperatorWhenRightSideIsNullThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix - other; }); - } - /// /// Subtract operator when right side has fewer columns throws ArgumentOutOfRangeException /// @@ -604,17 +495,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => matrix.TransposeAndMultiply(other)); } - /// - /// Transpose and multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeAndMultiply(other)); - } - /// /// Can transpose and multiply a matrix with matrix into a result matrix. /// @@ -653,28 +533,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => { var result = matrix * other; }); } - /// - /// Multiply null matrix with matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyNullMatrixWithMatrixThrowsArgumentNullException() - { - Matrix matrix = null; - var other = TestMatrices["Wide2x3"]; - Assert.Throws(() => { var result = matrix * other; }); - } - - /// - /// Multiply a matrix with null matrix throws ArgumentNullException. - /// - [Test] - public void MultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => { var result = matrix * other; }); - } - /// /// Can multiply a matrix with matrix into a result matrix. /// @@ -759,18 +617,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Multiply transposed matrix with vector into result fails when result is null. - /// - [Test] - public void TransposeThisAndMultiplyWithVectorIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - var x = new DenseVector(new[] { 1.0f, 2.0f, 3.0f }); - Vector y = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(x, y)); - } - /// /// Multiply transposed matrix with a vector into too large result throws ArgumentException. /// @@ -820,17 +666,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); } - /// - /// Multiply the transpose of matrix with another matrix null matrix throws ArgumentNullException. - /// - [Test] - public void TransposeThisAndMultiplyMatrixWithNullMatrixThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - Assert.Throws(() => matrix.TransposeThisAndMultiply(other)); - } - /// /// Multiply transpose of this matrix with another matrix into a result matrix. /// @@ -908,17 +743,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Negate into null result throws ArgumentNullException. - /// - [Test] - public void NegateIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Singular3x3"]; - Matrix copy = null; - Assert.Throws(() => matrix.Negate(copy)); - } - /// /// Negate into a result matrix with more rows throws ArgumentException. /// @@ -1071,29 +895,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Pointwise multiply null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, result)); - } - - /// - /// Pointwise multiply matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseMultiply(other, null)); - } - /// /// Pointwise multiply matrices with invalid dimensions into a result throws ArgumentException. /// @@ -1146,29 +947,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Pointwise divide null matrices into a result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideNullIntoResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - Matrix other = null; - var result = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, result)); - } - - /// - /// Pointwise divide matrices into null result throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideIntoNullResultThrowsArgumentNullException() - { - var matrix = TestMatrices["Wide2x3"]; - var other = matrix.Clone(); - Assert.Throws(() => matrix.PointwiseDivide(other, null)); - } - /// /// Pointwise divide matrices with invalid dimensions into a result throws ArgumentException. /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs index c53e5dfa..5e3ec4c2 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/SparseVectorTest.cs @@ -242,18 +242,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Outer product for null sparse vectors throws ArgumentNullException. - /// - [Test] - public void OuterProductForNullSparseVectorsThrowsArgumentNullException() - { - SparseVector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - Assert.Throws(() => Vector.OuterProduct(vector2, vector1)); - } - /// /// Check sparse mechanism by setting values. /// diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs index b5141813..86b71d7a 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/VectorTests.Arithmetic.cs @@ -35,17 +35,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// public abstract partial class VectorTests { - /// - /// Operator "+" throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorPlusWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = +vector); - } - /// /// Can call unary "+" operator. /// @@ -98,16 +87,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single CollectionAssert.AreEqual(Data, result); } - /// - /// Adding scalar to a vector when result vector is null throws an exception. - /// - [Test] - public void AddingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Add(0.0f, null)); - } - /// /// Adding scalar to a vector using result vector with wrong size throws an exception. /// @@ -119,16 +98,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => vector.Add(0.0f, result)); } - /// - /// Adding two vectors when one is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Add(null)); - } - /// /// Adding two vectors of different size throws an exception. /// @@ -140,17 +109,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => vector.Add(other)); } - /// - /// Adding two vectors when a result vector is null throws an exception. - /// - [Test] - public void AddingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Add(other, null)); - } - /// /// Adding two vectors when a result vector is different size throws an exception. /// @@ -163,21 +121,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => vector.Add(other, result)); } - /// - /// Addition operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void AdditionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a += b); - - a = b; - b = null; - Assert.Throws(() => a += b); - } - /// /// Addition operator throws ArgumentException if vectors are different size. /// @@ -305,17 +248,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Negate operator throws ArgumentNullException when call on null vector. - /// - [Test] - public void OperatorNegateWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector other = null; - Assert.Throws(() => other = -vector); - } - /// /// Can call unary negation operator. /// @@ -375,16 +307,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Subtracting a scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void SubtractingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Subtract(0.0f, null)); - } - /// /// Subtracting a scalar with wrong size result vector throws ArgumentException. /// @@ -396,16 +318,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => vector.Subtract(0.0f, result)); } - /// - /// Subtracting two vectors when one is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndOneIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data); - Assert.Throws(() => vector.Subtract(null)); - } - /// /// Subtracting two vectors of differing size throws ArgumentException. /// @@ -417,17 +329,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => vector.Subtract(other)); } - /// - /// Subtracting two vectors when a result vector is null throws ArgumentNullException. - /// - [Test] - public void SubtractingTwoVectorsAndResultIsNullThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - var other = CreateVector(Data.Length + 1); - Assert.Throws(() => vector.Subtract(other, null)); - } - /// /// Subtracting two vectors when a result vector is different size throws ArgumentException. /// @@ -440,21 +341,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.Throws(() => vector.Subtract(other, result)); } - /// - /// Subtraction operator throws ArgumentNullException if a vector is null. - /// - [Test] - public void SubtractionOperatorIfAVectorIsNullThrowsArgumentNullException() - { - Vector a = null; - var b = CreateVector(Data.Length); - Assert.Throws(() => a -= b); - - a = b; - b = null; - Assert.Throws(() => a -= b); - } - /// /// Subtraction operator throws ArgumentException if vectors are different size. /// @@ -656,26 +542,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Multiplying by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void MultiplyingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Multiply(1.0f, null)); - } - - /// - /// Dividing by scalar with null result vector throws ArgumentNullException. - /// - [Test] - public void DividingScalarWithNullResultVectorThrowsArgumentNullException() - { - var vector = CreateVector(Data.Length); - Assert.Throws(() => vector.Divide(1.0f, null)); - } - /// /// Multiplying by scalar with wrong result vector size throws ArgumentException. /// @@ -754,28 +620,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Operator multiply throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorMultiplyWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Vector result = null; - Assert.Throws(() => result = vector * 2.0f); - Assert.Throws(() => result = 2.0f * vector); - } - - /// - /// Operator divide throws ArgumentNullException when a vector is null. - /// - [Test] - public void OperatorDivideWhenVectorIsNullThrowsArgumentNullException() - { - Vector vector = null; - Assert.Throws(() => vector = vector / 2.0f); - } - /// /// Can calculate the dot product /// @@ -788,18 +632,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.AreEqual(55.0f, dataA.DotProduct(dataB)); } - /// - /// Dot product throws ArgumentNullException when an argument is null. - /// - [Test] - public void DotProductWhenArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => dataA.DotProduct(dataB)); - } - /// /// Dot product throws ArgumentException when an argument has different size /// @@ -824,30 +656,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single Assert.AreEqual(55.0f, dataA * dataB); } - /// - /// Operator "*" throws ArgumentNullException when the left argument is null. - /// - [Test] - public void OperatorDotProductWhenLeftArgumentIsNullThrowsArgumentNullException() - { - var dataA = CreateVector(Data); - Vector dataB = null; - - Assert.Throws(() => { var d = dataA * dataB; }); - } - - /// - /// Operator "*" throws ArgumentNullException when the right argument is null. - /// - [Test] - public void OperatorDotProductWhenRightArgumentIsNullThrowsArgumentNullException() - { - Vector dataA = null; - var dataB = CreateVector(Data); - - Assert.Throws(() => { var d = dataA * dataB; }); - } - /// /// Operator "*" throws ArgumentException when the argument has different size. /// @@ -891,30 +699,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Pointwise multiply with null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - - /// - /// Pointwise multiply with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseMultiplyWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseMultiply(vector2, result)); - } - /// /// Pointwise multiply with a result vector wrong size throws ArgumentException. /// @@ -958,30 +742,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Pointwise divide with null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - var result = CreateVector(vector1.Count); - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - - /// - /// Pointwise divide with a result vector is null throws ArgumentNullException. - /// - [Test] - public void PointwiseDivideWithResultNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - var vector2 = vector1.Clone(); - Vector result = null; - Assert.Throws(() => vector1.PointwiseDivide(vector2, result)); - } - /// /// Pointwise divide with a result vector wrong size throws ArgumentException. /// @@ -1012,28 +772,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Outer product with null first parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenFirstIsNullThrowsArgumentNullException() - { - Vector vector1 = null; - var vector2 = CreateVector(Data); - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - - /// - /// Outer product with null second parameter throws ArgumentNullException. - /// - [Test] - public void OuterProductWhenSecondIsNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => Vector.OuterProduct(vector1, vector2)); - } - /// /// Can calculate the tensor multiply. /// @@ -1052,17 +790,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single } } - /// - /// Tensor multiply with null parameter throws ArgumentNullException. - /// - [Test] - public void TensorMultiplyWithNullThrowsArgumentNullException() - { - var vector1 = CreateVector(Data); - Vector vector2 = null; - Assert.Throws(() => vector1.OuterProduct(vector2)); - } - /// /// Can compute the modules of each element of vector. ///