Skip to content
Snippets Groups Projects
Commit 00250fb9 authored by Stephen Smith's avatar Stephen Smith
Browse files

added to pinv - actually zero singular values if they're less than tol (when...

added to pinv - actually zero singular values if they're less than tol (when inverting them), rather than just leaving them as they are
parent b5b63258
No related branches found
No related tags found
No related merge requests found
......@@ -513,7 +513,8 @@ namespace MISCMATHS {
float tol;
tol = MaximumAbsoluteValue(D) * Max(mat.Nrows(),mat.Ncols()) * 1e-16;
for (int n=1; n<=D.Nrows(); n++) {
if (fabs(D(n,n))>tol) D(n,n) = 1.0/D(n,n);
if (fabs(D(n,n))>tol) D(n,n) = 1.0/D(n,n);
else D(n,n) = 0.0; // reduce the number of columns because too close to singular
}
Matrix pinv = V * D * U.t();
pinv.Release();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment