Registered Member
|
Hi,
I got a problem with the Eigen 3.0-beta1 SVD Module. Im using it to solve a Problem with a few thousand equations. Sometimes I get "access violation at address ..." (I hope its the correct translation . The real Problem is the "sometimes". In 3 out of 10 tries i get the error, and the other tries work perfectly. The Error occurs in the Line 471 in the SVD.h while executing "Scalar si = dec().singularValues().coeff(i);" I tested and debugged the last two days and im nearly sure that i did not broke anything in the memory My programm is a little to big to show it here, but i made a little example where i get the same error:
I know that 7000 is a big number, but i do not get a bad alloc. Bad_allocs occur with numbers bigger 10000 (at my machine), which is absolutely logical With Eigen 2.0 everything works good... except the fact that the results are not exact enough edit: Now i happens already with 500 instead of 7000.... and i definitely have enough memory for this Any hints? greets chef_seppel |
Registered Member
|
Hi,
we need more detail in order to help you. Right now, I am unable to reproduce your error on my machine (vs2010, 64bit build, debug+release) with this code
In order to be able to help you, we need a self-contained example (i.e. I can take it and compile it) that shows the problem and information regarding your build environment (compiler version, are you building 32 or 64 bit version, is vectorization enabled, etc). Typically I would say, such random behavior is most likely being caused by a bad memory access but since you say Eigen 2 is working I am a bit surprised. Regards, Hauke |
Registered Member
|
Thanks for the reply, here are more informations:
I'm using Windows7, Visual Studio 2008 on a Intel Core 2Quad CPU @ 2.66GHz with a 32-bit Operating System. I'm not sure with the Vectorization.. but i did not change anything, so it should be the default. To reproduct the error: Visual Studio-> New Project-> Win32-Console Application and everything on default. Then add the Eigen-directory to the include-Directories and replace everything in the .cpp with this:
I just noticed that it works in release mode but crashes in the Debug Mode at the above mentioned point.
Me two Greets chef_seppel |
Registered Member
|
We can reproduce the error and its being worked on.
Thanks for pointing this out! - Hauke |
Registered Member
|
Thats great!
Thank you for all your work! |
Registered Member
|
It turns out that the reason why your latter program is failing is that there actually IS NO SOLUTION to your equation. Your 500-dimensional random RHS vector just isn't in the linear span of the 5 columns of your matrix. Our documentation is pretty clear that in this case the result is undefined.
Pushed Hauke's fix to your access violation error, plus an improved unit test and an assertion that rows >= cols.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Hmm... I do not understand the problem. I got 500 Equations and only 5 parameters to optimize... why shouldn't that be possible. (Except the fact that it's all random and the results don't mean anything). I got a highly overdetermined equation system (i hope the translation is right , which should be solvable.
Where exactly? I don't find the right part. Thanks again for everything |
Registered Member
|
I was talking about the example we discussed in this thread. Sure you can see it as an overdetermined system, but since the coeffs are *random*, the solution you'll get won't have any sort of significance. Yes, if you apply this to a real-world overdetermined system (i.e. when a good approximate solution is meant to exist) you'll get your solution, because SVD::solve is implicitly doing least squares. Important: for this kind of very-rectangular matrices, you will get much, much better results using JacobiSVD than SVD (in Eigen 3). You'll get even better results if you let Eigen know at compile time that the number of columns is 5, by using this matrix type: Matrix<double, Dynamic, 5> instead of MatrixXd.
i was thinking about http://eigen.tuxfamily.org/dox-devel/cl ... 028fa45b4d but it's true that in the case of SVD, it is implicitly doing least-squares, so you can ignore what I said. It's just that in the example here, with random coeffs, least squares doesn't make much sense.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
but JacobiSVD doesn't have a solve-function?
Good to know, but in my problem not possible Thanks again chef_seppel |
Registered Member
|
True. But it's so easy to implement! Notice that you can implement least squares using only V, not U, which will allow you to go much faster. (Dont remember the details but it's in the wikipedia page on least squares).
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]