-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Justification for eig, eigvecs, eigvals and eigfact? #322
Comments
I think it could be worth cleaning up some namespace here. |
The reason to define As I read your proposal, Right now, a problem with the factorizations is that extracting the factors is not type stable. Hopefully, something like dot overloading will fix that and cleaning up the namespace will probably be easier at that point. |
Indeed. Maybe with a keyword argument?
No, my proposal is to keep only the variant returning a
Maybe |
@vtjnash Do you think |
what makes you think that it isn't? all it needs is an iterable:
that's an interesting combination. i don't see an obvious way to make this work however. i like the iteration version. i think carnaval has been talking about providing a way to make the getindex version easier as well, perhaps in v0.6. |
@vtjnash I guess I should have tried destructuring a non-tuple. That's cool. Regarding |
This statement is correct only as the generic fallback for types like ordinary matrices. For some specialized matrix types (notably I introduced
|
But it doesn't look like we're ready to replace it with |
i was roughly thinking that the |
Hmm, I'm not sure how that would work. Returning an immutable sounds quite natural here (if it weren't for the impossibility of destructuring it). I've played a bit more with
UPDATE: |
Since |
Actually, I don't think Is it expected that the |
it should be eliminated unfortunately this happens at codegen time and it's too late to get the inferred type right. This is indeed a known issue. |
OK, thanks. So it looks like we'll have to wait for this to work. |
Looks like inference has progressed in 0.5 and master (compared to 0.4.7). Now, the example from my comment above is correctly inferred. Unfortunately, I've not been able to make the destructuring using iteration protocol type stable. In the two following functions, the type of the first variable ( import Base.Eigen
Base.start(::Eigen) = Val{:values}
Base.done(::Eigen, state) = state <: Val{:done}
function Base.next{T}(x::Eigen, state::Type{T})
if T <: Val{:values}
return x.values, Val{:vectors}
elseif T <: Val{:vectors}
return x.vectors, Val{:done}
else
throw(KeyError(T))
end
end
function f(A)
a, b = eigfact(A)
a, b
end
A = Symmetric([1 0; 0 1])
@code_warntype f(A)
function g(A)
f = eigfact(A)
s = start(f)
a, s = next(f, s)
b, s = next(f, s)
a, b
end
@code_warntype g(A) |
For triage: is there anything we could be done for 0.7 here? If we expect to make |
If we move |
Triage thinks we should wait until a solution for |
@andreasnoack Do you plan to change any of the functions mentioned here? |
Yes. I'll try to continue the work in JuliaLang/julia#25187 and see if can work generally. |
In a similar vein, is there any reason for |
+1 to cleaning up things that set us up for the long term. |
Fixed by JuliaLang/julia#27212 |
I wonder whether we really need to offer
eig
,eigvecs
andeigfact
at the same time.eig
andeigvecs
are respectively a two- and a one-line wrapper aroundeigfact
.Also, maybe
eigvals!
could be replaced with aneigfact!
function taking the vector in which to store eigenvectors. This would allow getting rid ofeigvals
, which is yet another wrapper aroundeigfact
.The same applies to the
svd*
family of functions.A more speculative note: if tuple destructuring was extended to immutables, one could write directly
val, vec = eigfact(X)
. This would offer a perfect replacement foreig
.The text was updated successfully, but these errors were encountered: