Registered Member
|
I have spent some time testing the example code provided in the two previous forum posts I found on the topic, and I have also tried to adjust the lines of code provided in the tutorial, but I don't quite seem to understand how to use the SVD. Could someone please provide me with a working example code?
I just downloaded Eigen 2.0.3 and tested this bit of code:
It compiles, but after the output "..." the code crashes and the following error message is printed to the console:
Thanks for your help. Magnus |
Registered Member
|
It looks like the specified dimensions are not compatible. The matrix A and the vector b should have the same number of rows (that is probably what the mysterious error message is trying to tell you). In your case, the matrix A is 26 x 12 (26 rows, 12 columns), but the vector b has 12 rows. So change
Disclaimer: I didn't try it myself. I get a mysterious error, probably due to an out-of-date library. |
Registered Member
|
There are two more issues:
This leads to the following code, which works on my machine:
|
Registered Member
|
Thanks!
The size of vector b was a sloppy mistake by me. Also, I concentrated on the solve function so I didn't pay attention to the 3-by-3 matrices at the end. With your suggested size changes, the code now works. This is what it finally looks like (for future reference):
Slightly OT: I checked the singular values and the values in the last column of V returned by Eigen against those returned by Matlab. Eigen (or Matlab ) is accurate down to the fourth decimal which is going to work just nicely for my application. Thanks. Magnus Edit: Typo. |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]