示例#1
0
def test_linsys_herm_indef():
    A = test_utils.get_matrix_herm_indef()
    Ainv = numpy.linalg.inv(A)

    # solution
    x = (1.+1.j)*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 = [
            { '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.minres, krypy.linsys.gmres ]
    for case in produce_cases(A, x, params_adds, solvers):
        yield case
示例#2
0
def test_linsys_herm_indef():
    A = test_utils.get_matrix_herm_indef()
    Ainv = numpy.linalg.inv(A)

    # solution
    x = (1. + 1.j) * 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 = [{
        '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.minres, krypy.linsys.gmres]
    for case in produce_cases(A, x, params_adds, solvers):
        yield case
示例#3
0
                              list(params_add.items()))):
        yield params


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:
示例#4
0
    # 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():