示例#1
0
        self.solver_options = solver_options

    def apply(self, U, mu=None):
        return self.op.apply(U, mu=mu)

    def apply_adjoint(self, V, mu=None):
        return self.op.apply_adjoint(V, mu=mu)


@pytest.fixture(params=pymor.algorithms.genericsolvers.solver_options().keys())
def generic_solver(request):
    return {'inverse': request.param}

all_sparse_solvers = set(pymor.algorithms.genericsolvers.solver_options().keys())
from pymor.bindings.scipy import solver_options as scipy_solver_options
all_sparse_solvers.update(scipy_solver_options().keys())
if config.HAVE_PYAMG:
    from pymor.bindings.pyamg import solver_options as pyamg_solver_options
    all_sparse_solvers.update(pyamg_solver_options().keys())


@pytest.fixture(params=all_sparse_solvers)
def numpy_sparse_solver(request):
    return {'inverse': request.param}


def test_generic_solvers(generic_solver):
    op = GenericOperator(generic_solver)
    rhs = op.range.make_array(np.ones(10))
    solution = op.apply_inverse(rhs)
    assert ((op.apply(solution) - rhs).l2_norm() / rhs.l2_norm())[0] < 1e-8
示例#2
0
        self.solver_options = solver_options

    def apply(self, U, mu=None):
        return self.op.apply(U, mu=mu)

    def apply_adjoint(self, V, mu=None):
        return self.op.apply_adjoint(V, mu=mu)


@pytest.fixture(params=pymor.algorithms.genericsolvers.solver_options().keys())
def generic_solver(request):
    return {'inverse': request.param}

all_sparse_solvers = set(pymor.algorithms.genericsolvers.solver_options().keys())
from pymor.bindings.scipy import solver_options as scipy_solver_options
all_sparse_solvers.update(scipy_solver_options().keys())
if config.HAVE_PYAMG:
    from pymor.bindings.pyamg import solver_options as pyamg_solver_options
    all_sparse_solvers.update(pyamg_solver_options().keys())


@pytest.fixture(params=all_sparse_solvers)
def numpy_sparse_solver(request):
    return {'inverse': request.param}


def test_generic_solvers(generic_solver):
    op = GenericOperator(generic_solver)
    rhs = op.range.make_array(np.ones(10))
    solution = op.apply_inverse(rhs)
    assert ((op.apply(solution) - rhs).l2_norm() / rhs.l2_norm())[0] < 1e-8