Hi. Given a matrix M I would like to compute its SVD truncated to rank k. I think this is possible without doing the full SVD. For example, Python has this: sklearn.decomposition.TruncatedSVD β scikit-learn 1.1.2 documentation. The code I am currently using to do this is given below. The problem is that it computes SVD first, and then throws out the extra rows/columns, which can be quite costly if k is much smaller than rank of M. Is there a function in Julia to do this?
using LinearAlgebra
"return U, S, Vt truncated to rank k"
function truncated_svd(M, k)
@assert k <= min(size(M)...)
F = svd(M)
SVD(F.U[:,1:k], F.S[1:k], F.Vt[1:k,:])
end