def __init__(self, A, **kwargs): PysparseDirectSolver.__init__(self, A, **kwargs) if 'strategy' in kwargs.keys(): strategy = upper(kwargs.get('strategy')) if strategy not in ['AUTO', 'UNSYMMETRIC', 'SYMMETRIC', '2BY2']: strategy = 'AUTO' kwargs['strategy'] = 'UMFPACK_STRATEGY_' + strategy if 'scale' in kwargs.keys(): scale = upper(kwargs.get('scale')) if scale not in ['NONE', 'SUM', 'MAX']: scale = 'SUM' kwargs['scale'] = 'UMFPACK_SCALE_' + scale self.type = numpy.float self.nrow, self.ncol = A.getShape() t = cputime() self.LU = umfpack.factorize(A.matrix, **kwargs) self.factorizationTime = cputime() - t self.solutionTime = 0.0 self.sol = None self.L = self.U = None self.P = self.Q = self.R = None self.do_recip = False self.lnz = self.unz = self.nz_udiag = None return
def __init__(self, A, **kwargs): PysparseDirectSolver.__init__(self, A, **kwargs) self.type = numpy.float self.nrow, self.ncol = A.getShape() t = cputime() self.LU = superlu.factorize(A.matrix.to_csr(), **kwargs) self.factorizationTime = cputime() - t self.solutionTime = 0.0 self.sol = None self.L = self.U = None return
def solve(self, rhs, transpose = False): """ Solve the linear system ``A x = rhs``, where ``A`` is the input matrix and ``rhs`` is a Numpy vector of appropriate dimension. The result is placed in the :attr:`sol` member of the class instance. If the optional argument ``transpose`` is ``True``, the transpose system ``A^T x = rhs`` is solved. """ if self.sol is None: self.sol = numpy.empty(self.ncol, self.type) transp = 'N' if transpose: transp = 'T' t = cputime() self.LU.solve(rhs, self.sol, transp) self.solutionTime = cputime() - t return
def solve(self, rhs, **kwargs): """ Solve the linear system ``A x = rhs``. The result is placed in the :attr:`sol` member of the class instance. :parameters: :rhs: a Numpy vector of appropriate dimension. :keywords: :method: specifies the type of system being solved: +-------------------+--------------------------------------+ |``"UMFPACK_A"`` | :math:`\mathbf{A} x = b` (default) | +-------------------+--------------------------------------+ |``"UMFPACK_At"`` | :math:`\mathbf{A}^T x = b` | +-------------------+--------------------------------------+ |``"UMFPACK_Pt_L"`` | :math:`\mathbf{P}^T \mathbf{L} x = b`| +-------------------+--------------------------------------+ |``"UMFPACK_L"`` | :math:`\mathbf{L} x = b` | +-------------------+--------------------------------------+ |``"UMFPACK_Lt_P"`` | :math:`\mathbf{L}^T \mathbf{P} x = b`| +-------------------+--------------------------------------+ |``"UMFPACK_Lt"`` | :math:`\mathbf{L}^T x = b` | +-------------------+--------------------------------------+ |``"UMFPACK_U_Qt"`` | :math:`\mathbf{U} \mathbf{Q}^T x = b`| +-------------------+--------------------------------------+ |``"UMFPACK_U"`` | :math:`\mathbf{U} x = b` | +-------------------+--------------------------------------+ |``"UMFPACK_Q_Ut"`` | :math:`\mathbf{Q} \mathbf{U}^T x = b`| +-------------------+--------------------------------------+ |``"UMFPACK_Ut"`` | :math:`\mathbf{U}^T x = b` | +-------------------+--------------------------------------+ :irsteps: number of iterative refinement steps to attempt. Default: 2 """ method = kwargs.get('method', 'UMFPACK_A') irsteps = kwargs.get('irsteps', 2) if self.sol is None: self.sol = numpy.empty(self.ncol, self.type) t = cputime() self.LU.solve(rhs, self.sol, method, irsteps) self.solutionTime = cputime() - t return