This code uses LOBPCG to find the minimum eigenvalue of a matrix. Knowledge of the minimum eigenvalue can be used to regularize the matrix to be positive (semi)definite.
Add LOBPCG to your matlab folder, and then run
lobpcg_setup.m
Using LOBPCG is very simple. For a sparse symmetrical matrix A, do
lambda = lobpcg_mex(A);
If A is dense, do
lambda = lobpcg_mex(sparse(A));
The algorithm implemented here is described in detail in Algorithm 4.1 in
Knyazev, A. V. (2001). Toward the optimal preconditioned eigensolver: Locally optimal block preconditioned conjugate gradient method. SIAM journal on scientific computing, 23(2), 517-541.
The method also makes use of the eigenvalue problem solving implemented in LAPACK, particularly of dsyev
and dsygv
.