Can I use the same tolerance that the MATLAB rank() for dense matrices uses? This seems reasonable. See code below:
A = gallery('chebspec',3,0); % this will produce an ill-conditioned A. It has rank of 2.
[L,U,P] = lu(A);
s = abs(diag(U));
tolerance = max(size(A)) * eps(max(s))
singularPivots = s < tolerance
tolerance =
6.6613e-16
singularPivots =
3×1 logical array
0
0
1
What do you think? Is this good enough? I am leaning towards this is good enough. My rational is eigen values of U are on the diaganol. The eigen value relative size to each other is similar but not the same as looking at the relative size of the singular values. However, the analog seems close enough that this may be good enough. Your thought are welcomed.