Browse Source

Build fix

v4
Christoph Ruegg 6 years ago
parent
commit
165eb49304
  1. 30
      src/Numerics/LinearAlgebra/Builder.cs
  2. 6
      src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
  3. 7
      src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Complex.cs
  4. 7
      src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Complex32.cs
  5. 7
      src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Double.cs
  6. 7
      src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Single.cs

30
src/Numerics/LinearAlgebra/Builder.cs

@ -33,7 +33,6 @@ using System.Linq;
using MathNet.Numerics.Distributions; using MathNet.Numerics.Distributions;
using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers;
using MathNet.Numerics.LinearAlgebra.Storage; using MathNet.Numerics.LinearAlgebra.Storage;
using MathNet.Numerics.Properties;
using MathNet.Numerics.Random; using MathNet.Numerics.Random;
namespace MathNet.Numerics.LinearAlgebra.Double namespace MathNet.Numerics.LinearAlgebra.Double
@ -1139,17 +1138,17 @@ namespace MathNet.Numerics.LinearAlgebra
// //
// Rows = 4, Columns = 6, NonZeroCount = 14 // Rows = 4, Columns = 6, NonZeroCount = 14
// //
// (1) COO, Coordinate Format: // (1) COO, Coordinate Format:
// cooRowIndices = { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 } // cooRowIndices = { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 }
// cooColumnIndices = { 1, 3, 0, 1, 2, 3, 2, 3, 4, 5, 1, 2, 3, 4 } // cooColumnIndices = { 1, 3, 0, 1, 2, 3, 2, 3, 4, 5, 1, 2, 3, 4 }
// cooValues = { b, h, a, c, e, i, f, j, l, n, d, g, k, m } // cooValues = { b, h, a, c, e, i, f, j, l, n, d, g, k, m }
// //
// (2) CSR, Compressed Sparse Row representation: // (2) CSR, Compressed Sparse Row representation:
// csrRowPointers = { 0, 2, 6, 10, 14 } // csrRowPointers = { 0, 2, 6, 10, 14 }
// csrColumnIndices = { 1, 3, 0, 1, 2, 3, 2, 3, 4, 5, 1, 2, 3, 4 } // csrColumnIndices = { 1, 3, 0, 1, 2, 3, 2, 3, 4, 5, 1, 2, 3, 4 }
// csrValues = { b, h, a, c, e, i, f, j, l, n, d, g, k, m } // csrValues = { b, h, a, c, e, i, f, j, l, n, d, g, k, m }
// //
// (3) CSC, Compressed Sparse Column representation: // (3) CSC, Compressed Sparse Column representation:
// csrColumnPointers = { 0, 1, 4, 7, 11, 13, 14 } // csrColumnPointers = { 0, 1, 4, 7, 11, 13, 14 }
// csrRowIndices = { 1, 0, 1, 3, 1, 2, 3, 0, 1, 2, 3, 2, 3, 2 } // csrRowIndices = { 1, 0, 1, 3, 1, 2, 3, 0, 1, 2, 3, 2, 3, 2 }
// csrValues = { a, b, c, d, e, f, g, h, i, j, k, l, m, n } // csrValues = { a, b, c, d, e, f, g, h, i, j, k, l, m, n }
@ -1168,16 +1167,15 @@ namespace MathNet.Numerics.LinearAlgebra
throw new NullReferenceException(nameof(cooRowIndices)); throw new NullReferenceException(nameof(cooRowIndices));
if (cooColumnIndices == null) if (cooColumnIndices == null)
throw new NullReferenceException(nameof(cooColumnIndices)); throw new NullReferenceException(nameof(cooColumnIndices));
if (cooRowIndices.Length < nonZeroCount || cooColumnIndices.Length < nonZeroCount || cooValues.Length < nonZeroCount) if (cooRowIndices.Length < nonZeroCount || cooColumnIndices.Length < nonZeroCount || cooValues.Length < nonZeroCount)
{ {
var message = string.Format(Resources.ArgumentArrayWrongLength, nonZeroCount); throw new Exception($"The given array has the wrong length. Should be {nonZeroCount}.");
throw new Exception(message);
} }
// convert from COO to CSR // convert from COO to CSR
var csrValues = new T[nonZeroCount]; var csrValues = new T[nonZeroCount];
var csrColumnIndices = new int[nonZeroCount]; var csrColumnIndices = new int[nonZeroCount];
var csrRowPointers = new int[rows + 1]; var csrRowPointers = new int[rows + 1];
@ -1220,13 +1218,11 @@ namespace MathNet.Numerics.LinearAlgebra
throw new NullReferenceException(nameof(csrRowPointers)); throw new NullReferenceException(nameof(csrRowPointers));
if (csrRowPointers.Length < rows) if (csrRowPointers.Length < rows)
{ {
var message = string.Format(Resources.ArgumentArrayWrongLength, rows + 1); throw new Exception($"The given array has the wrong length. Should be {rows + 1}.");
throw new Exception(message);
} }
if (nonZeroCount != csrRowPointers[rows]) if (nonZeroCount != csrRowPointers[rows])
{ {
var message = string.Format("{0} should be same to {1}", nameof(nonZeroCount), csrRowPointers[rows]); throw new Exception($"{nameof(nonZeroCount)} should be same to {csrRowPointers[rows]}");
throw new Exception(message);
} }
var values = new T[nonZeroCount]; var values = new T[nonZeroCount];
@ -1252,21 +1248,19 @@ namespace MathNet.Numerics.LinearAlgebra
if (cscRowIndices == null) if (cscRowIndices == null)
throw new NullReferenceException(nameof(cscRowIndices)); throw new NullReferenceException(nameof(cscRowIndices));
if (cscColumnPointers == null) if (cscColumnPointers == null)
throw new NullReferenceException(nameof(cscColumnPointers)); throw new NullReferenceException(nameof(cscColumnPointers));
if (cscColumnPointers.Length < columns) if (cscColumnPointers.Length < columns)
{ {
var message = string.Format(Resources.ArgumentArrayWrongLength, columns + 1); throw new Exception($"The given array has the wrong length. Should be {columns + 1}.");
throw new Exception(message);
} }
if (nonZeroCount != cscColumnPointers[columns]) if (nonZeroCount != cscColumnPointers[columns])
{ {
var message = string.Format("{0} should be same to {1}", nameof(nonZeroCount), cscColumnPointers[columns]); throw new Exception($"{nameof(nonZeroCount)} should be same to {cscColumnPointers[columns]}");
throw new Exception(message);
} }
// convert from CSC to CSR // convert from CSC to CSR
var csrValues = new T[nonZeroCount]; var csrValues = new T[nonZeroCount];
var csrRowPointers = new int[rows + 1]; var csrRowPointers = new int[rows + 1];
var csrColumnIndices = new int[nonZeroCount]; var csrColumnIndices = new int[nonZeroCount];

6
src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs

@ -80,7 +80,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
internal SparseCompressedRowMatrixStorage(int rows, int columns, int[] rowPointers, int[] columnIndices, T[] values) internal SparseCompressedRowMatrixStorage(int rows, int columns, int[] rowPointers, int[] columnIndices, T[] values)
: base(rows, columns) : base(rows, columns)
{ {
RowPointers = rowPointers; RowPointers = rowPointers;
ColumnIndices = columnIndices; ColumnIndices = columnIndices;
Values = values; Values = values;
@ -290,7 +290,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
} }
/// <summary> /// <summary>
/// Fill zeros explicitly on the diagonal entries as required by the Intel MKL direct sparse solver. /// Fill zeros explicitly on the diagonal entries as required by the Intel MKL direct sparse solver.
/// </summary> /// </summary>
public void PopulateExplicitZerosOnDiagonal() public void PopulateExplicitZerosOnDiagonal()
{ {
@ -315,7 +315,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
var size = Values.Length + delta; var size = Values.Length + delta;
if (size > int.MaxValue) if (size > int.MaxValue)
{ {
throw new NotSupportedException(Resources.TooManyElements); throw new NotSupportedException("We only support sparse matrix with less than int.MaxValue elements.");
} }
var newRowPointers = new int[RowCount + 1]; var newRowPointers = new int[RowCount + 1];

7
src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Complex.cs

@ -1,6 +1,5 @@
#if NATIVE #if NATIVE
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.Common.Mkl; using MathNet.Numerics.Providers.Common.Mkl;
using System; using System;
using System.Security; using System.Security;
@ -36,7 +35,7 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
{ {
if (rowCount != columnCount) if (rowCount != columnCount)
{ {
throw new ArgumentNullException(Resources.ArgumentMatrixSymmetric); throw new ArgumentException("Matrix must be symmetric.");
} }
if (rowPointers == null) if (rowPointers == null)
@ -66,12 +65,12 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
if (rowCount * nRhs != rhs.Length) if (rowCount * nRhs != rhs.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(rhs)); throw new ArgumentException("The array arguments must have the same length.", nameof(rhs));
} }
if (columnCount * nRhs != solution.Length) if (columnCount * nRhs != solution.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(solution)); throw new ArgumentException("The array arguments must have the same length.", nameof(solution));
} }
var error = SafeNativeMethods.z_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType, var error = SafeNativeMethods.z_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType,

7
src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Complex32.cs

@ -1,6 +1,5 @@
#if NATIVE #if NATIVE
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.Common.Mkl; using MathNet.Numerics.Providers.Common.Mkl;
using System; using System;
using System.Security; using System.Security;
@ -35,7 +34,7 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
{ {
if (rowCount != columnCount) if (rowCount != columnCount)
{ {
throw new ArgumentException(Resources.ArgumentMatrixSymmetric); throw new ArgumentException("Matrix must be symmetric.");
} }
if (rowPointers == null) if (rowPointers == null)
@ -65,12 +64,12 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
if (rowCount * nRhs != rhs.Length) if (rowCount * nRhs != rhs.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(rhs)); throw new ArgumentException("The array arguments must have the same length.", nameof(rhs));
} }
if (columnCount * nRhs != solution.Length) if (columnCount * nRhs != solution.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(solution)); throw new ArgumentException("The array arguments must have the same length.", nameof(solution));
} }
var error = SafeNativeMethods.c_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType, var error = SafeNativeMethods.c_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType,

7
src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Double.cs

@ -1,6 +1,5 @@
#if NATIVE #if NATIVE
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.Common.Mkl; using MathNet.Numerics.Providers.Common.Mkl;
using System; using System;
using System.Security; using System.Security;
@ -35,7 +34,7 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
{ {
if (rowCount != columnCount) if (rowCount != columnCount)
{ {
throw new ArgumentException(Resources.ArgumentMatrixSymmetric); throw new ArgumentException("Matrix must be symmetric.");
} }
if (rowPointers == null) if (rowPointers == null)
@ -65,12 +64,12 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
if (rowCount * nRhs != rhs.Length) if (rowCount * nRhs != rhs.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(rhs)); throw new ArgumentException("The array arguments must have the same length.", nameof(rhs));
} }
if (columnCount * nRhs != solution.Length) if (columnCount * nRhs != solution.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(solution)); throw new ArgumentException("The array arguments must have the same length.", nameof(solution));
} }
var error = SafeNativeMethods.d_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType, var error = SafeNativeMethods.d_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType,

7
src/Numerics/Providers/SparseSolver/Mkl/MklSparseSolverProvider.Single.cs

@ -1,6 +1,5 @@
#if NATIVE #if NATIVE
using MathNet.Numerics.Properties;
using MathNet.Numerics.Providers.Common.Mkl; using MathNet.Numerics.Providers.Common.Mkl;
using System; using System;
using System.Security; using System.Security;
@ -35,7 +34,7 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
{ {
if (rowCount != columnCount) if (rowCount != columnCount)
{ {
throw new ArgumentException(Resources.ArgumentMatrixSymmetric); throw new ArgumentException("Matrix must be symmetric.");
} }
if (rowPointers == null) if (rowPointers == null)
@ -65,12 +64,12 @@ namespace MathNet.Numerics.Providers.SparseSolver.Mkl
if (rowCount * nRhs != rhs.Length) if (rowCount * nRhs != rhs.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(rhs)); throw new ArgumentException("The array arguments must have the same length.", nameof(rhs));
} }
if (columnCount * nRhs != solution.Length) if (columnCount * nRhs != solution.Length)
{ {
throw new ArgumentException(Resources.ArgumentArraysSameLength, nameof(solution)); throw new ArgumentException("The array arguments must have the same length.", nameof(solution));
} }
var error = SafeNativeMethods.s_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType, var error = SafeNativeMethods.s_dss_solve((int)matrixStructure, (int)matrixType, (int)systemType,

Loading…
Cancel
Save