Closed JoeSpencer1 closed 1 year ago
As a stopgap solution I am creating the R matrix incorrectly. It is unable to find columns that are linearly independent yet, I think.
Complex eigenvalues require the double QR algorithm.
You'll have to use double steps. Follow these instructions on roughly page 15: https://people.inf.ethz.ch/arbenz/ewp/Lnotes/2010/chapter3.pdf
Once you have an upper hessenberg matrix (zeros below the diagonal), use this process. It's on page 66 (16). https://people.inf.ethz.ch/arbenz/ewp/Lnotes/2010/chapter3.pdf
I think the link above explains it best.
Ok, you need to do it in Hessenberg form.
Page 413 of textbook.
Page 413-Chapter 18.
You need to put matrices in upper Hessenberg form before QR-ing: Page 396-Chapter 18.
These are called Householder matrices, to get the row and the row below it.
https://www.youtube.com/watch?v=OqgYYqy0M4w Householder matrix
This video walks through Householder matrices better. https://www.youtube.com/watch?v=s_rhzm6uW_E
Or just the wikipedia article. https://en.wikipedia.org/wiki/Householder_transformation
Now it simplifies to a Householder matrix.
This video shows how to take the eigenvalues from a Schur matrix. You also need Householder form. https://www.youtube.com/watch?v=voKfs7M9Nr0
Whoops, I think those three actually only work for symmetric matrices. Instead you're just supposed to use the nn entry as the shift. https://web.stanford.edu/class/cme335/lecture5
I have it mostly working! Now there's just a segmentation fault that needs to be resolved.
I think I could resolve the seg fault (and create a few more) by using pointers instead of a vector.
Ok, breaking down the matrix into QR still works.
I think the part where I subtract an identity matrix multiplied by the imaginary portion got deleted.
At this point it can converge for complex eignevalues too. It seems like the order is reversed, though, and the pointers still do not work.
To keep the QR algorithm from going off track, make it not move to the next step until each of the bottom entries of the diagonal are there too. If it’s a complex eigenvalue, instead check the 2 entries of the diagonal that goes up to the right.
To receive the finished qr matrices, add vectors of vectors to the vector in the constructor. This way they won’t require more space.
Halleluja! It lives!
Now it can return a value for the QR algorithm, but it is still not accurate. I think I messed up the threshold for what's an accurate value to return.
I need to determine a way to make the matrices in the QR algorithm stay true to the previous matrices within a tighter tolerance.
Eureka! Now it skip straight to the end if the eigenvalues are all real instead of doing the risky cycling through other rows.
Hmm I actually just broke it again...
I've fixed it again. You might have to fiddle with the tolerances in the future.
I should make it so each term in this algorithm converges to within the accuracy of itself. I was measuring convergence with a number, but I think I should use a boolean operator instead. Also, the way the QR algorithm is currently set up it doesn't return any eigenvectors.
Ok, now it's within 0.00001 for the real portion and 0.00002 for the imaginary portion, which I'm saying is close enought.
Right now my QR algorithm is unable to create an R matrix that is totally upper triangular. It works pretty well for matrices with all real eigenvalues, but then for the case when a matrix has complex or imaginary eigenvalues it is unable to recognize that.