This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Unexpected behavior of resize() in ArrayXd

Tags: None
(comma "," separated)
lowsfer
Registered Member
Posts
5
Karma
0
Hi, I'm using ArrayXd in my code and I found the resize() function didn't what I think it should do. For simplicity, I'm showing this problem with the following code.
Code: Select all
#include <iostream>
#include <eigen3/Eigen/Core>
int main(int argc, char** argv)
{
        Eigen::ArrayXd arr;
        arr.resize(3,4);
        std::cout<<"rows="<<arr.rows()<<"\ncols="<<arr.cols()<<std::endl;
        return 0;
}

The output was
Code: Select all
rows=3
cols=1

I would expect "cols=4" however. If I use MatrixXd instead of ArrayXd, cols() will return 4. My understanding is that Matrix and Array should behave the same here, but no. Is it designed to be like this or a bug?
lowsfer
Registered Member
Posts
5
Karma
0
Well, solved the problem. ;) ArrayXd is not the array version of MatrixXd, but the array version of VectorXd. The array version of MatrixXd is ArrayXXd.
VectorXd -> ArrayXd
MatrixXd -> ArrayXXd


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]