qcd_ml.util¶
qcd_ml.util.solver¶
Solvers for systems of linear equations.
- qcd_ml.util.solver.GMRES(A, b, x0, maxiter=1000, inner_iter=30, eps=1e-05, innerproduct=<function <lambda>>, preconditioner=None, verbose=False)[source]¶
Implementation of thr GMRES algorithm for solving the linear system Ax = b.
A: callable or a matrix that allowsA @ xto be computed.b: right-hand side of the linear system.x0: initial guess for the solution.maxiter: maximum number of iterations.inner_iter: number of iterations before restarting.eps: tolerance for the residual. The true tolerance iseps * ||b||oreps * ||r0||.innerproduct: inner product function.preconditioner: preconditioner function. Should be a function that takes a vector and returns a vector.
- qcd_ml.util.solver.GMRES_inner(A, b, x0, stopat_residual, niterations, innerproduct, preconditioner)[source]¶
Inner GMRES, i.e.,
niterationswithout restart.
- qcd_ml.util.solver.update_qr(H, s, c, j)[source]¶
Runs and updates the QR decomposition of the matrix H. This function is used internally by GMRES_inner.
- qcd_ml.util.solver.update_result(x, Z, gamma, H, y, j)[source]¶
Updates the result of GMRES_inner by going from the Krylov space (spanned by Z, coefficients H and gamma) to the solution x.
Provides Multigrid with zero point projection.
- class qcd_ml.util.qcd.multigrid.ZPP_Multigrid(block_size, ui_blocked, n_basis, L_coarse, L_fine)[source]¶
Multigrid with zeropoint projection.
Use
.v_projectand.v_prolongto project and prolong vectors. Use.get_coarse_operatorto construct a coarse operator.use
ZPP_Multigrid.gen_from_fine_vectors([random vectors], [i, j, k, l], lambda b, xo: <solve Dx = b for x>)to construct aZPP_Multigrid.- classmethod from_basis_vectors(basis_vectors, block_size)[source]¶
Used to generate a multigrid setup using basis vectors and a block size. The basis vectors can be obtained using
.get_basis_vectors()method.
- classmethod gen_from_fine_vectors(fine_vectors, block_size, solver, verbose=False)[source]¶
Used to generate a multigrid setup using fine vectors, a block size and a solver.
- solver should be
(x, info) = solver(b, x0)- which solves
D x = b
- we will choose
b = torch.zeros_like(x0)
- get_basis_vectors()[source]¶
Returns the basis vectors. This function is necessary because the basis vectors are stored “by-coarse-grid-index” and not on a fine grid.
- get_coarse_operator(fine_operator)[source]¶
Given a fine operator
fine_operator(psi), construct a coarse operator.In case of a 9-point operator, such as Wilson and Wilson-Clover Dirac operator, a significantly faster implementation can be achieved by using
qcd_ml.qcd.dirac.coarsened.coarse_9point_op_NG.