def test_linsys_hpd(): A = test_utils.get_matrix_hpd() 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, Ainv ] + test_utils.get_operators(Minv) }, { 'Ml': [ None, Ainv ] + test_utils.get_operators(Minv) }, { 'Mr': [ None, Ainv ] + test_utils.get_operators(Minv) } ] solvers = [ krypy.linsys.cg, krypy.linsys.minres, krypy.linsys.gmres ] for case in produce_cases(A, x, params_adds, solvers): yield case
def test_linsys_hpd(): A = test_utils.get_matrix_hpd() 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, Ainv] + test_utils.get_operators(Minv) }, { 'Ml': [None, Ainv] + test_utils.get_operators(Minv) }, { 'Mr': [None, Ainv] + test_utils.get_operators(Minv) }] solvers = [krypy.linsys.cg, krypy.linsys.minres, krypy.linsys.gmres] for case in produce_cases(A, x, params_adds, solvers): yield case
'tol': [1e-13, 1e-2], 'maxiter': [15], } if ls.exact_solution is not None: solver_params['x0'].append(ls.exact_solution) for params in dictproduct(dict(list(solver_params.items()) + 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 params in dictproduct( dict(list(solver_params.items()) + 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