Registered Member
|
Hi...
I'm trying to do a linear regression, based on this example. If i create a minimal example (with a small change, because the example given inside the link does not compile...) i'm getting a segfault.... Maybe someone can point me in the correct direction?
Compile this segfaulting example by doing
Additionally, my own example does segfault, too...
Again, compiling is done by the following:
What am I doing wrong?
Last edited by emmett on Wed Feb 23, 2011 8:19 am, edited 4 times in total.
|
Registered Member
|
sorry for posting several times... firefox had some problems on my system, seems to be related to this. so the error pops up but the message is posted anyways...
|
Moderator
|
This is because the linearRegression function expect a array of pointers to points that is not what you are providing. Nevertheless, I'd rather recommend you to bypass this function and do your own cooking.
|
Registered Member
|
hm, this does not help me.
I want to use this functionality, because eigen2 is already used in the project, I can't introduce another dependency and my real usecase will be a little bit more complicated than this simple example... Might I suggest that the documentation is a little bit misleading in this case? Thanks for the reply, anyways And have a nice evening emmett |
Moderator
|
oh, indeed, the doc is not correct. If you still want to call this function then simply do:
std::vector<VectorType *> points_ptrs(size); for(int i = 0; i < size; i++) points_ptrs[i] = &(pPoints[i]); and call: linearRegression(size, &(points_ptrs[0]), &coeffs, 1); but actually I was suggesting you to directly use lower level Eigen features such as LU or Cholesky for standard least square or SelfAdjointEigenSolver for total least square. Note that linearRegression does a total least square fit, and maybe this is not what you are looking for. |
Registered Member
|
Hm, is this so? Indeed, this works... But to be honest, you could've saved me one day digging through my code, hating gdb and reading the page 20 times... Without knowing more...
May you tell me if I run into serious problems if I use linearRegression in the way you explained? I expected it to be something similiar so octaves "polyfit"-function. Anyways, it works and I don't want to dig into LU or Cholesky in the moment... Do you know if the developers are reading in this forum? Will someone fix the documentation? |
Moderator
|
the doc is already fixed actually
|
Registered Member
|
|
Registered Member
|
Dear All,
Maybe my question is stupid, but I need to solve it. My task is - compute coeficients for x data 8 points width. I am trying with eigen linearregression, but no success. I am not familiar with C++, just C, so maybe this is stupid question, but howto make this? My test code is:
when trying to compile I have folowing errors:
Could anybody help me? |
Registered Member
|
The first error is not that difficult to explain: Your program uses 'VectorType' but this type is not declared anywhere. You should replace it by Vector3d.
I never used the linearRegression() function, but I suspect that the second argument should be a C-style array; it cannot be of type std::vector. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]