[eigen] Using Eigen::Map to use eigen operations on my data |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
I must be missing something. The following code prints:
[1 2 3 4]
1 0
0 1
although I thought that the point of Map was to create an object that
shared memory with an underlying array. What am I Missing?
R
#include <iostream>
#include "Eigen/Core.h"
using namespace std;
using namespace Eigen;
void identity(MatrixXf *mat) {
(*mat)(0, 0) = (*mat)(1, 1) = 1;
(*mat)(1, 0) = (*mat)(0, 1) = 0;
}
int main() {
float data[4] = { 1, 2, 3, 4 };
MatrixXf mat2x2 = MatrixXf(Map<MatrixXf>(data, 2, 2));
identity(&mat2x2);
cout << "[" << data[0] << " " << data[1] << " " << data[2] << "
" << data[3] << "]\n" << mat2x2 << endl;
}