Open clairevalva opened 2 years ago
Currently, we assume(d) the input is Real
.
A quick fix would be to compare the magnitude and truncation:
function truncated_svd(A::AbstractMatrix{T}, truncation::Real) where T <: Number
truncation = min(norm(convert(T, truncation)), norm(one(T)))
U, S, V = svd(A)
r = vec(S .> truncation*maximum(S))
U = U[:, r]
S = S[r]
V = V[:, r]
return U, S, V
end
We should probably throw an error message much sooner then that makes it clear that complex isn't supported here.
An error sooner would be nice :) (But at least for the case of DMDSVD, there is no particular reason intrinsic to the algorithm itself that requires real input.)
truncated_svd appears to be unable to handle complex matrices (both with the method of truncation by explicit rank or tolerance). The following code which uses truncated_svd() via DMDSVD() fails.
with errors: