-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support complex matrices? #6
Comments
I have not considered complex matrices, but there is not reason not to allow them right away! I'll have a look and see what we can do |
The following now works on u = randn(ComplexF64, 100)
v = randn(ComplexF64, 20)
E = randn(ComplexF64,100,20) .* 10 .* (rand.() .< 0.01)
A = u*v'
D = A .+ E
Ah, Eh, s, sv = rpca(D)
@test sum(abs2, Eh-E)/sum(abs2, E) < 1e-5
@test sum(abs2, Ah-A)/sum(abs2, A) < 1e-5 I had to find a replacement for the soft thresholding operator for complex numbers, the following seems to work okay but not much thought has gotten into it @inline function soft_th(x::Complex, ϵ)
m,a = abs(x), angle(x)
m = max(m-ϵ,zero(m)) + min(m+ϵ,zero(m))
m*cis(a)
end |
Great, thanks! I’ll try it out and see if this improves things over regular PCA for my problem. |
I'm not sure if the underyling algorithm is amenable to supporting complex matrices. If so do you think it's an easy add to the package? Currently it throws an error trying to get
eps(::Complex)
MWE:
The text was updated successfully, but these errors were encountered: