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
enabled complex eigenvectors for lapack #1106
Conversation
@Andlon Is there any update on this issue? Im stuck compiling against my local nalgebra version |
@metric-space Maybe you are the better ping since you implemented the current function |
@geoeo: Sorry, I did not mean to ignore you for so long. I'm not too familiar with the I'm also confused - the original issue in #1105 states that the eigenvalue computation crashes. However, this PR completely changes the signature of the method. Wouldn't it be better to separately fix the computation of the eigenvalues and have a separate routine for the eigenvectors? |
@Andlon Yes. Maybe my attempt to explain this was very convoluted, since I wasnt sure what was going on at the start. I fixed two issues I had with the codebase:
I am completely open to putting this a new function. I just wanted to get some feedback on my code and have this being tracked. |
I was just reviewing the code and I dont think its a good idea to split up the method into two. The problem is that as stated above: So in order to check if an eigenvector is complex I query the corresponding eigenvalue. Its similar to the lapack method which has the same signature. There is also only one method for that. I can rename it though since the name is no longer descriptive |
@Andlon could you give feedback if this would be mergable or what is still neccessary? |
@geoeo apologies for the radio silence to your ping. Haven't had the time to look at this (still don't ). That said please note I am just a contributor and am not a maintainer like @Andlon or @sebcrozet |
@geoeo: I'm sorry but I don't really know the code base of I'd also say the current API is very strange, as I don't understand why |
@Andlon i think a real square matrix can have complex eigenvales in conjugate pairs |
@geoeo: indeed it can, but the |
@sebcrozet hey. Any update on this? |
@geoeo Thanks for this PR! I pushed some change to:
Please, let me know if you have any issue with these changes. |
Now that the complex eigenvalues are stored into |
As far as I can tell everything is working fine. I can have a look at the computation of the explicit complex eigenvectors. |
@sebcrozet Im having trouble with the generics for a complex number.
|
The error I'm getting is
I believe the error has more to do with your dimension constraints than the non-existence of the method from the below nalgebra/src/base/construction.rs Line 647 in 74c4aa9
and Eigen has type constraint of One way out is to replace It's been a while so I could be wrong |
Im careful with chaning the constraints. That whole system is a but opaque to me. But if its the only way then so be it. |
@geoeo Switching to 187: let (number_of_elements, _) = self.eigenvalues_re.shape_generic();
202: for mut i in 0..number_of_elements.value() {
209: let mut r1_vec = OVector::<Complex<T>, D>::zeros_generic(number_of_elements, Const::<1>);
210: let mut r1_vec_conj = OVector::<Complex<T>, D>::zeros_generic(number_of_elements, Const::<1>); |
@sebcrozet @metric-space Thanks a lot. I pushed an initial version that compiles. But I would want to write a test for it. Do you know of a "standard" matrix which produces complex eigenvalues that I can check against? |
I found this test matrix from https://textbooks.math.gatech.edu/ila/1553/complex-eigenvalues.html Ill park this here |
@sebcrozet Feel free to review. I wrote an example/test for eigenvalues and (right) eigenvectors. I had to change the Cargo.toml to make it build. |
Thank you for your perseverance @geoeo. I think we are good to merge this version. |
As mentioned in #1105
complex eigenvector computation is actually implemented but the complex values are simply discarded.
I changed the signature of
complex_eigenvalues()
to maybe return the eigenvectors.Important! : I do not return the complex type because it would require an n^2 iteration according to: http://www.netlib.org/lapack/explore-html/d9/d8e/group__double_g_eeigen_ga66e19253344358f5dee1e60502b9e96f.html
If the j-th eigenvalue is real, then u(j) = VL(:,j), the j-th column of VL. If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then u(j) = VL(:,j) + iVL(:,j+1) and u(j+1) = VL(:,j) - iVL(:,j+1).
I simply return the eigenvector matrix as is. Any user interested in the complex eigenvectors would have to do this themselves. Usually one would be interested in the real vectors (at least for me). This should probably be documented and is somewhat at odds with the current interface.
Furthermore I replaced the macro calls if
lapack_info!
withlapacl_panic!
due to typing issues