Re: [eigen] Re: mixing Matrix types in expressions containing reductions

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


2010/10/31 Patrick Sauer <pat05.mlst@xxxxxxxxx>:
> Hi,
>
> I'm trying to compute the variance of data vectors contained in the rows of
> an Eigen3 matrix, i.e.:
>
> MatrixXd Y              = MatrixXd::Random(2,3);
> VectorXd mean        = Y.colwise().mean();
> MatrixXd variance    = (Y.colwise().squaredNorm()/Y.rows()).array() -
> mean.array()*mean.array();
>
> Strangely, with this code the variance vector contains only the variance
> over the first column. However, changing the "VectorXd mean" declaration to
> "MatrixXd mean" solves this problem and the code yields the correct result.

Looks like you found a bug.

What happens with "RowVectorXd mean" ?

Benoit


> Is this behaviour expected? Could the compiler provide the user with a hint
> here, or does the user need to remember to use equivalent types in
> expressions containing reduction operations?
>
> Thanks.
>
> Kind regards,
>
> Patrick
>



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