Browse Source

Merge pull request #28 from andreister/master

Linear Algebra: Dimension mismatch exceptions should tell the actual dimensions
la-knuth
Christoph Ruegg 15 years ago
parent
commit
43f5772730
  1. 2
      src/Numerics/Distributions/Multivariate/MatrixNormal.cs
  2. 2
      src/Numerics/Distributions/Multivariate/Wishart.cs
  3. 6
      src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
  4. 42
      src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
  5. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseCholesky.cs
  6. 2
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs
  7. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs
  8. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs
  9. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseQR.cs
  10. 2
      src/Numerics/LinearAlgebra/Complex/Factorization/DenseSvd.cs
  11. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/UserCholesky.cs
  12. 2
      src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs
  13. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/UserGramSchmidt.cs
  14. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/UserLU.cs
  15. 4
      src/Numerics/LinearAlgebra/Complex/Factorization/UserQR.cs
  16. 2
      src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs
  17. 4
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs
  18. 2
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs
  19. 11
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs
  20. 11
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs
  21. 11
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs
  22. 18
      src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
  23. 6
      src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs
  24. 42
      src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
  25. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseCholesky.cs
  26. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs
  27. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs
  28. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseQR.cs
  29. 2
      src/Numerics/LinearAlgebra/Complex32/Factorization/DenseSvd.cs
  30. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/UserCholesky.cs
  31. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/UserGramSchmidt.cs
  32. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/UserLU.cs
  33. 4
      src/Numerics/LinearAlgebra/Complex32/Factorization/UserQR.cs
  34. 2
      src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs
  35. 4
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs
  36. 2
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs
  37. 4
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs
  38. 4
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs
  39. 4
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs
  40. 18
      src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
  41. 6
      src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
  42. 47
      src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
  43. 4
      src/Numerics/LinearAlgebra/Double/Factorization/DenseCholesky.cs
  44. 4
      src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs
  45. 4
      src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs
  46. 4
      src/Numerics/LinearAlgebra/Double/Factorization/DenseQR.cs
  47. 2
      src/Numerics/LinearAlgebra/Double/Factorization/DenseSvd.cs
  48. 4
      src/Numerics/LinearAlgebra/Double/Factorization/UserCholesky.cs
  49. 4
      src/Numerics/LinearAlgebra/Double/Factorization/UserGramSchmidt.cs
  50. 4
      src/Numerics/LinearAlgebra/Double/Factorization/UserLU.cs
  51. 4
      src/Numerics/LinearAlgebra/Double/Factorization/UserQR.cs
  52. 2
      src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs
  53. 4
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs
  54. 2
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs
  55. 4
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs
  56. 4
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs
  57. 4
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs
  58. 18
      src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
  59. 153
      src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
  60. 14
      src/Numerics/LinearAlgebra/Generic/Matrix.cs
  61. 6
      src/Numerics/LinearAlgebra/Single/DenseMatrix.cs
  62. 47
      src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
  63. 4
      src/Numerics/LinearAlgebra/Single/Factorization/DenseCholesky.cs
  64. 4
      src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs
  65. 4
      src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs
  66. 4
      src/Numerics/LinearAlgebra/Single/Factorization/DenseQR.cs
  67. 2
      src/Numerics/LinearAlgebra/Single/Factorization/DenseSvd.cs
  68. 4
      src/Numerics/LinearAlgebra/Single/Factorization/UserCholesky.cs
  69. 4
      src/Numerics/LinearAlgebra/Single/Factorization/UserGramSchmidt.cs
  70. 4
      src/Numerics/LinearAlgebra/Single/Factorization/UserLU.cs
  71. 4
      src/Numerics/LinearAlgebra/Single/Factorization/UserQR.cs
  72. 2
      src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs
  73. 4
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs
  74. 2
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs
  75. 4
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs
  76. 4
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs
  77. 4
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs
  78. 18
      src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
  79. 1
      src/Numerics/Numerics.csproj
  80. 29
      src/Numerics/Properties/Resources.Designer.cs
  81. 9
      src/Numerics/Properties/Resources.resx

2
src/Numerics/Distributions/Multivariate/MatrixNormal.cs

@ -238,7 +238,7 @@ namespace MathNet.Numerics.Distributions
{
if (x.RowCount != _m.RowCount || x.ColumnCount != _m.ColumnCount)
{
throw new ArgumentOutOfRangeException("x", Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentOutOfRangeException>(x, _m, "x");
}
var a = x - _m;

2
src/Numerics/Distributions/Multivariate/Wishart.cs

@ -247,7 +247,7 @@ namespace MathNet.Numerics.Distributions
if (x.RowCount != p || x.ColumnCount != p)
{
throw new ArgumentOutOfRangeException("x", Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentOutOfRangeException>(x, _s, "x");
}
var dX = x.Determinant();

6
src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs

@ -666,7 +666,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Add(rightSide);
@ -713,7 +713,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Subtract(rightSide);
@ -794,7 +794,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Multiply(rightSide);

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

@ -296,7 +296,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<Complex> result;
@ -334,12 +334,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
}
var diagOther = other as DiagonalMatrix;
@ -371,7 +371,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<Complex> result;
@ -409,12 +409,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
var diagOther = other as DiagonalMatrix;
@ -542,12 +542,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
if (result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, result);
}
var m = other as DiagonalMatrix;
@ -584,7 +584,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var m = other as DiagonalMatrix;
@ -616,7 +616,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (ColumnCount != rightSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "rightSide");
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
}
if (result == null)
@ -626,7 +626,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (RowCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(rightSide, result))
@ -666,7 +666,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (RowCount != leftSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "leftSide");
throw DimensionsDontMatch<ArgumentException>(this, leftSide, "leftSide");
}
if (result == null)
@ -676,7 +676,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(leftSide, result))
@ -765,7 +765,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (ColumnCount != otherDiagonal.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, otherDiagonal);
}
var result = (DiagonalMatrix)CreateMatrix(RowCount, other.RowCount);
@ -804,7 +804,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target);
}
Array.Copy(Data, diagonalTarget.Data, Data.Length);
@ -1028,7 +1028,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -1068,7 +1068,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1098,7 +1098,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1133,7 +1133,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1368,7 +1368,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != (RowCount + lower.RowCount) || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
// Clear the result matrix
@ -1500,7 +1500,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount + lower.RowCount || result.ColumnCount != ColumnCount + lower.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
// Clear the result matrix

4
src/Numerics/LinearAlgebra/Complex/Factorization/DenseCholesky.cs

@ -104,7 +104,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseMatrix;
@ -153,7 +153,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseVector;

2
src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs

@ -906,7 +906,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (VectorEv.Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(VectorEv, result);
}
if (IsSymmetric)

4
src/Numerics/LinearAlgebra/Complex/Factorization/DenseGramSchmidt.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -202,7 +202,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Complex/Factorization/DenseLU.cs

@ -106,7 +106,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseMatrix;
@ -155,7 +155,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Complex/Factorization/DenseQR.cs

@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -158,7 +158,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var dinput = input as DenseVector;

2
src/Numerics/LinearAlgebra/Complex/Factorization/DenseSvd.cs

@ -161,7 +161,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Complex/Factorization/UserCholesky.cs

@ -171,7 +171,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);
@ -232,7 +232,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);

2
src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs

@ -901,7 +901,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (VectorEv.Count != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(VectorEv, result);
}
if (IsSymmetric)

4
src/Numerics/LinearAlgebra/Complex/Factorization/UserGramSchmidt.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -211,7 +211,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var inputCopy = input.Clone();

4
src/Numerics/LinearAlgebra/Complex/Factorization/UserLU.cs

@ -162,7 +162,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.
@ -243,7 +243,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.

4
src/Numerics/LinearAlgebra/Complex/Factorization/UserQR.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -297,7 +297,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var inputCopy = input.Clone();

2
src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs

@ -903,7 +903,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var mn = Math.Min(MatrixU.RowCount, MatrixVT.ColumnCount);

4
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs

@ -260,7 +260,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, result);
}
// Initialize the solver fields
@ -520,7 +520,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

2
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs

@ -616,7 +616,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

11
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs

@ -307,14 +307,9 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
throw new ArgumentNullException("result");
}
if (result.Count != input.Count)
if (input.Count != matrix.RowCount || result.Count != input.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
// Initialize the solver fields
@ -630,7 +625,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

11
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs

@ -329,14 +329,9 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
throw new ArgumentNullException("result");
}
if (result.Count != input.Count)
if (input.Count != matrix.RowCount || result.Count != input.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
// Initialize the solver fields
@ -797,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

11
src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs

@ -240,14 +240,9 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
throw new ArgumentNullException("result");
}
if (result.Count != input.Count)
if (input.Count != matrix.RowCount || result.Count != input.Count)
{
throw new ArgumentException(Resources.ArgumentVectorsSameLength);
}
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
// Initialize the solver fields
@ -525,7 +520,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

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

@ -275,7 +275,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result);
}
if (ReferenceEquals(this, result))
@ -337,7 +337,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result);
}
if (ReferenceEquals(this, result))
@ -471,7 +471,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result);
}
if (ReferenceEquals(this, result))
@ -534,7 +534,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result);
}
if (ReferenceEquals(this, result))
@ -817,7 +817,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target, "target");
}
// Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
@ -1042,7 +1042,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
{
if (resultSparseMatrix.RowCount != RowCount + lowerSparseMatrix.RowCount || resultSparseMatrix.ColumnCount != ColumnCount + lowerSparseMatrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, resultSparseMatrix, lowerSparseMatrix);
}
resultSparseMatrix.NonZerosCount = NonZerosCount + lowerSparseMatrix.NonZerosCount;
@ -1622,7 +1622,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Add(rightSide);
@ -1669,7 +1669,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Subtract(rightSide);
@ -1750,7 +1750,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Multiply(rightSide);

6
src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs

@ -666,7 +666,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Add(rightSide);
@ -713,7 +713,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Subtract(rightSide);
@ -794,7 +794,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Multiply(rightSide);

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

@ -301,7 +301,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<Complex32> result;
@ -339,12 +339,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
var diagOther = other as DiagonalMatrix;
@ -376,7 +376,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<Complex32> result;
@ -414,12 +414,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "result");
}
var diagOther = other as DiagonalMatrix;
@ -547,12 +547,12 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
if (result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var m = other as DiagonalMatrix;
@ -589,7 +589,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var m = other as DiagonalMatrix;
@ -621,7 +621,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (ColumnCount != rightSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "rightSide");
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
}
if (result == null)
@ -631,7 +631,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (RowCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(rightSide, result))
@ -671,7 +671,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (RowCount != leftSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "leftSide");
throw DimensionsDontMatch<ArgumentException>(this, leftSide, "leftSide");
}
if (result == null)
@ -681,7 +681,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(leftSide, result))
@ -770,7 +770,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (ColumnCount != otherDiagonal.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, otherDiagonal);
}
var result = (DiagonalMatrix)CreateMatrix(RowCount, other.RowCount);
@ -809,7 +809,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target, "target");
}
Array.Copy(Data, diagonalTarget.Data, Data.Length);
@ -1033,7 +1033,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -1073,7 +1073,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1103,7 +1103,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1138,7 +1138,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1373,7 +1373,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != (RowCount + lower.RowCount) || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lower, result);
}
// Clear the result matrix
@ -1505,7 +1505,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount + lower.RowCount || result.ColumnCount != ColumnCount + lower.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lower, result);
}
// Clear the result matrix

4
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseCholesky.cs

@ -104,7 +104,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseMatrix;
@ -153,7 +153,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseGramSchmidt.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -202,7 +202,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseLU.cs

@ -106,7 +106,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseMatrix;
@ -155,7 +155,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseQR.cs

@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -158,7 +158,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var dinput = input as DenseVector;

2
src/Numerics/LinearAlgebra/Complex32/Factorization/DenseSvd.cs

@ -161,7 +161,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Complex32/Factorization/UserCholesky.cs

@ -171,7 +171,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);
@ -232,7 +232,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);

4
src/Numerics/LinearAlgebra/Complex32/Factorization/UserGramSchmidt.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -211,7 +211,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var inputCopy = input.Clone();

4
src/Numerics/LinearAlgebra/Complex32/Factorization/UserLU.cs

@ -162,7 +162,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.
@ -243,7 +243,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.

4
src/Numerics/LinearAlgebra/Complex32/Factorization/UserQR.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -297,7 +297,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var inputCopy = input.Clone();

2
src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs

@ -903,7 +903,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var mn = Math.Min(MatrixU.RowCount, MatrixVT.ColumnCount);

4
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs

@ -259,7 +259,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -519,7 +519,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

2
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs

@ -613,7 +613,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs

@ -314,7 +314,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -630,7 +630,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs

@ -335,7 +335,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -796,7 +796,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs

@ -247,7 +247,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -525,7 +525,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix, result);
}
for (var column = 0; column < input.ColumnCount; column++)

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

@ -275,7 +275,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -337,7 +337,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -472,7 +472,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -535,7 +535,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -818,7 +818,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target, "target");
}
// Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
@ -1043,7 +1043,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
{
if (resultSparseMatrix.RowCount != RowCount + lowerSparseMatrix.RowCount || resultSparseMatrix.ColumnCount != ColumnCount + lowerSparseMatrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lowerSparseMatrix, resultSparseMatrix);
}
resultSparseMatrix.NonZerosCount = NonZerosCount + lowerSparseMatrix.NonZerosCount;
@ -1624,7 +1624,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Add(rightSide);
@ -1671,7 +1671,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Subtract(rightSide);
@ -1752,7 +1752,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Multiply(rightSide);

6
src/Numerics/LinearAlgebra/Double/DenseMatrix.cs

@ -684,7 +684,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Add(rightSide);
@ -731,7 +731,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Subtract(rightSide);
@ -812,7 +812,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Multiply(rightSide);

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

@ -295,7 +295,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<double> result;
@ -333,12 +333,12 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
}
var diagOther = other as DiagonalMatrix;
@ -370,7 +370,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<double> result;
@ -408,12 +408,12 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
}
var diagOther = other as DiagonalMatrix;
@ -539,14 +539,9 @@ namespace MathNet.Numerics.LinearAlgebra.Double
throw new ArgumentNullException("result");
}
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
if (ColumnCount != other.RowCount || result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
var m = other as DiagonalMatrix;
@ -583,7 +578,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var m = other as DiagonalMatrix;
@ -615,7 +610,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (ColumnCount != rightSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "rightSide");
throw DimensionsDontMatch<ArgumentException>(this, rightSide);
}
if (result == null)
@ -625,7 +620,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (RowCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(rightSide, result))
@ -665,7 +660,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (RowCount != leftSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "leftSide");
throw DimensionsDontMatch<ArgumentException>(this, leftSide, "leftSide");
}
if (result == null)
@ -675,7 +670,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(leftSide, result))
@ -764,7 +759,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (ColumnCount != otherDiagonal.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, otherDiagonal);
}
var result = (DiagonalMatrix)CreateMatrix(RowCount, other.RowCount);
@ -803,7 +798,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target, "target");
}
Buffer.BlockCopy(Data, 0, diagonalTarget.Data, 0, Data.Length * Constants.SizeOfDouble);
@ -1027,7 +1022,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -1067,7 +1062,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1097,7 +1092,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1132,7 +1127,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1367,7 +1362,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != (RowCount + lower.RowCount) || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lower, result);
}
// Clear the result matrix
@ -1499,7 +1494,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount + lower.RowCount || result.ColumnCount != ColumnCount + lower.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lower, result);
}
// Clear the result matrix

4
src/Numerics/LinearAlgebra/Double/Factorization/DenseCholesky.cs

@ -102,7 +102,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseMatrix;
@ -151,7 +151,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Double/Factorization/DenseGramSchmidt.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -201,7 +201,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Double/Factorization/DenseLU.cs

@ -104,7 +104,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseMatrix;
@ -153,7 +153,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Double/Factorization/DenseQR.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -157,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var dinput = input as DenseVector;

2
src/Numerics/LinearAlgebra/Double/Factorization/DenseSvd.cs

@ -160,7 +160,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Double/Factorization/UserCholesky.cs

@ -170,7 +170,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);
@ -231,7 +231,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);

4
src/Numerics/LinearAlgebra/Double/Factorization/UserGramSchmidt.cs

@ -60,7 +60,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -205,7 +205,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var inputCopy = input.Clone();

4
src/Numerics/LinearAlgebra/Double/Factorization/UserLU.cs

@ -161,7 +161,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.
@ -242,7 +242,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.

4
src/Numerics/LinearAlgebra/Double/Factorization/UserQR.cs

@ -62,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -297,7 +297,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var inputCopy = input.Clone();

2
src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs

@ -887,7 +887,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var mn = Math.Min(MatrixU.RowCount, MatrixVT.ColumnCount);

4
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs

@ -258,7 +258,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -518,7 +518,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

2
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs

@ -611,7 +611,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs

@ -313,7 +313,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -629,7 +629,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs

@ -335,7 +335,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -790,7 +790,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs

@ -246,7 +246,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -524,7 +524,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

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

@ -268,7 +268,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -330,7 +330,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -465,7 +465,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -528,7 +528,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -829,7 +829,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target, "target");
}
// Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
@ -1054,7 +1054,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
{
if (resultSparseMatrix.RowCount != RowCount + lowerSparseMatrix.RowCount || resultSparseMatrix.ColumnCount != ColumnCount + lowerSparseMatrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lowerSparseMatrix, resultSparseMatrix);
}
resultSparseMatrix.NonZerosCount = NonZerosCount + lowerSparseMatrix.NonZerosCount;
@ -1662,7 +1662,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Add(rightSide);
@ -1709,7 +1709,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Subtract(rightSide);
@ -1790,7 +1790,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Multiply(rightSide);

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

@ -62,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other);
}
var result = CreateMatrix(RowCount, ColumnCount);
@ -86,12 +86,12 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
}
DoAdd(other, result);
@ -122,7 +122,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other);
}
var result = CreateMatrix(RowCount, ColumnCount);
@ -146,7 +146,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other);
}
DoSubtract(other, result);
@ -326,7 +326,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (ColumnCount != rightSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "rightSide");
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
}
if (result == null)
@ -336,7 +336,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (RowCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(rightSide, result))
@ -390,7 +390,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (RowCount != leftSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "leftSide");
throw DimensionsDontMatch<ArgumentException>(this, leftSide, "leftSide");
}
if (result == null)
@ -400,7 +400,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(leftSide, result))
@ -446,14 +446,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
throw new ArgumentNullException("result");
}
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
if (ColumnCount != other.RowCount || result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
if (ReferenceEquals(this, result) || ReferenceEquals(other, result))
@ -481,10 +476,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
{
throw new ArgumentNullException("other");
}
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var result = CreateMatrix(RowCount, other.ColumnCount);
@ -520,14 +514,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
throw new ArgumentNullException("result");
}
if (ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if ((result.RowCount != RowCount) || (result.ColumnCount != other.RowCount))
if (ColumnCount != other.ColumnCount || result.RowCount != RowCount || result.ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
if (ReferenceEquals(this, result) || ReferenceEquals(other, result))
@ -558,7 +547,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var result = CreateMatrix(RowCount, other.RowCount);
@ -605,7 +594,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (RowCount != rightSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "rightSide");
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
}
if (result == null)
@ -615,7 +604,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(rightSide, result))
@ -658,14 +647,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
throw new ArgumentNullException("result");
}
if (RowCount != other.RowCount)
if (RowCount != other.RowCount || result.RowCount != ColumnCount || result.ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if ((result.RowCount != ColumnCount) || (result.ColumnCount != other.ColumnCount))
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
if (ReferenceEquals(this, result) || ReferenceEquals(other, result))
@ -696,7 +680,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (RowCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var result = CreateMatrix(ColumnCount, other.ColumnCount);
@ -737,7 +721,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, result);
}
DoNegate(result);
@ -774,7 +758,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return leftSide.Add(rightSide);
@ -821,7 +805,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return leftSide.Subtract(rightSide);
@ -902,7 +886,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return leftSide.Multiply(rightSide);
@ -958,7 +942,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "other");
throw DimensionsDontMatch<ArgumentException>(this, other, "other");
}
var result = CreateMatrix(RowCount, ColumnCount);
@ -987,14 +971,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
throw new ArgumentNullException("result");
}
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
DoPointwiseMultiply(other, result);
@ -1016,7 +995,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "other");
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var result = CreateMatrix(RowCount, ColumnCount);
@ -1052,14 +1031,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
throw new ArgumentNullException("result");
}
if (ColumnCount != other.ColumnCount || RowCount != other.RowCount)
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount || ColumnCount != other.ColumnCount || RowCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
}
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
DoPointwiseDivide(other, result);
@ -1098,7 +1072,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (ColumnCount != result.ColumnCount || RowCount != result.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result);
}
DoModulus(divisor, result);
@ -1288,7 +1262,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != (RowCount * other.RowCount) || result.ColumnCount != (ColumnCount * other.ColumnCount))
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, result);
}
for (var j = 0; j < ColumnCount; j++)
@ -1345,5 +1319,68 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
return ret;
}
#region Exceptions - possibly move elsewhere?
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Matrix<T> right, Matrix<T> result, string paramName = null)
where TException : Exception
{
var message = string.Format(Resources.ArgumentMatrixDimensions3, left.RowCount + "x" + left.ColumnCount, right.RowCount + "x" + right.ColumnCount, result.RowCount + "x" + result.ColumnCount);
return CreateException<TException>(message, paramName);
}
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Matrix<T> right, string paramName = null)
where TException : Exception
{
var message = string.Format(Resources.ArgumentMatrixDimensions2, left.RowCount + "x" + left.ColumnCount, right.RowCount + "x" + right.ColumnCount);
return CreateException<TException>(message, paramName);
}
public static Exception DimensionsDontMatch<TException>(Matrix<T> matrix)
where TException : Exception
{
var message = string.Format(Resources.ArgumentMatrixDimensions1, matrix.RowCount + "x" + matrix.ColumnCount);
return CreateException<TException>(message);
}
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Vector<T> right, Vector<T> result, string paramName = null)
where TException : Exception
{
return DimensionsDontMatch<TException>(left, right.ToColumnMatrix(), result.ToColumnMatrix(), paramName);
}
public static Exception DimensionsDontMatch<TException>(Matrix<T> left, Vector<T> right, string paramName = null)
where TException : Exception
{
return DimensionsDontMatch<TException>(left, right.ToColumnMatrix(), paramName);
}
public static Exception DimensionsDontMatch<TException>(Vector<T> left, Matrix<T> right, string paramName = null)
where TException : Exception
{
return DimensionsDontMatch<TException>(left.ToColumnMatrix(), right, paramName);
}
public static Exception DimensionsDontMatch<TException>(Vector<T> left, Vector<T> right, string paramName = null)
where TException : Exception
{
return DimensionsDontMatch<TException>(left.ToColumnMatrix(), right.ToColumnMatrix(), paramName);
}
private static Exception CreateException<TException>(string message, string paramName = null)
where TException : Exception
{
if (typeof(TException) == typeof(ArgumentException))
{
return new ArgumentException(message, paramName);
}
if (typeof(TException) == typeof(ArgumentOutOfRangeException))
{
return new ArgumentOutOfRangeException(paramName, message);
}
return new Exception(message);
}
#endregion
}
}

14
src/Numerics/LinearAlgebra/Generic/Matrix.cs

@ -280,7 +280,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target);
}
for (var i = 0; i < RowCount; i++)
@ -573,7 +573,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
for (var row = 0; row < RowCount; row++)
@ -619,7 +619,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
for (var row = 0; row < RowCount; row++)
@ -848,7 +848,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
for (var row = 0; row < RowCount; row++)
@ -895,7 +895,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
for (var row = 0; row < RowCount; row++)
@ -1717,7 +1717,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != (RowCount + lower.RowCount) || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
for (var i = 0; i < RowCount; i++)
@ -1779,7 +1779,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
if (result.RowCount != RowCount + lower.RowCount || result.ColumnCount != ColumnCount + lower.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
for (var i = 0; i < RowCount; i++)

6
src/Numerics/LinearAlgebra/Single/DenseMatrix.cs

@ -683,7 +683,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Add(rightSide);
@ -730,7 +730,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Subtract(rightSide);
@ -811,7 +811,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (DenseMatrix)leftSide.Multiply(rightSide);

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

@ -295,7 +295,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<float> result;
@ -333,12 +333,12 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
}
var diagOther = other as DiagonalMatrix;
@ -370,7 +370,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
Matrix<float> result;
@ -408,12 +408,12 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("other", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, other, "other");
}
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentOutOfRangeException("result", Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentOutOfRangeException>(this, result, "result");
}
var diagOther = other as DiagonalMatrix;
@ -539,14 +539,9 @@ namespace MathNet.Numerics.LinearAlgebra.Single
throw new ArgumentNullException("result");
}
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
}
if (result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
if (ColumnCount != other.RowCount || result.RowCount != RowCount || result.ColumnCount != other.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other, result);
}
var m = other as DiagonalMatrix;
@ -583,7 +578,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (ColumnCount != other.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, other);
}
var m = other as DiagonalMatrix;
@ -615,7 +610,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (ColumnCount != rightSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "rightSide");
throw DimensionsDontMatch<ArgumentException>(this, rightSide, "rightSide");
}
if (result == null)
@ -625,7 +620,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (RowCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(rightSide, result))
@ -665,7 +660,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (RowCount != leftSide.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "leftSide");
throw DimensionsDontMatch<ArgumentException>(this, leftSide, "leftSide");
}
if (result == null)
@ -675,7 +670,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(leftSide, result))
@ -764,7 +759,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (ColumnCount != otherDiagonal.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(this, otherDiagonal);
}
var result = (DiagonalMatrix)CreateMatrix(RowCount, other.RowCount);
@ -803,7 +798,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target, "target");
}
Buffer.BlockCopy(Data, 0, diagonalTarget.Data, 0, Data.Length * Constants.SizeOfFloat);
@ -1027,7 +1022,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -1067,7 +1062,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1097,7 +1092,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1132,7 +1127,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
result.Clear();
@ -1367,7 +1362,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != (RowCount + lower.RowCount) || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lower, result);
}
// Clear the result matrix
@ -1499,7 +1494,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount + lower.RowCount || result.ColumnCount != ColumnCount + lower.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lower, result);
}
// Clear the result matrix

4
src/Numerics/LinearAlgebra/Single/Factorization/DenseCholesky.cs

@ -102,7 +102,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseMatrix;
@ -151,7 +151,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Single/Factorization/DenseGramSchmidt.cs

@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -201,7 +201,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Single/Factorization/DenseLU.cs

@ -104,7 +104,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseMatrix;
@ -153,7 +153,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Single/Factorization/DenseQR.cs

@ -70,7 +70,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -157,7 +157,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var dinput = input as DenseVector;

2
src/Numerics/LinearAlgebra/Single/Factorization/DenseSvd.cs

@ -160,7 +160,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var dinput = input as DenseVector;

4
src/Numerics/LinearAlgebra/Single/Factorization/UserCholesky.cs

@ -170,7 +170,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.RowCount != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);
@ -231,7 +231,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.Count != CholeskyFactor.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, CholeskyFactor);
}
input.CopyTo(result);

4
src/Numerics/LinearAlgebra/Single/Factorization/UserGramSchmidt.cs

@ -60,7 +60,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixQ = matrix.Clone();
@ -205,7 +205,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check that x is a column vector with n entries
if (MatrixQ.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixQ, result);
}
var inputCopy = input.Clone();

4
src/Numerics/LinearAlgebra/Single/Factorization/UserLU.cs

@ -161,7 +161,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.RowCount != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.
@ -242,7 +242,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (input.Count != Factors.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, Factors);
}
// Copy the contents of input to result.

4
src/Numerics/LinearAlgebra/Single/Factorization/UserQR.cs

@ -62,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
if (matrix.RowCount < matrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix);
}
MatrixR = matrix.Clone();
@ -297,7 +297,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check that x is a column vector with n entries
if (MatrixR.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixR, result);
}
var inputCopy = input.Clone();

2
src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs

@ -887,7 +887,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization
// Check that x is a column vector with n entries
if (MatrixVT.ColumnCount != result.Count)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(MatrixVT, result);
}
var mn = Math.Min(MatrixU.RowCount, MatrixVT.ColumnCount);

4
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs

@ -258,7 +258,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -518,7 +518,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

2
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs

@ -613,7 +613,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs

@ -313,7 +313,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -629,7 +629,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs

@ -333,7 +333,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -792,7 +792,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

4
src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs

@ -246,7 +246,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (input.Count != matrix.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(input, matrix);
}
// Initialize the solver fields
@ -524,7 +524,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
if (matrix.RowCount != input.RowCount || input.RowCount != result.RowCount || input.ColumnCount != result.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw Matrix.DimensionsDontMatch<ArgumentException>(matrix, input, result);
}
for (var column = 0; column < input.ColumnCount; column++)

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

@ -269,7 +269,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -331,7 +331,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -466,7 +466,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -529,7 +529,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, result, "result");
}
if (ReferenceEquals(this, result))
@ -812,7 +812,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (RowCount != target.RowCount || ColumnCount != target.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "target");
throw DimensionsDontMatch<ArgumentException>(this, target, "target");
}
// Lets copy only needed data. Portion of needed data is determined by NonZerosCount value
@ -1037,7 +1037,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
{
if (resultSparseMatrix.RowCount != RowCount + lowerSparseMatrix.RowCount || resultSparseMatrix.ColumnCount != ColumnCount + lowerSparseMatrix.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions, "result");
throw DimensionsDontMatch<ArgumentException>(this, lowerSparseMatrix, resultSparseMatrix, "result");
}
resultSparseMatrix.NonZerosCount = NonZerosCount + lowerSparseMatrix.NonZerosCount;
@ -1645,7 +1645,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Add(rightSide);
@ -1692,7 +1692,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (leftSide.RowCount != rightSide.RowCount || leftSide.ColumnCount != rightSide.ColumnCount)
{
throw new ArgumentOutOfRangeException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Subtract(rightSide);
@ -1773,7 +1773,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single
if (leftSide.ColumnCount != rightSide.RowCount)
{
throw new ArgumentException(Resources.ArgumentMatrixDimensions);
throw DimensionsDontMatch<ArgumentException>(leftSide, rightSide);
}
return (SparseMatrix)leftSide.Multiply(rightSide);

1
src/Numerics/Numerics.csproj

@ -443,6 +443,7 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>

29
src/Numerics/Properties/Resources.Designer.cs

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.225
// Runtime Version:4.0.30319.239
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -159,6 +159,33 @@ namespace MathNet.Numerics.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Matrix dimensions must agree: {0}..
/// </summary>
internal static string ArgumentMatrixDimensions1 {
get {
return ResourceManager.GetString("ArgumentMatrixDimensions1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix dimensions must agree: op1 is {0}, op2 is {1}..
/// </summary>
internal static string ArgumentMatrixDimensions2 {
get {
return ResourceManager.GetString("ArgumentMatrixDimensions2", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Matrix dimensions must agree: op1 is {0}, op2 is {1}, op3 is {2}..
/// </summary>
internal static string ArgumentMatrixDimensions3 {
get {
return ResourceManager.GetString("ArgumentMatrixDimensions3", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The requested matrix does not exist..
/// </summary>

9
src/Numerics/Properties/Resources.resx

@ -138,6 +138,15 @@
<data name="ArgumentMatrixDimensions" xml:space="preserve">
<value>Matrix dimensions must agree.</value>
</data>
<data name="ArgumentMatrixDimensions1" xml:space="preserve">
<value>Matrix dimensions must agree: {0}.</value>
</data>
<data name="ArgumentMatrixDimensions2" xml:space="preserve">
<value>Matrix dimensions must agree: op1 is {0}, op2 is {1}.</value>
</data>
<data name="ArgumentMatrixDimensions3" xml:space="preserve">
<value>Matrix dimensions must agree: op1 is {0}, op2 is {1}, op3 is {2}.</value>
</data>
<data name="ArgumentMatrixSameRowDimension" xml:space="preserve">
<value>Matrix row dimensions must agree.</value>
</data>

Loading…
Cancel
Save