/// <summary> /// Factorize the sparse matrix associated to the solver instance. /// </summary> public void Factorize() { if (_buffer != IntPtr.Zero) { throw new Exception("Context already created."); } int rows = matrix.RowCount; int columns = matrix.ColumnCount; Cuda.Malloc(ref d_x, sizeT * columns); Cuda.Malloc(ref d_b, sizeT * rows); // TODO: can the original matrix really be disposed after factorization? using (var cusparse = new CuSparseContext <T>(stream, matrix, MatrixType.General, transpose)) { PrepareFactorize(); // Start the timer after the first call to cusolver. var timer = Stopwatch.StartNew(); Factorize(rows, columns, matrix.NonZerosCount, cusparse); factorized = true; timer.Stop(); FactorizationTime = TimeSpan.FromTicks(timer.ElapsedTicks).TotalSeconds; } }
protected abstract void Factorize(int rows, int columns, int nnz, CuSparseContext <T> A);