Created attachment 12 [details] Simple test cases There seem to be some issues with using LinSpaced with row vectors. Simply outputting something like RowVectorXd::LinSpaced(3, 0, 1) works, but comparing RowVectorXd::LinSpaced(3, 0, 1) == RowVector3d(0, 0.5, 1) fails and performing the explicit conversion MatrixXd(RowVectorXd::LinSpaced(3, 0, 1)) produces a matrix of all zeros. All the corresponding VectorXd versions work; I've attached a file that demonstrates the issue. Eigen 3 Beta 2 g++ --version: i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Thanks for pointing this out. I just fixed it. The issue is that during two dimensional indexing the linspace functor always assumed 'row' to be the running index whereas in your example it is 'col'. My fix was to use row + col as the new index since either of the to must be zero. I am also checking this with ei_assert. A regression test was added too.
I would fix it like this.... template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar> struct ei_plain_row_type { typedef Matrix<Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> MatrixRowType; typedef Array<Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> ArrayRowType; typedef typename ei_meta_if< ei_is_same_type< typename ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, MatrixRowType, ArrayRowType >::ret type; }; - Hauke
(In reply to comment #2) > I would fix it like this.... > > template<typename ExpressionType, typename Scalar = typename > ExpressionType::Scalar> > struct ei_plain_row_type > { > typedef Matrix<Scalar, 1, ExpressionType::ColsAtCompileTime, > ExpressionType::PlainObject::Options | RowMajor, 1, > ExpressionType::MaxColsAtCompileTime> MatrixRowType; > typedef Array<Scalar, 1, ExpressionType::ColsAtCompileTime, > ExpressionType::PlainObject::Options | RowMajor, 1, > ExpressionType::MaxColsAtCompileTime> ArrayRowType; > > typedef typename ei_meta_if< ei_is_same_type< typename > ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, > MatrixRowType, > ArrayRowType >::ret type; > }; > > - Hauke I don't know what happened here. Sorry for the noise.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/79.