

def _do_one_inner_iteration(self, A, b, **kwargs):
    '\n        This method solves AX = b and returns the result to the corresponding\n        algorithm.\n        '
    logger.info('Solving AX = b for the sparse matrices')
    if (A is None):
        A = self.A
    if (b is None):
        b = self.b
    if (self._iterative_solver is None):
        X = sprslin.spsolve(A, b)
    else:
        if (self._iterative_solver not in ['cg', 'gmres']):
            raise Exception(('GenericLinearTransport does not support the' + ' requested iterative solver!'))
        params = kwargs.copy()
        solver_params = ['x0', 'tol', 'maxiter', 'xtype', 'M', 'callback']
        [params.pop(item, None) for item in kwargs.keys() if (item not in solver_params)]
        tol = kwargs.get('tol')
        if (tol is None):
            tol = 1e-20
        params['tol'] = tol
        if (self._iterative_solver == 'cg'):
            result = sprslin.cg(A, b, **params)
        elif (self._iterative_solver == 'gmres'):
            result = sprslin.gmres(A, b, **params)
        X = result[0]
        self._iterative_solver_info = result[1]
    return X

dataset/ETHPy150Open PMEAL/OpenPNM/OpenPNM/Algorithms/__GenericLinearTransport__.py GenericLinearTransport._do_one_inner_iteration/original