Exemple #1
0
def test_linsys_nonsymm():
    A = test_utils.get_matrix_nonsymm()
    Ainv = numpy.linalg.inv(A)

    # solution
    x = numpy.ones((10,1))

    # preconditioner
    m = numpy.array(range(1,11))
    m[-1] = 1.
    M, Minv = numpy.diag(m), numpy.diag(1./m)
    params_adds = [
            { 'maxiter': [5], 'max_restarts': [20] },
            { 'M': [ None ] + test_utils.get_operators(Minv) },
            { 'Ml': [ None, Ainv ] + test_utils.get_operators(Minv) },
            { 'Mr': [ None, Ainv ] + test_utils.get_operators(Minv) }
            ]
    solvers = [ krypy.linsys.gmres ]
    for case in produce_cases(A, x, params_adds, solvers):
        yield case
Exemple #2
0
def test_linsys_nonsymm():
    A = test_utils.get_matrix_nonsymm()
    Ainv = numpy.linalg.inv(A)

    # solution
    x = numpy.ones((10, 1))

    # preconditioner
    m = numpy.array(range(1, 11))
    m[-1] = 1.
    M, Minv = numpy.diag(m), numpy.diag(1. / m)
    params_adds = [{
        'maxiter': [5],
        'max_restarts': [20]
    }, {
        'M': [None] + test_utils.get_operators(Minv)
    }, {
        'Ml': [None, Ainv] + test_utils.get_operators(Minv)
    }, {
        'Mr': [None, Ainv] + test_utils.get_operators(Minv)
    }]
    solvers = [krypy.linsys.gmres]
    for case in produce_cases(A, x, params_adds, solvers):
        yield case
Exemple #3
0
cases = [
    # spd
    {'A': test_utils.get_matrix_spd(),
     'normal': True, 'self_adjoint': True, 'positive_definite': True},
    # hpd
    {'A': test_utils.get_matrix_hpd(),
     'normal': True, 'self_adjoint': True, 'positive_definite': True},
    # symmetric indefinite
    {'A': test_utils.get_matrix_symm_indef(),
     'normal': True, 'self_adjoint': True},
    # hermitian indefinite
    {'A': test_utils.get_matrix_herm_indef(),
     'normal': True, 'self_adjoint': True},
    # nonsymm
    {'A': test_utils.get_matrix_nonsymm()},
    # nonsymm
    {'A': test_utils.get_matrix_comp_nonsymm()},
    ]


def test_solver():
    for case in cases:
        for ls in linear_systems_generator(**case):
            solvers = [krypy.linsys.Gmres, krypy.linsys.RestartedGmres]
            if ls.self_adjoint:
                solvers.append(krypy.linsys.Minres)
            if ls.positive_definite:
                solvers.append(krypy.linsys.Cg)
            for solver in solvers:
                for params in solver_params_generator(solver, ls):
Exemple #4
0
    },
    # symmetric indefinite
    {
        'A': test_utils.get_matrix_symm_indef(),
        'normal': True,
        'self_adjoint': True
    },
    # hermitian indefinite
    {
        'A': test_utils.get_matrix_herm_indef(),
        'normal': True,
        'self_adjoint': True
    },
    # nonsymm
    {
        'A': test_utils.get_matrix_nonsymm()
    },
    # nonsymm
    {
        'A': test_utils.get_matrix_comp_nonsymm()
    },
]


def test_solver():
    for case in cases:
        for ls in linear_systems_generator(**case):
            solvers = [krypy.linsys.Gmres, krypy.linsys.RestartedGmres]
            if ls.self_adjoint:
                solvers.append(krypy.linsys.Minres)
            if ls.positive_definite: