public static void SetEntry(ref int _ref, ref int i, ref int j, ref double val, out int ierr) { ierr = 0; try { IMutableMatrix M = (IMutableMatrix)Infrastructure.GetObject(_ref); M[i, j] = val; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetRowPart(ref int MtxRef, out int PartRef, out int ierr) { ierr = 0; PartRef = -1; try { ISparseMatrix M = (ISparseMatrix)Infrastructure.GetObject(MtxRef); PartRef = Infrastructure.RegisterObject(M.RowPartitioning); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetLocLen(ref int _ref, out int LocLen, out int ierr) { ierr = 0; LocLen = -1; try { ISparseMatrix M = (ISparseMatrix)Infrastructure.GetObject(_ref); LocLen = M.RowPartitioning.LocalLength; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetI0(ref int _ref, out int i0, out int ierr) { ierr = 0; i0 = -1; try { ISparseMatrix M = (ISparseMatrix)Infrastructure.GetObject(_ref); i0 = (int)M.RowPartitioning.i0; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetMPIsize(ref int _ref, out int MPIsize, out int ierr) { ierr = 0; MPIsize = -1; try { IPartitioning p = (IPartitioning)Infrastructure.GetObject(_ref); MPIsize = (int)p.Size; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetLocLen(ref int _ref, out int LocLen, out int ierr) { ierr = 0; LocLen = -1; try { IPartitioning p = (IPartitioning)Infrastructure.GetObject(_ref); LocLen = (int)p.LocalLength; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetI0(ref int _ref, out int i0, out int ierr) { ierr = 0; i0 = -1; try { IPartitioning p = (IPartitioning)Infrastructure.GetObject(_ref); i0 = (int)p.i0; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetMPIrank(ref int _ref, out int MPIrank, out int ierr) { ierr = 0; MPIrank = -1; try { Partition p = (Partition)Infrastructure.GetObject(_ref); MPIrank = (int)p.Rank; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
unsafe public static void DefineMatrix(ref int SolverRef, ref int MatrixRef, out int ierr) { ierr = 0; try { ISparseSolver solver = (ISparseSolver)Infrastructure.GetObject(SolverRef); IMutableMatrixEx matrix = (IMutableMatrixEx)Infrastructure.GetObject(MatrixRef); solver.DefineMatrix(matrix); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
unsafe public static void SaveToTextFileSparseF(ref int _ref, byte *termchar, byte *path, out int ierr) { ierr = 0; try { string _path = Infrastructure.FortranToDotNET(path, *termchar); IMutableMatrixEx M = (IMutableMatrixEx)Infrastructure.GetObject(_ref); M.SaveToTextFileSparse(_path); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
unsafe public static void SaveToTextFileSparse(ref int _ref, byte *path, out int ierr) { ierr = 0; try { string _paht = Marshal.PtrToStringAnsi((IntPtr)path); IMutableMatrixEx M = (IMutableMatrixEx)Infrastructure.GetObject(_ref); //Console.WriteLine("saving: >" + _paht + "<"); M.SaveToTextFileSparse(_paht); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
/// <summary> /// releases all C# - references on an object, making it ready for garbage-collection. /// </summary> public static void ReleaseObject(ref int _ref, out int ierr) { ierr = 0; try { object o = Infrastructure.GetObject(_ref); if (o is IDisposable) { ((IDisposable)o).Dispose(); } Infrastructure.ForgetObject(_ref); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
unsafe public static void Solve(ref int SolverRef, ref int N, double *x, double *rhs, out int ierr) { ierr = 0; try { ISparseSolver solver = (ISparseSolver)Infrastructure.GetObject(SolverRef); // create managed buffers from unmanaged ones // (ginge auch effizienter, aber ...) double[] _x = new double[N]; double[] _rhs = new double[N]; unsafe { Marshal.Copy((IntPtr)x, _x, 0, N); Marshal.Copy((IntPtr)rhs, _rhs, 0, N); // call solver solver.Solve(_x, _rhs); Marshal.Copy(_x, 0, (IntPtr)x, N); Marshal.Copy(_rhs, 0, (IntPtr)rhs, N); } } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }