[eigen] Eigen objects as vectors and matrices

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

I want to an object both as a matrix and as a vector, so I am constructing the object using
    Matrix<double, Dynamic, Dynamic> object(m*n, 1);
and then plan to do an
    object. conservativeResize(m, n)
before using it as a matrix. The problem is that the bracket operator
does not seem to work when object is a vector (and the software I am using access vectors this way).

For example, the following source code does not compile:

    # include <Eigen/Dense>
    int main(void)
         using Eigen::Matrix;
         using Eigen::Dynamic;

         typedef Matrix<double, Dynamic, Dynamic> matrix;

         matrix v(2,1);
         v[0] = 1.0;
         v[1] = 2.0;

         return 0;

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