protected override CholmodSparse CreateSparse(CompressedColumnStorage <Complex> matrix, List <GCHandle> handles) { var A = new CholmodSparse(); A.nrow = (uint)matrix.RowCount; A.ncol = (uint)matrix.ColumnCount; A.dtype = Dtype.Double; A.xtype = Xtype.Real; A.stype = Stype.Upper; // TODO: this should be configurable! A.itype = Constants.CHOLMOD_INT; A.nzmax = (uint)matrix.Values.Length; A.packed = 1; A.sorted = 1; A.nz = IntPtr.Zero; A.p = InteropHelper.Pin(matrix.ColumnPointers, handles); A.i = InteropHelper.Pin(matrix.RowIndices, handles); A.x = InteropHelper.Pin(matrix.Values, handles); A.z = IntPtr.Zero; return(A); }
public static CompressedColumnStorage <Complex> GetSparseMatrix(CholmodSparse sparse, ref double[] buffer) { int rows = (int)sparse.nrow; int columns = (int)sparse.ncol; var matrix = new SparseMatrix(rows, columns); var ap = new int[sparse.ncol + 1]; Marshal.Copy(sparse.p, ap, 0, columns + 1); int nnz = ap[columns]; var ai = new int[nnz]; var ax = new Complex[nnz]; Marshal.Copy(sparse.i, ai, 0, nnz); CopyArray(2 * (int)sparse.nzmax, sparse.x, matrix.Values, ref buffer); matrix.ColumnPointers = ap; matrix.RowIndices = ai; matrix.Values = ax; return(matrix); }
public static CholmodSparse CreateSparse(CompressedColumnStorage <Complex> matrix, Stype stype, List <GCHandle> handles) { var A = new CholmodSparse(); A.nrow = (uint)matrix.RowCount; A.ncol = (uint)matrix.ColumnCount; A.dtype = Dtype.Double; A.xtype = Xtype.Complex; A.stype = stype; A.itype = Constants.CHOLMOD_INT; A.nzmax = (uint)matrix.Values.Length; A.packed = 1; A.sorted = 1; A.nz = IntPtr.Zero; A.p = InteropHelper.Pin(matrix.ColumnPointers, handles); A.i = InteropHelper.Pin(matrix.RowIndices, handles); A.x = InteropHelper.Pin(matrix.Values, handles); A.z = IntPtr.Zero; return(A); }
public static CompressedColumnStorage <double> GetSparseMatrix(CholmodSparse sparse) { int rows = (int)sparse.nrow; int columns = (int)sparse.ncol; var matrix = new SparseMatrix(rows, columns); var ap = new int[sparse.ncol + 1]; Marshal.Copy(sparse.p, ap, 0, columns + 1); int nnz = ap[columns]; var ai = new int[nnz]; var ax = new double[nnz]; Marshal.Copy(sparse.i, ai, 0, nnz); Marshal.Copy(sparse.x, ax, 0, nnz); matrix.ColumnPointers = ap; matrix.RowIndices = ai; matrix.Values = ax; return(matrix); }
public static extern IntPtr SuiteSparseQR_C_symbolic ( /* inputs: */ int ordering, int allow_tol, ref CholmodSparse A, ref CholmodCommon cc );
public static extern IntPtr SuiteSparseQR_C_factorize ( /* inputs: */ int ordering, double tol, ref CholmodSparse A, ref CholmodCommon cc );
public static extern CholmodDense SuiteSparseQR_C_backslash ( int ordering, double tol, ref CholmodSparse A, ref CholmodDense B, ref CholmodCommon cc );
public static extern int SuiteSparseQR_C_numeric ( /* inputs: */ double tol, ref CholmodSparse A, /* input/output: */ IntPtr QR, ref CholmodCommon cc );
public static extern CholmodSparse SuiteSparseQR_C_backslash_sparse ( /* inputs: */ int ordering, double tol, ref CholmodSparse A, ref CholmodSparse B, ref CholmodCommon cc );
public static extern sp_long SuiteSparseQR_C_QR ( /* inputs: */ int ordering, double tol, sp_long econ, ref CholmodSparse A, /* outputs: */ out IntPtr Q, // CholmodSparse out IntPtr R, // CholmodSparse out IntPtr E, // SuiteSparse_long[] ref CholmodCommon cc );
public static extern sp_long SuiteSparseQR_C ( /* inputs: */ int ordering, double tol, sp_long econ, int getCTX, ref CholmodSparse A, IntPtr Bsparse, // ref CholmodSparse ref CholmodDense Bdense, /* outputs: */ out IntPtr Zsparse, // CholmodSparse out IntPtr Zdense, // CholmodDense out IntPtr R, // CholmodSparse out IntPtr E, // SuiteSparse_long[] out IntPtr H, // CholmodSparse out IntPtr HPinv, // SuiteSparse_long[] out IntPtr HTau, // CholmodDense ref CholmodCommon cc // );
public static extern CholmodDense SuiteSparseQR_C_backslash_default ( ref CholmodSparse A, ref CholmodDense B, ref CholmodCommon cc );