Choosing algorithm for SVD

The svd function in LinearAlgebra package has an option to select the algorithm for factorization method. But could not find proper way to use it.

using LinearAlgebra
A= rand(Float32, 10, 20);
F = svd(A, full=true) # works fine 
F2 = svd(A, full=true, alg=QRIteration()) # does not work

Asks me to use LinearAlgebra.Algorithm and when I use it :

F2 = svd(A, full=true, alg=LinearAlgebra.QRIteration())
#throws and error saying

ERROR: TypeError: in keyword argument alg, expected LinearAlgebra.Algorithm, got Type{LinearAlgebra.QRIteration}

What is the proper use of another algorithm for svd ?
Yet another question is can svd be used with CUDA.jl ?

B.R.

This works for me with Julia 1.5.3. What version of Julia are you using?

1 Like

versioninfo() shows 1.5.2 . Probably, I didn’t write it as a function call QRIteration().

Thaks

Is there a reason we have to write the function with () at the end? This seems inconsistent with the way other functions are passed as arguments, e.g. sum(exp, rand(5)).

1 Like

Is there a reason we have to write the function with () at the end? This seems inconsistent with the way other functions are passed as arguments, e.g. sum(exp, rand(5)) .

nice point

LinearAlgebra.QRIteration() is a call to a constructor (for the QRIteration type), it’s not a function like exp.

4 Likes