#if NATIVE using IStation.Numerics.Providers.Common.Mkl; using System; using System.Security; using Complex = System.Numerics.Complex; namespace IStation.Numerics.Providers.SparseSolver.Mkl { /// /// Intel's Math Kernel Library (MKL) direct sparse solver provider. /// internal partial class MklSparseSolverProvider { /// /// Solves sparse linear systems of equations, AX = B. /// /// The symmetricity of the matrix. For a symmetric matrix, only upper ot lower triangular matrix is used. /// The definiteness of the matrix. /// The type of the systems. /// The number of rows of matrix. /// The number of columns of matrix. /// The number of non zero elements of matrix. /// The array containing the row indices of the existing rows. /// The array containing the column indices of the non-zero values /// The array that contains the non-zero elements of matrix. No diagonal element can be ommitted. /// The number of columns of the right hand side matrix. /// The right hand side matrix /// The left hand side matrix /// The status of the solver. [SecuritySafeCritical] public override DssStatus Solve(DssMatrixStructure matrixStructure, DssMatrixType matrixType, DssSystemType systemType, int rowCount, int columnCount, int nonZerosCount, int[] rowPointers, int[] columnIndices, Complex[] values, int nRhs, Complex[] rhs, Complex[] solution) { if (rowCount != columnCount) { throw new ArgumentException("Matrix must be symmetric."); } if (rowPointers == null) { throw new ArgumentNullException(nameof(rowPointers)); } if (columnIndices == null) { throw new ArgumentNullException(nameof(columnIndices)); } if (values == null) { throw new ArgumentNullException(nameof(values)); } if (rhs == null) { throw new ArgumentNullException(nameof(rhs)); } if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (rowCount * nRhs != rhs.Length) { throw new ArgumentException("The array arguments must have the same length.", nameof(rhs)); } if (columnCount * nRhs != solution.Length) { 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, rowCount, columnCount, nonZerosCount, rowPointers, columnIndices, values, nRhs, rhs, solution); return (DssStatus)error; } } } #endif