Browse Source

LA: Refactor away the remaining usages of the non-generic base classes

pull/163/head
Christoph Ruegg 13 years ago
parent
commit
7ec72961a9
  1. 2
      src/Examples/LinearAlgebra/MatrixRowColumnOperations.cs
  2. 16
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs
  3. 32
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs
  4. 22
      src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs
  5. 16
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs
  6. 32
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs
  7. 22
      src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs
  8. 24
      src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs
  9. 32
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs
  10. 22
      src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs
  11. 20
      src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs
  12. 22
      src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs
  13. 12
      src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs
  14. 14
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs
  15. 14
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs
  16. 14
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs
  17. 14
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs
  18. 2
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/DiagonalTest.cs
  19. 8
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs
  20. 10
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs
  21. 8
      src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs
  22. 22
      src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs
  23. 11
      src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrixTests.cs
  24. 22
      src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs
  25. 24
      src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs
  26. 12
      src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs
  27. 14
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs
  28. 14
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs
  29. 14
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs
  30. 14
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs
  31. 2
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/DiagonalTest.cs
  32. 16
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IluptElementSorterTest.cs
  33. 8
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs
  34. 10
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs
  35. 10
      src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs
  36. 24
      src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs
  37. 13
      src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrixTests.cs
  38. 21
      src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs
  39. 14
      src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs
  40. 13
      src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs
  41. 14
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs
  42. 14
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs
  43. 14
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs
  44. 14
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs
  45. 2
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/DiagonalTest.cs
  46. 16
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IluptElementSorterTest.cs
  47. 8
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs
  48. 10
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs
  49. 10
      src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs
  50. 23
      src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs
  51. 12
      src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrixTests.cs
  52. 21
      src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs
  53. 23
      src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs
  54. 12
      src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs
  55. 14
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs
  56. 14
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs
  57. 14
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs
  58. 14
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs
  59. 2
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/DiagonalTest.cs
  60. 16
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IluptElementSorterTest.cs
  61. 8
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs
  62. 4
      src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs
  63. 23
      src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs
  64. 12
      src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrixTests.cs

2
src/Examples/LinearAlgebra/MatrixRowColumnOperations.cs

@ -101,7 +101,7 @@ namespace Examples.LinearAlgebraExamples
Console.WriteLine();
// 3. Set column values
matrix.SetColumn(2, (Vector)vector);
matrix.SetColumn(2, vector);
Console.WriteLine(@"3. Set column values");
Console.WriteLine(matrix.ToString("#0.00\t", formatProvider));
Console.WriteLine();

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

@ -286,7 +286,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// Compute r_0 = b - Ax_0 for some initial guess x_0
// In this case we take x_0 = vector
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, result, input);
// Choose r~ (for example, r~ = r_0)
@ -295,13 +295,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// create seven temporary vectors needed to hold temporary
// coefficients. All vectors are mangled in each iteration.
// These are defined here to prevent stressing the garbage collector
Vector vecP = new DenseVector(residuals.Count);
Vector vecPdash = new DenseVector(residuals.Count);
Vector nu = new DenseVector(residuals.Count);
Vector vecS = new DenseVector(residuals.Count);
Vector vecSdash = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
var vecP = new DenseVector(residuals.Count);
var vecPdash = new DenseVector(residuals.Count);
var nu = new DenseVector(residuals.Count);
var vecS = new DenseVector(residuals.Count);
var vecSdash = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
// create some temporary double variables that are needed
// to hold values in between iterations

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

@ -329,11 +329,11 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// x_0 is initial guess
// Take x_0 = 0
Vector xtemp = new DenseVector(input.Count);
var xtemp = new DenseVector(input.Count);
// r_0 = b - Ax_0
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, xtemp, input);
// Define the temporary scalars
@ -341,26 +341,26 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// Define the temporary vectors
// rDash_0 = r_0
Vector rdash = DenseVector.OfVector(residuals);
var rdash = DenseVector.OfVector(residuals);
// t_-1 = 0
Vector t = new DenseVector(residuals.Count);
Vector t0 = new DenseVector(residuals.Count);
var t = new DenseVector(residuals.Count);
var t0 = new DenseVector(residuals.Count);
// w_-1 = 0
Vector w = new DenseVector(residuals.Count);
var w = new DenseVector(residuals.Count);
// Define the remaining temporary vectors
Vector c = new DenseVector(residuals.Count);
Vector p = new DenseVector(residuals.Count);
Vector s = new DenseVector(residuals.Count);
Vector u = new DenseVector(residuals.Count);
Vector y = new DenseVector(residuals.Count);
Vector z = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
Vector temp3 = new DenseVector(residuals.Count);
var c = new DenseVector(residuals.Count);
var p = new DenseVector(residuals.Count);
var s = new DenseVector(residuals.Count);
var u = new DenseVector(residuals.Count);
var y = new DenseVector(residuals.Count);
var z = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
var temp3 = new DenseVector(residuals.Count);
// for (k = 0, 1, .... )
var iterationNumber = 0;

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

@ -349,7 +349,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// Choose an initial guess x_0
// Take x_0 = 0
Vector xtemp = new DenseVector(input.Count);
var xtemp = new DenseVector(input.Count);
// Choose k vectors q_1, q_2, ..., q_k
// Build a new set if:
@ -378,24 +378,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative
// r_0 = b - Ax_0
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, xtemp, input);
// Define the temporary values
var c = new Complex[k];
// Define the temporary vectors
Vector gtemp = new DenseVector(residuals.Count);
var gtemp = new DenseVector(residuals.Count);
Vector u = new DenseVector(residuals.Count);
Vector utemp = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp1 = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
var u = new DenseVector(residuals.Count);
var utemp = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp1 = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
Vector zd = new DenseVector(residuals.Count);
Vector zg = new DenseVector(residuals.Count);
Vector zw = new DenseVector(residuals.Count);
var zd = new DenseVector(residuals.Count);
var zg = new DenseVector(residuals.Count);
var zw = new DenseVector(residuals.Count);
var d = CreateVectorArray(_startingVectors.Count, residuals.Count);

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

@ -280,7 +280,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// Compute r_0 = b - Ax_0 for some initial guess x_0
// In this case we take x_0 = vector
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, result, input);
// Choose r~ (for example, r~ = r_0)
@ -289,13 +289,13 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// create seven temporary vectors needed to hold temporary
// coefficients. All vectors are mangled in each iteration.
// These are defined here to prevent stressing the garbage collector
Vector vecP = new DenseVector(residuals.Count);
Vector vecPdash = new DenseVector(residuals.Count);
Vector nu = new DenseVector(residuals.Count);
Vector vecS = new DenseVector(residuals.Count);
Vector vecSdash = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
var vecP = new DenseVector(residuals.Count);
var vecPdash = new DenseVector(residuals.Count);
var nu = new DenseVector(residuals.Count);
var vecS = new DenseVector(residuals.Count);
var vecSdash = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
// create some temporary float variables that are needed
// to hold values in between iterations

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

@ -328,11 +328,11 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// x_0 is initial guess
// Take x_0 = 0
Vector xtemp = new DenseVector(input.Count);
var xtemp = new DenseVector(input.Count);
// r_0 = b - Ax_0
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, xtemp, input);
// Define the temporary scalars
@ -340,26 +340,26 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// Define the temporary vectors
// rDash_0 = r_0
Vector rdash = DenseVector.OfVector(residuals);
var rdash = DenseVector.OfVector(residuals);
// t_-1 = 0
Vector t = new DenseVector(residuals.Count);
Vector t0 = new DenseVector(residuals.Count);
var t = new DenseVector(residuals.Count);
var t0 = new DenseVector(residuals.Count);
// w_-1 = 0
Vector w = new DenseVector(residuals.Count);
var w = new DenseVector(residuals.Count);
// Define the remaining temporary vectors
Vector c = new DenseVector(residuals.Count);
Vector p = new DenseVector(residuals.Count);
Vector s = new DenseVector(residuals.Count);
Vector u = new DenseVector(residuals.Count);
Vector y = new DenseVector(residuals.Count);
Vector z = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
Vector temp3 = new DenseVector(residuals.Count);
var c = new DenseVector(residuals.Count);
var p = new DenseVector(residuals.Count);
var s = new DenseVector(residuals.Count);
var u = new DenseVector(residuals.Count);
var y = new DenseVector(residuals.Count);
var z = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
var temp3 = new DenseVector(residuals.Count);
// for (k = 0, 1, .... )
var iterationNumber = 0;

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

@ -348,7 +348,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// Choose an initial guess x_0
// Take x_0 = 0
Vector xtemp = new DenseVector(input.Count);
var xtemp = new DenseVector(input.Count);
// Choose k vectors q_1, q_2, ..., q_k
// Build a new set if:
@ -377,24 +377,24 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative
// r_0 = b - Ax_0
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, xtemp, input);
// Define the temporary values
var c = new Complex32[k];
// Define the temporary vectors
Vector gtemp = new DenseVector(residuals.Count);
var gtemp = new DenseVector(residuals.Count);
Vector u = new DenseVector(residuals.Count);
Vector utemp = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp1 = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
var u = new DenseVector(residuals.Count);
var utemp = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp1 = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
Vector zd = new DenseVector(residuals.Count);
Vector zg = new DenseVector(residuals.Count);
Vector zw = new DenseVector(residuals.Count);
var zd = new DenseVector(residuals.Count);
var zg = new DenseVector(residuals.Count);
var zw = new DenseVector(residuals.Count);
var d = CreateVectorArray(_startingVectors.Count, residuals.Count);

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

@ -352,7 +352,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
// Choose an initial guess x_0
// Take x_0 = 0
Vector xtemp = new DenseVector(input.Count);
var xtemp = new DenseVector(input.Count);
// Choose k vectors q_1, q_2, ..., q_k
// Build a new set if:
@ -381,24 +381,24 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
// r_0 = b - Ax_0
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, xtemp, input);
// Define the temporary scalars
var c = new double[k];
// Define the temporary vectors
Vector gtemp = new DenseVector(residuals.Count);
var gtemp = new DenseVector(residuals.Count);
Vector u = new DenseVector(residuals.Count);
Vector utemp = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp1 = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
var u = new DenseVector(residuals.Count);
var utemp = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp1 = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
Vector zd = new DenseVector(residuals.Count);
Vector zg = new DenseVector(residuals.Count);
Vector zw = new DenseVector(residuals.Count);
var zd = new DenseVector(residuals.Count);
var zg = new DenseVector(residuals.Count);
var zw = new DenseVector(residuals.Count);
var d = CreateVectorArray(_startingVectors.Count, residuals.Count);
@ -793,7 +793,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative
for (var column = 0; column < input.ColumnCount; column++)
{
var solution = Solve(matrix, (Vector)input.Column(column));
var solution = Solve(matrix, input.Column(column));
foreach (var element in solution.EnumerateNonZeroIndexed())
{
result.At(element.Item1, column, element.Item2);

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

@ -326,11 +326,11 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
// x_0 is initial guess
// Take x_0 = 0
Vector xtemp = new DenseVector(input.Count);
var xtemp = new DenseVector(input.Count);
// r_0 = b - Ax_0
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, xtemp, input);
// Define the temporary scalars
@ -338,26 +338,26 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
// Define the temporary vectors
// rDash_0 = r_0
Vector rdash = DenseVector.OfVector(residuals);
var rdash = DenseVector.OfVector(residuals);
// t_-1 = 0
Vector t = new DenseVector(residuals.Count);
Vector t0 = new DenseVector(residuals.Count);
var t = new DenseVector(residuals.Count);
var t0 = new DenseVector(residuals.Count);
// w_-1 = 0
Vector w = new DenseVector(residuals.Count);
var w = new DenseVector(residuals.Count);
// Define the remaining temporary vectors
Vector c = new DenseVector(residuals.Count);
Vector p = new DenseVector(residuals.Count);
Vector s = new DenseVector(residuals.Count);
Vector u = new DenseVector(residuals.Count);
Vector y = new DenseVector(residuals.Count);
Vector z = new DenseVector(residuals.Count);
var c = new DenseVector(residuals.Count);
var p = new DenseVector(residuals.Count);
var s = new DenseVector(residuals.Count);
var u = new DenseVector(residuals.Count);
var y = new DenseVector(residuals.Count);
var z = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
Vector temp3 = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
var temp3 = new DenseVector(residuals.Count);
// for (k = 0, 1, .... )
var iterationNumber = 0;
@ -628,7 +628,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
for (var column = 0; column < input.ColumnCount; column++)
{
var solution = Solve(matrix, (Vector) input.Column(column));
var solution = Solve(matrix, input.Column(column));
foreach (var element in solution.EnumerateNonZeroIndexed())
{
result.At(element.Item1, column, element.Item2);

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

@ -351,7 +351,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
// Choose an initial guess x_0
// Take x_0 = 0
Vector xtemp = new DenseVector(input.Count);
var xtemp = new DenseVector(input.Count);
// Choose k vectors q_1, q_2, ..., q_k
// Build a new set if:
@ -380,24 +380,24 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative
// r_0 = b - Ax_0
// This is basically a SAXPY so it could be made a lot faster
Vector residuals = new DenseVector(matrix.RowCount);
var residuals = new DenseVector(matrix.RowCount);
CalculateTrueResidual(matrix, residuals, xtemp, input);
// Define the temporary scalars
var c = new float[k];
// Define the temporary vectors
Vector gtemp = new DenseVector(residuals.Count);
var gtemp = new DenseVector(residuals.Count);
Vector u = new DenseVector(residuals.Count);
Vector utemp = new DenseVector(residuals.Count);
Vector temp = new DenseVector(residuals.Count);
Vector temp1 = new DenseVector(residuals.Count);
Vector temp2 = new DenseVector(residuals.Count);
var u = new DenseVector(residuals.Count);
var utemp = new DenseVector(residuals.Count);
var temp = new DenseVector(residuals.Count);
var temp1 = new DenseVector(residuals.Count);
var temp2 = new DenseVector(residuals.Count);
Vector zd = new DenseVector(residuals.Count);
Vector zg = new DenseVector(residuals.Count);
Vector zw = new DenseVector(residuals.Count);
var zd = new DenseVector(residuals.Count);
var zg = new DenseVector(residuals.Count);
var zw = new DenseVector(residuals.Count);
var d = CreateVectorArray(_startingVectors.Count, residuals.Count);

20
src/UnitTests/LinearAlgebraTests/Complex/DenseMatrixTests.cs

@ -28,13 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Complex;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
using System;
using System.Collections.Generic;
using System.Numerics;
using LinearAlgebra.Complex;
using NUnit.Framework;
/// <summary>
/// Dense matrix tests.
@ -47,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex> CreateMatrix(int rows, int columns)
{
return new DenseMatrix(rows, columns);
}
@ -57,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex[,] data)
protected override Matrix<Complex> CreateMatrix(Complex[,] data)
{
return DenseMatrix.OfArray(data);
}
@ -68,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex> CreateVector(int size)
{
return new DenseVector(size);
}
@ -78,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex[] data)
protected override Vector<Complex> CreateVector(Complex[] data)
{
return new DenseVector(data);
}
@ -89,7 +91,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<Complex>>
{
{"Singular3x3", new DenseMatrix(3, 3, new[] {new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1), new Complex(2.0, 1), new Complex(2.0, 1)})},
{"Square3x3", new DenseMatrix(3, 3, new[] {new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.6, 1)})},

22
src/UnitTests/LinearAlgebraTests/Complex/DiagonalMatrixTests.cs

@ -28,13 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Complex;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
using System;
using System.Collections.Generic;
using System.Numerics;
using LinearAlgebra.Complex;
using NUnit.Framework;
/// <summary>
/// Diagonal matrix tests.
@ -57,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{"Wide2x3", new[,] {{new Complex(-1.1, 1), Complex.Zero, Complex.Zero}, {Complex.Zero, new Complex(1.1, 1), Complex.Zero}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<Complex>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));
@ -70,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex> CreateMatrix(int rows, int columns)
{
return new DiagonalMatrix(rows, columns);
}
@ -80,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex[,] data)
protected override Matrix<Complex> CreateMatrix(Complex[,] data)
{
return DiagonalMatrix.OfArray(data);
}
@ -91,7 +93,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex> CreateVector(int size)
{
return new SparseVector(size);
}
@ -101,7 +103,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex[] data)
protected override Vector<Complex> CreateVector(Complex[] data)
{
return SparseVector.OfEnumerable(data);
}
@ -112,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void CanCreateMatrixFromDiagonalArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<Complex>>
{
{"Singular3x3", new DiagonalMatrix(3, 3, new[] {new Complex(1.0, 1), Complex.Zero, new Complex(3.0, 1)})},
{"Square3x3", new DiagonalMatrix(3, 3, new[] {new Complex(-1.1, 1), new Complex(1.1, 1), new Complex(6.6, 1)})},

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

@ -52,7 +52,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices { get; set; }
protected Dictionary<string, Matrix<Complex>> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -60,14 +60,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected abstract Matrix CreateMatrix(int rows, int columns);
protected abstract Matrix<Complex> CreateMatrix(int rows, int columns);
/// <summary>
/// Creates a matrix from a 2D array.
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected abstract Matrix CreateMatrix(Complex[,] data);
protected abstract Matrix<Complex> CreateMatrix(Complex[,] data);
/// <summary>
/// Creates a vector of the given size.
@ -75,14 +75,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(int size);
protected abstract Vector<Complex> CreateVector(int size);
/// <summary>
/// Creates a vector from an array.
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(Complex[] data);
protected abstract Vector<Complex> CreateVector(Complex[] data);
/// <summary>
/// Setup test matrices.
@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{"Symmetric3x3", new[,] {{Complex.One, 2.0, 3.0}, {2.0, 2.0, 0.0}, {3.0, 0.0, 3.0}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<Complex>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));

14
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/BiCgStabTest.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -89,10 +89,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => Complex.One);
var y = DenseVector.Create(matrix.RowCount, i => Complex.One);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -131,13 +131,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(new Complex(Math.PI, Math.PI), matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => Complex.One);
var y = DenseVector.Create(matrix.RowCount, i => Complex.One);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -215,7 +215,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => Complex.One);
var y = DenseVector.Create(matrix.RowCount, i => Complex.One);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/GpBiCgTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -129,13 +129,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/MlkBiCgStabTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -130,13 +130,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Iterative/TFQMRTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -130,13 +130,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Iterativ
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

2
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/DiagonalTest.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)

8
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IlutpTest.cs

@ -179,7 +179,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)
{
@ -205,7 +205,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
_fillLevel = 100;
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}
@ -226,7 +226,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
_fillLevel = 100;
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}
@ -347,7 +347,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
FillLevel = 10
};
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}

10
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/IncompleteLUTest.cs

@ -72,9 +72,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix GetUpperTriangle(IncompleteLU ilu)
private static Matrix<Complex> GetUpperTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "UpperTriangle");
return GetMethod<Matrix<Complex>>(ilu, "UpperTriangle");
}
/// <summary>
@ -82,9 +82,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix GetLowerTriangle(IncompleteLU ilu)
private static Matrix<Complex> GetLowerTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "LowerTriangle");
return GetMethod<Matrix<Complex>>(ilu, "LowerTriangle");
}
/// <summary>
@ -109,7 +109,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)

8
src/UnitTests/LinearAlgebraTests/Complex/Solvers/Preconditioners/PreConditionerTest.cs

@ -70,9 +70,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
/// </summary>
/// <param name="size">Size of the vector.</param>
/// <returns>New vector.</returns>
protected Vector CreateStandardBcVector(int size)
protected DenseVector CreateStandardBcVector(int size)
{
Vector vector = new DenseVector(size);
var vector = new DenseVector(size);
for (var i = 0; i < size; i++)
{
vector[i] = i + 1;
@ -164,7 +164,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count + 10);
var result = new DenseVector(vector.Count + 10);
Assert.Throws<ArgumentNullException>(() => preconditioner.Approximate(null, result));
}
@ -181,7 +181,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex.Solvers.Precondi
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = null;
Vector<Complex> result = null;
Assert.Throws<ArgumentNullException>(() => preconditioner.Approximate(vector, result));
}

22
src/UnitTests/LinearAlgebraTests/Complex/SparseMatrixTests.cs

@ -28,12 +28,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Complex;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
using LinearAlgebra.Complex;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Numerics;
/// <summary>
@ -47,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex> CreateMatrix(int rows, int columns)
{
return new SparseMatrix(rows, columns);
}
@ -57,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex[,] data)
protected override Matrix<Complex> CreateMatrix(Complex[,] data)
{
return SparseMatrix.OfArray(data);
}
@ -68,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex> CreateVector(int size)
{
return new SparseVector(size);
}
@ -78,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex[] data)
protected override Vector<Complex> CreateVector(Complex[] data)
{
return SparseVector.OfEnumerable(data);
}
@ -89,7 +91,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<Complex>>
{
{"Singular3x3", SparseMatrix.OfColumnMajor(3, 3, new[] {new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1), new Complex(2.0, 1), new Complex(2.0, 1)})},
{"Square3x3", SparseMatrix.OfColumnMajor(3, 3, new[] {new Complex(-1.1, 1), Complex.Zero, new Complex(-4.4, 1), new Complex(-2.2, 1), new Complex(1.1, 1), new Complex(5.5, 1), new Complex(-3.3, 1), new Complex(2.2, 1), new Complex(6.6, 1)})},
@ -185,7 +187,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
var matrix = new SparseMatrix(500, 1000);
var nonzero = 0;
var rnd = new Random();
var rnd = new System.Random();
for (var i = 0; i < matrix.RowCount; i++)
{

11
src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrixTests.cs

@ -24,10 +24,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
using System.Numerics;
using LinearAlgebra.Complex;
/// <summary>
/// Test class for user-defined matrix.
@ -40,7 +41,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex> CreateMatrix(int rows, int columns)
{
return new UserDefinedMatrix(rows, columns);
}
@ -50,7 +51,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex[,] data)
protected override Matrix<Complex> CreateMatrix(Complex[,] data)
{
return new UserDefinedMatrix(data);
}
@ -61,7 +62,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex> CreateVector(int size)
{
return new UserDefinedVector(size);
}
@ -71,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex[] data)
protected override Vector<Complex> CreateVector(Complex[] data)
{
return new UserDefinedVector(data);
}

22
src/UnitTests/LinearAlgebraTests/Complex32/DenseMatrixTests.cs

@ -28,13 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Complex32;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
using LinearAlgebra.Complex32;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Complex32 = Numerics.Complex32;
using Numerics;
/// <summary>
/// Dense matrix tests.
@ -47,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex32> CreateMatrix(int rows, int columns)
{
return new DenseMatrix(rows, columns);
}
@ -57,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex32[,] data)
protected override Matrix<Complex32> CreateMatrix(Complex32[,] data)
{
return DenseMatrix.OfArray(data);
}
@ -68,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex32> CreateVector(int size)
{
return new DenseVector(size);
}
@ -78,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex32[] data)
protected override Vector<Complex32> CreateVector(Complex32[] data)
{
return new DenseVector(data);
}
@ -89,7 +91,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<Complex32>>
{
{"Singular3x3", new DenseMatrix(3, 3, new[] {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1)})},
{"Square3x3", new DenseMatrix(3, 3, new[] {new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.6f, 1)})},

24
src/UnitTests/LinearAlgebraTests/Complex32/DiagonalMatrixTests.cs

@ -28,13 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Complex32;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
using LinearAlgebra.Complex32;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Complex32 = Numerics.Complex32;
using Numerics;
/// <summary>
/// Diagonal matrix tests.
@ -57,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{"Wide2x3", new[,] {{new Complex32(-1.1f, 1), Complex32.Zero, Complex32.Zero}, {Complex32.Zero, new Complex32(1.1f, 1), Complex32.Zero}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<Complex32>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));
@ -70,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex32> CreateMatrix(int rows, int columns)
{
return new DiagonalMatrix(rows, columns);
}
@ -80,7 +82,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex32[,] data)
protected override Matrix<Complex32> CreateMatrix(Complex32[,] data)
{
return DiagonalMatrix.OfArray(data);
}
@ -91,7 +93,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex32> CreateVector(int size)
{
return new SparseVector(size);
}
@ -101,7 +103,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex32[] data)
protected override Vector<Complex32> CreateVector(Complex32[] data)
{
return SparseVector.OfEnumerable(data);
}
@ -112,7 +114,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void CanCreateMatrixFromDiagonalArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<Complex32>>
{
{"Singular3x3", new DiagonalMatrix(3, 3, new[] {new Complex32(1.0f, 1), Complex32.Zero, new Complex32(3.0f, 1)})},
{"Square3x3", new DiagonalMatrix(3, 3, new[] {new Complex32(-1.1f, 1), new Complex32(1.1f, 1), new Complex32(6.6f, 1)})},

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

@ -52,7 +52,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices { get; set; }
protected Dictionary<string, Matrix<Complex32>> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -60,14 +60,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected abstract Matrix CreateMatrix(int rows, int columns);
protected abstract Matrix<Complex32> CreateMatrix(int rows, int columns);
/// <summary>
/// Creates a matrix from a 2D array.
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected abstract Matrix CreateMatrix(Complex32[,] data);
protected abstract Matrix<Complex32> CreateMatrix(Complex32[,] data);
/// <summary>
/// Creates a vector of the given size.
@ -75,14 +75,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(int size);
protected abstract Vector<Complex32> CreateVector(int size);
/// <summary>
/// Creates a vector from an array.
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(Complex32[] data);
protected abstract Vector<Complex32> CreateVector(Complex32[] data);
/// <summary>
/// Setup test matrices.
@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{"Symmetric3x3", new[,] {{Complex32.One, 2.0f, 3.0f}, {2.0f, 2.0f, 0.0f}, {3.0f, 0.0f, 3.0f}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<Complex32>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));

14
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/BiCgStabTest.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -76,7 +76,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -89,10 +89,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => Complex32.One);
var y = DenseVector.Create(matrix.RowCount, i => Complex32.One);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -131,13 +131,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(new Complex32((float) Math.PI, (float) Math.PI), matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => Complex32.One);
var y = DenseVector.Create(matrix.RowCount, i => Complex32.One);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -215,7 +215,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => Complex32.One);
var y = DenseVector.Create(matrix.RowCount, i => Complex32.One);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/GpBiCgTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -129,13 +129,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply((float) Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/MlkBiCgStabTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -130,13 +130,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply((float) Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Iterative/TFQMRTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -130,13 +130,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply((float) Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Iterat
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

2
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/DiagonalTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)
{

16
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IluptElementSorterTest.cs

@ -177,7 +177,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithIncreasingDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -207,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithDecreasingDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 9;
values[1] = 8;
values[2] = 7;
@ -237,7 +237,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithRandomDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 5;
values[1] = 2;
values[2] = 8;
@ -299,7 +299,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithDuplicateDoubleEntries()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 1;
values[1] = 1;
values[2] = 1;
@ -363,7 +363,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithSpecialConstructedDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 0;
values[2] = 0;
@ -472,7 +472,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithIncreasingDoubleArrayWithLowerBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -502,7 +502,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithIncreasingDoubleArrayWithUpperBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -532,7 +532,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
public void HeapSortWithIncreasingDoubleArrayWithLowerAndUpperBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;

8
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IlutpTest.cs

@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)
{
@ -200,7 +200,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
_fillLevel = 100;
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}
@ -221,7 +221,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
_fillLevel = 100;
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}
@ -342,7 +342,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
FillLevel = 10
};
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}

10
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/IncompleteLUTest.cs

@ -67,9 +67,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix GetUpperTriangle(IncompleteLU ilu)
private static Matrix<Complex32> GetUpperTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "UpperTriangle");
return GetMethod<Matrix<Complex32>>(ilu, "UpperTriangle");
}
/// <summary>
@ -77,9 +77,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix GetLowerTriangle(IncompleteLU ilu)
private static Matrix<Complex32> GetLowerTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "LowerTriangle");
return GetMethod<Matrix<Complex32>>(ilu, "LowerTriangle");
}
/// <summary>
@ -104,7 +104,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)

10
src/UnitTests/LinearAlgebraTests/Complex32/Solvers/Preconditioners/PreConditionerTest.cs

@ -56,7 +56,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
{
matrix[i, i] = 2;
}
return matrix;
}
@ -65,14 +64,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
/// </summary>
/// <param name="size">Size of the vector.</param>
/// <returns>New vector.</returns>
protected Vector CreateStandardBcVector(int size)
protected DenseVector CreateStandardBcVector(int size)
{
Vector vector = new DenseVector(size);
var vector = new DenseVector(size);
for (var i = 0; i < size; i++)
{
vector[i] = i + 1;
}
return vector;
}
@ -159,7 +157,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count + 10);
var result = new DenseVector(vector.Count + 10);
Assert.Throws<ArgumentNullException>(() => preconditioner.Approximate(null, result));
}
@ -176,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32.Solvers.Precon
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = null;
Vector<Complex32> result = null;
Assert.Throws<ArgumentNullException>(() => preconditioner.Approximate(vector, result));
}

24
src/UnitTests/LinearAlgebraTests/Complex32/SparseMatrixTests.cs

@ -28,13 +28,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Complex32;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
using LinearAlgebra.Complex32;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Complex32 = Numerics.Complex32;
using Numerics;
/// <summary>
/// Sparse matrix tests.
@ -47,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex32> CreateMatrix(int rows, int columns)
{
return new SparseMatrix(rows, columns);
}
@ -57,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex32[,] data)
protected override Matrix<Complex32> CreateMatrix(Complex32[,] data)
{
return SparseMatrix.OfArray(data);
}
@ -68,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex32> CreateVector(int size)
{
return new SparseVector(size);
}
@ -78,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex32[] data)
protected override Vector<Complex32> CreateVector(Complex32[] data)
{
return SparseVector.OfEnumerable(data);
}
@ -89,7 +91,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<Complex32>>
{
{"Singular3x3", SparseMatrix.OfColumnMajor(3, 3, new[] {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1), new Complex32(2.0f, 1)})},
{"Square3x3", SparseMatrix.OfColumnMajor(3, 3, new[] {new Complex32(-1.1f, 1), Complex32.Zero, new Complex32(-4.4f, 1), new Complex32(-2.2f, 1), new Complex32(1.1f, 1), new Complex32(5.5f, 1), new Complex32(-3.3f, 1), new Complex32(2.2f, 1), new Complex32(6.6f, 1)})},
@ -185,7 +187,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
var matrix = new SparseMatrix(500, 1000);
var nonzero = 0;
var rnd = new Random();
var rnd = new System.Random();
for (var i = 0; i < matrix.RowCount; i++)
{

13
src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrixTests.cs

@ -24,10 +24,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
using LinearAlgebra.Complex32;
using Complex32 = Numerics.Complex32;
using Numerics;
/// <summary>
/// Test class for user-defined matrix.
@ -40,7 +41,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<Complex32> CreateMatrix(int rows, int columns)
{
return new UserDefinedMatrix(rows, columns);
}
@ -50,7 +51,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(Complex32[,] data)
protected override Matrix<Complex32> CreateMatrix(Complex32[,] data)
{
return new UserDefinedMatrix(data);
}
@ -61,7 +62,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<Complex32> CreateVector(int size)
{
return new UserDefinedVector(size);
}
@ -71,7 +72,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(Complex32[] data)
protected override Vector<Complex32> CreateVector(Complex32[] data)
{
return new UserDefinedVector(data);
}

21
src/UnitTests/LinearAlgebraTests/Double/DenseMatrixTests.cs

@ -28,13 +28,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
using LinearAlgebra.Double;
using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary>
/// Dense matrix tests.
/// </summary>
@ -46,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<double> CreateMatrix(int rows, int columns)
{
return new DenseMatrix(rows, columns);
}
@ -56,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(double[,] data)
protected override Matrix<double> CreateMatrix(double[,] data)
{
return DenseMatrix.OfArray(data);
}
@ -67,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<double> CreateVector(int size)
{
return new DenseVector(size);
}
@ -77,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(double[] data)
protected override Vector<double> CreateVector(double[] data)
{
return new DenseVector(data);
}
@ -88,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<double>>
{
{"Singular3x3", new DenseMatrix(3, 3, new[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0})},
{"Square3x3", new DenseMatrix(3, 3, new[] {-1.1, 0.0, -4.4, -2.2, 1.1, 5.5, -3.3, 2.2, 6.6})},

14
src/UnitTests/LinearAlgebraTests/Double/DiagonalMatrixTests.cs

@ -28,11 +28,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using NUnit.Framework;
using System;
using System.Collections.Generic;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
@ -57,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{"Wide2x3", new[,] {{-1.1, 0.0, 0.0}, {0.0, 1.1, 0.0}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<double>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));
@ -70,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<double> CreateMatrix(int rows, int columns)
{
return new DiagonalMatrix(rows, columns);
}
@ -80,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(double[,] data)
protected override Matrix<double> CreateMatrix(double[,] data)
{
return DiagonalMatrix.OfArray(data);
}
@ -91,7 +91,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<double> CreateVector(int size)
{
return new DenseVector(size);
}
@ -101,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(double[] data)
protected override Vector<double> CreateVector(double[] data)
{
return new DenseVector(data);
}

13
src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs

@ -29,7 +29,6 @@
// </copyright>
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
@ -51,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices { get; set; }
protected Dictionary<string, Matrix<double>> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -59,14 +58,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected abstract Matrix CreateMatrix(int rows, int columns);
protected abstract Matrix<double> CreateMatrix(int rows, int columns);
/// <summary>
/// Creates a matrix from a 2D array.
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected abstract Matrix CreateMatrix(double[,] data);
protected abstract Matrix<double> CreateMatrix(double[,] data);
/// <summary>
/// Creates a vector of the given size.
@ -74,14 +73,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(int size);
protected abstract Vector<double> CreateVector(int size);
/// <summary>
/// Creates a vector from an array.
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(double[] data);
protected abstract Vector<double> CreateVector(double[] data);
/// <summary>
/// Setup test matrices.
@ -100,7 +99,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{"Symmetric3x3", new[,] {{1.0, 2.0, 3.0}, {2.0, 2.0, 0.0}, {3.0, 0.0, 3.0}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<double>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));

14
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/BiCgStabTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -129,13 +129,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -213,7 +213,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/GpBiCgTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -129,13 +129,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/MlkBiCgStabTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -130,13 +130,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Double/Solvers/Iterative/TFQMRTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -130,13 +130,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply(Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

2
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/DiagonalTest.cs

@ -59,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)
{

16
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IluptElementSorterTest.cs

@ -177,7 +177,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -207,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithDecreasingDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 9;
values[1] = 8;
values[2] = 7;
@ -237,7 +237,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithRandomDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 5;
values[1] = 2;
values[2] = 8;
@ -299,7 +299,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithDuplicateDoubleEntries()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 1;
values[1] = 1;
values[2] = 1;
@ -363,7 +363,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithSpecialConstructedDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 0;
values[2] = 0;
@ -472,7 +472,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArrayWithLowerBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -502,7 +502,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArrayWithUpperBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -532,7 +532,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArrayWithLowerAndUpperBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;

8
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IlutpTest.cs

@ -172,7 +172,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)
{
@ -197,7 +197,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
_fillLevel = 100;
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}
@ -218,7 +218,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
_fillLevel = 100;
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}
@ -337,7 +337,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
FillLevel = 10
};
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count);
var result = new DenseVector(vector.Count);
preconditioner.Approximate(vector, result);
CheckResult(preconditioner, newMatrix, vector, result);
}

10
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/IncompleteLUTest.cs

@ -65,9 +65,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix GetUpperTriangle(IncompleteLU ilu)
private static Matrix<double> GetUpperTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "UpperTriangle");
return GetMethod<Matrix<double>>(ilu, "UpperTriangle");
}
/// <summary>
@ -75,9 +75,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix GetLowerTriangle(IncompleteLU ilu)
private static Matrix<double> GetLowerTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "LowerTriangle");
return GetMethod<Matrix<double>>(ilu, "LowerTriangle");
}
/// <summary>
@ -102,7 +102,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)

10
src/UnitTests/LinearAlgebraTests/Double/Solvers/Preconditioners/PreConditionerTest.cs

@ -54,7 +54,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
{
matrix[i, i] = 2;
}
return matrix;
}
@ -63,14 +62,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
/// </summary>
/// <param name="size">Size of the vector.</param>
/// <returns>New vector.</returns>
protected Vector CreateStandardBcVector(int size)
protected DenseVector CreateStandardBcVector(int size)
{
Vector vector = new DenseVector(size);
var vector = new DenseVector(size);
for (var i = 0; i < size; i++)
{
vector[i] = i + 1;
}
return vector;
}
@ -157,7 +155,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = new DenseVector(vector.Count + 10);
var result = new DenseVector(vector.Count + 10);
Assert.Throws<ArgumentNullException>(() => preconditioner.Approximate(null, result));
}
@ -174,7 +172,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double.Solvers.Precondit
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = null;
Vector<double> result = null;
Assert.Throws<ArgumentNullException>(() => preconditioner.Approximate(vector, result));
}

23
src/UnitTests/LinearAlgebraTests/Double/SparseMatrixTests.cs

@ -28,13 +28,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
using LinearAlgebra.Double;
using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary>
/// Sparse matrix tests.
/// </summary>
@ -46,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<double> CreateMatrix(int rows, int columns)
{
return new SparseMatrix(rows, columns);
}
@ -56,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(double[,] data)
protected override Matrix<double> CreateMatrix(double[,] data)
{
return SparseMatrix.OfArray(data);
}
@ -67,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<double> CreateVector(int size)
{
return new SparseVector(size);
}
@ -77,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(double[] data)
protected override Vector<double> CreateVector(double[] data)
{
return SparseVector.OfEnumerable(data);
}
@ -88,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<double>>
{
{"Singular3x3", SparseMatrix.OfColumnMajor(3, 3, new double[] {1, 1, 1, 1, 1, 1, 2, 2, 2})},
{"Square3x3", SparseMatrix.OfColumnMajor(3, 3, new[] {-1.1, 0.0, -4.4, -2.2, 1.1, 5.5, -3.3, 2.2, 6.6})},
@ -184,7 +185,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
var matrix = new SparseMatrix(500, 1000);
var nonzero = 0;
var rnd = new Random();
var rnd = new System.Random();
for (var i = 0; i < matrix.RowCount; i++)
{

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

@ -24,10 +24,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
using LinearAlgebra.Double;
/// <summary>
/// Test class for user-defined matrix.
/// </summary>
@ -39,7 +39,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<double> CreateMatrix(int rows, int columns)
{
return new UserDefinedMatrix(rows, columns);
}
@ -49,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(double[,] data)
protected override Matrix<double> CreateMatrix(double[,] data)
{
return new UserDefinedMatrix(data);
}
@ -60,7 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<double> CreateVector(int size)
{
return new UserDefinedVector(size);
}
@ -70,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(double[] data)
protected override Vector<double> CreateVector(double[] data)
{
return new UserDefinedVector(data);
}

21
src/UnitTests/LinearAlgebraTests/Single/DenseMatrixTests.cs

@ -28,13 +28,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Single;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
using LinearAlgebra.Single;
using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary>
/// Dense matrix tests.
/// </summary>
@ -46,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<float> CreateMatrix(int rows, int columns)
{
return new DenseMatrix(rows, columns);
}
@ -56,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(float[,] data)
protected override Matrix<float> CreateMatrix(float[,] data)
{
return DenseMatrix.OfArray(data);
}
@ -67,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<float> CreateVector(int size)
{
return new DenseVector(size);
}
@ -77,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(float[] data)
protected override Vector<float> CreateVector(float[] data)
{
return new DenseVector(data);
}
@ -88,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<float>>
{
{"Singular3x3", new DenseMatrix(3, 3, new[] {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f})},
{"Square3x3", new DenseMatrix(3, 3, new[] {-1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f, -3.3f, 2.2f, 6.6f})},

23
src/UnitTests/LinearAlgebraTests/Single/DiagonalMatrixTests.cs

@ -28,13 +28,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Single;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
using LinearAlgebra.Single;
using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary>
/// Diagonal matrix tests.
/// </summary>
@ -56,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{"Wide2x3", new[,] {{-1.1f, 0.0f, 0.0f}, {0.0f, 1.1f, 0.0f}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<float>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));
@ -69,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<float> CreateMatrix(int rows, int columns)
{
return new DiagonalMatrix(rows, columns);
}
@ -79,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(float[,] data)
protected override Matrix<float> CreateMatrix(float[,] data)
{
return DiagonalMatrix.OfArray(data);
}
@ -90,7 +91,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<float> CreateVector(int size)
{
return new DenseVector(size);
}
@ -100,7 +101,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(float[] data)
protected override Vector<float> CreateVector(float[] data)
{
return new DenseVector(data);
}
@ -111,7 +112,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
[Test]
public void CanCreateMatrixFromDiagonalArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<float>>
{
{"Singular3x3", new DiagonalMatrix(3, 3, new[] {1.0f, 0.0f, 3.0f})},
{"Square3x3", new DiagonalMatrix(3, 3, new[] {-1.1f, 1.1f, 6.6f})},

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

@ -50,7 +50,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices { get; set; }
protected Dictionary<string, Matrix<float>> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -58,14 +58,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected abstract Matrix CreateMatrix(int rows, int columns);
protected abstract Matrix<float> CreateMatrix(int rows, int columns);
/// <summary>
/// Creates a matrix from a 2D array.
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected abstract Matrix CreateMatrix(float[,] data);
protected abstract Matrix<float> CreateMatrix(float[,] data);
/// <summary>
/// Creates a vector of the given size.
@ -73,14 +73,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(int size);
protected abstract Vector<float> CreateVector(int size);
/// <summary>
/// Creates a vector from an array.
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected abstract Vector CreateVector(float[] data);
protected abstract Vector<float> CreateVector(float[] data);
/// <summary>
/// Setup test matrices.
@ -99,7 +99,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{"Symmetric3x3", new[,] {{1.0f, 2.0f, 3.0f}, {2.0f, 2.0f, 0.0f}, {3.0f, 0.0f, 3.0f}}}
};
TestMatrices = new Dictionary<string, Matrix>();
TestMatrices = new Dictionary<string, Matrix<float>>();
foreach (var name in TestData2D.Keys)
{
TestMatrices.Add(name, CreateMatrix(TestData2D[name]));

14
src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/BiCgStabTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new BiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -129,13 +129,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply((float) Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -213,7 +213,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/GpBiCgTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new GpBiCg();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -129,13 +129,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply((float) Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

14
src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/MlkBiCgStabTest.cs

@ -62,7 +62,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -75,7 +75,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new MlkBiCgStab();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -88,10 +88,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -131,13 +131,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply((float) Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -215,7 +215,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Due to datatype "float" it can happen that solution will not converge for specific random starting vectors
// That's why we will do 3 tries

14
src/UnitTests/LinearAlgebraTests/Single/Solvers/Iterative/TFQMRTest.cs

@ -61,7 +61,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveWideMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(2, 3);
Vector input = new DenseVector(2);
var input = new DenseVector(2);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -74,7 +74,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveLongMatrixThrowsArgumentException()
{
var matrix = new SparseMatrix(3, 2);
Vector input = new DenseVector(3);
var input = new DenseVector(3);
var solver = new TFQMR();
Assert.Throws<ArgumentException>(() => solver.Solve(matrix, input));
@ -87,10 +87,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -130,13 +130,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
public void SolveScaledUnitMatrixAndBackMultiply()
{
// Create the identity matrix
Matrix matrix = SparseMatrix.Identity(100);
var matrix = SparseMatrix.Identity(100);
// Scale it with a funny number
matrix.Multiply((float) Math.PI, matrix);
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]
@ -214,7 +214,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Iterative
}
// Create the y vector
Vector y = DenseVector.Create(matrix.RowCount, i => 1);
var y = DenseVector.Create(matrix.RowCount, i => 1);
// Create an iteration monitor which will keep track of iterative convergence
var monitor = new Iterator(new IIterationStopCriterium[]

2
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/DiagonalTest.cs

@ -59,7 +59,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
// Compute M * result = product
// compare vector and product. Should be equal
Vector product = new DenseVector(result.Count);
var product = new DenseVector(result.Count);
matrix.Multiply(result, product);
for (var i = 0; i < product.Count; i++)

16
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IluptElementSorterTest.cs

@ -177,7 +177,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -207,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithDecreasingDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 9;
values[1] = 8;
values[2] = 7;
@ -237,7 +237,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithRandomDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 5;
values[1] = 2;
values[2] = 8;
@ -299,7 +299,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithDuplicateDoubleEntries()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 1;
values[1] = 1;
values[2] = 1;
@ -363,7 +363,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithSpecialConstructedDoubleArray()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 0;
values[2] = 0;
@ -472,7 +472,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArrayWithLowerBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -502,7 +502,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArrayWithUpperBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;
@ -532,7 +532,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
public void HeapSortWithIncreasingDoubleArrayWithLowerAndUpperBound()
{
var sortedIndices = new int[10];
Vector values = new DenseVector(10);
var values = new DenseVector(10);
values[0] = 0;
values[1] = 1;
values[2] = 2;

8
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/IncompleteLUTest.cs

@ -65,9 +65,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Upper triangle.</returns>
private static Matrix GetUpperTriangle(IncompleteLU ilu)
private static Matrix<float> GetUpperTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "UpperTriangle");
return GetMethod<Matrix<float>>(ilu, "UpperTriangle");
}
/// <summary>
@ -75,9 +75,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="ilu"><c>IncompleteLU</c> instance.</param>
/// <returns>Lower triangle.</returns>
private static Matrix GetLowerTriangle(IncompleteLU ilu)
private static Matrix<float> GetLowerTriangle(IncompleteLU ilu)
{
return GetMethod<Matrix>(ilu, "LowerTriangle");
return GetMethod<Matrix<float>>(ilu, "LowerTriangle");
}
/// <summary>

4
src/UnitTests/LinearAlgebraTests/Single/Solvers/Preconditioners/PreConditionerTest.cs

@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
/// </summary>
/// <param name="size">Size of the vector.</param>
/// <returns>New vector.</returns>
protected Vector CreateStandardBcVector(int size)
protected DenseVector CreateStandardBcVector(int size)
{
var vector = new DenseVector(size);
for (var i = 0; i < size; i++)
@ -174,7 +174,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single.Solvers.Precondit
var preconditioner = CreatePreconditioner();
preconditioner.Initialize(newMatrix);
Vector result = null;
Vector<float> result = null;
Assert.Throws<ArgumentNullException>(() => preconditioner.Approximate(vector, result));
}

23
src/UnitTests/LinearAlgebraTests/Single/SparseMatrixTests.cs

@ -28,13 +28,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using System;
using System.Collections.Generic;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Single;
using NUnit.Framework;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
using LinearAlgebra.Single;
using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary>
/// Sparse matrix tests.
/// </summary>
@ -46,7 +47,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<float> CreateMatrix(int rows, int columns)
{
return new SparseMatrix(rows, columns);
}
@ -56,7 +57,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(float[,] data)
protected override Matrix<float> CreateMatrix(float[,] data)
{
return SparseMatrix.OfArray(data);
}
@ -67,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<float> CreateVector(int size)
{
return new SparseVector(size);
}
@ -77,7 +78,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(float[] data)
protected override Vector<float> CreateVector(float[] data)
{
return SparseVector.OfEnumerable(data);
}
@ -88,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
[Test]
public void CanCreateMatrixFrom1DArray()
{
var testData = new Dictionary<string, Matrix>
var testData = new Dictionary<string, Matrix<float>>
{
{"Singular3x3", SparseMatrix.OfColumnMajor(3, 3, new float[] {1, 1, 1, 1, 1, 1, 2, 2, 2})},
{"Square3x3", SparseMatrix.OfColumnMajor(3, 3, new[] {-1.1f, 0.0f, -4.4f, -2.2f, 1.1f, 5.5f, -3.3f, 2.2f, 6.6f})},
@ -184,7 +185,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
var matrix = new SparseMatrix(500, 1000);
var nonzero = 0;
var rnd = new Random();
var rnd = new System.Random();
for (var i = 0; i < matrix.RowCount; i++)
{

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

@ -24,10 +24,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
using MathNet.Numerics.LinearAlgebra;
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
using LinearAlgebra.Single;
/// <summary>
/// Test class for user-defined matrix.
/// </summary>
@ -39,7 +39,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param>
/// <returns>A matrix with the given dimensions.</returns>
protected override Matrix CreateMatrix(int rows, int columns)
protected override Matrix<float> CreateMatrix(int rows, int columns)
{
return new UserDefinedMatrix(rows, columns);
}
@ -49,7 +49,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The 2D array to create this matrix from.</param>
/// <returns>A matrix with the given values.</returns>
protected override Matrix CreateMatrix(float[,] data)
protected override Matrix<float> CreateMatrix(float[,] data)
{
return new UserDefinedMatrix(data);
}
@ -60,7 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="size">The size of the vector to create.
/// </param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(int size)
protected override Vector<float> CreateVector(int size)
{
return new UserDefinedVector(size);
}
@ -70,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary>
/// <param name="data">The array to create this vector from.</param>
/// <returns>The new vector. </returns>
protected override Vector CreateVector(float[] data)
protected override Vector<float> CreateVector(float[] data)
{
return new UserDefinedVector(data);
}

Loading…
Cancel
Save