I am using Eigen library in C++ .
My question is:
I have a fixed sized matrix A , Now I want to pass the pointer of a block of A (A.block(0,0,flag,flag) ) into a function.
For example:
int flag = 2;
Eigen::Matrix<int,3,3> A;
A<<1,2,3
4,5,6
7,8,9;
So I passed A.block(0,0,flag,flag).data() into the function but obviously when the function reads the values the reading order is still 1,2,3,4,......, but what I want is 1,2,4,5.
I think one way to achieve this is to create a dynamic matrix(B)(flag is not constant) to store the block of A, then pass the B.data() into the function. However, I had better not use dynamic matrix in my program.
I think another way is to fill the block as rows in the matrix and then pass A.data() into the function, as the following figure shows:
Can I use any faster/better operations instead of loops(because of big size of the matrix) to construct this or is there other way to pass the pointer of a block of a matrix?
Thanks in advance!
