Skip to content
Snippets Groups Projects
Commit d2b9866d authored by Matthew Webster's avatar Matthew Webster
Browse files

changes for overcomplete matrices

parent 35e7fda0
No related branches found
No related tags found
No related merge requests found
......@@ -512,10 +512,13 @@ namespace MISCMATHS {
}
}
ReturnMatrix pinv(const Matrix& mat)
ReturnMatrix pinv(const Matrix& mat2)
{
// calculates the psuedo-inverse using SVD
// note that the right-pinv(x') = pinv(x).t()
Matrix mat(mat2);
if ( mat2.Ncols() > mat2.Nrows() )
mat=mat.t();
Tracer tr("pinv");
DiagonalMatrix D;
Matrix U, V;
......@@ -527,6 +530,8 @@ namespace MISCMATHS {
else D(n,n) = 0.0; // reduce the number of columns because too close to singular
}
Matrix pinv = V * D * U.t();
if ( mat2.Ncols() > mat2.Nrows() )
pinv=pinv.t();
pinv.Release();
return pinv;
}
......
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