Re: [eigen] Documentation for Eigen::{fitHyperplane,linearRegression}

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Yes, I'm aware there's a problem there actually, I was too lazy to fix it....

I can't use your code as-is because the use of "new" here is really
inefficient, but i'll try to fix it soonish.

However the LeastSquares module is probably going away in eigen3 as we
figured that 1) it was really hard to come up with a good universal
API and 2) it's always very easy to do with just a SVD decomposition.

Benoit

2010/4/20 Tilman Vogel <tilman.vogel@xxxxxx>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I think, the example in the documentation is incorrect. The parameter
> "points" is documented as "the array of pointers to the points on which
> to perform the linear regression" and the code reveals that it is used
> as such, however, the example does:
>
> Vector3d points[5];
> points[0] = Vector3d( 3.02, 6.89, -4.32 );
> points[1] = Vector3d( 2.01, 5.39, -3.79 );
> points[2] = Vector3d( 2.41, 6.01, -4.01 );
> points[3] = Vector3d( 2.09, 5.55, -3.86 );
> points[4] = Vector3d( 2.58, 6.32, -4.10 );
>
> Vector3d coeffs; // will store the coefficients a, b, c
> linearRegression(
>  5,
>  &points,
>  &coeffs,
>  1 // the coord to express as a function of
>  // the other ones. 0 means x, 1 means y, 2 means z.
> );
>
> I.e. it passes a pointer to an array of points instead of an array of
> pointers to points. Which is formally correct w.r.t. the level of
> indirection, but actually, gcc 4.4.1 won't accept it. It can be forced
> by doing
>
> Vector3d * p = points;
> linearRegression(
>  5,
>  &p,
>  &coeffs,
>  1 // the coord to express as a function of
>  // the other ones. 0 means x, 1 means y, 2 means z.
> );
>
> but it will cause a segfault as expected.
>
> The example should be fixed to be:
>
> Vector3d * points[5];
> points[0] = new Vector3d( 3.02, 6.89, -4.32 );
> points[1] = new Vector3d( 2.01, 5.39, -3.79 );
> points[2] = new Vector3d( 2.41, 6.01, -4.01 );
> points[3] = new Vector3d( 2.09, 5.55, -3.86 );
> points[4] = new Vector3d( 2.58, 6.32, -4.10 );
>
> Vector3d coeffs; // will store the coefficients a, b, c
> linearRegression(
>  5,
>  points,
>  &coeffs,
>  1 // the coord to express as a function of
>  // the other ones. 0 means x, 1 means y, 2 means z.
> );
>
>
> Regards,
>
> Tilman
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.12 (GNU/Linux)
> Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkvNeeQACgkQ9ZPu6Yae8lk99gCeO8oeiGJE91/L4KGr0PlyjtHs
> Gs8AnjhD/8bmkiFdraFdp3/ZxNbX74tk
> =sNGM
> -----END PGP SIGNATURE-----
>
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/