Commit 5e770e84 authored by Davis King's avatar Davis King

Changed pinv() so it interprets its tol argument relative to the largest

singular value of the input matrix rather than as an absolute tolerance.
parent b271d5c8
......@@ -1595,8 +1595,8 @@ convergence:
const double machine_eps = std::numeric_limits<typename EXP::type>::epsilon();
// compute a reasonable epsilon below which we round to zero before doing the
// reciprocal. Unless a non-zero tol is given then we just use tol.
const double eps = (tol!=0) ? tol : machine_eps*std::max(m.nr(),m.nc())*max(w);
// reciprocal. Unless a non-zero tol is given then we just use tol*max(w).
const double eps = (tol!=0) ? tol*max(w) : machine_eps*std::max(m.nr(),m.nc())*max(w);
// now compute the pseudoinverse
return tmp(scale_columns(v,reciprocal(round_zeros(w,eps))))*trans(u);
......
......@@ -44,7 +44,7 @@ namespace dlib
- singular values less than max(m.nr(),m.nc()) times the machine epsilon
times the largest singular value are ignored.
- else
- singular values less than tol are ignored.
- singular values less than tol*max(singular value in m) are ignored.
!*/
// ----------------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment