Skip to content

Instantly share code, notes, and snippets.

@MatthieuBizien
Created December 12, 2013 22:11
Show Gist options
  • Save MatthieuBizien/7936480 to your computer and use it in GitHub Desktop.
Save MatthieuBizien/7936480 to your computer and use it in GitHub Desktop.
Eigen Map<> possible bug
#include <vector>
#include <Eigen/Dense>
class MatrixSequence
{
public:
MatrixSequence() {
data_.resize(1);
data_[0]=0;
}
Eigen::Map<Eigen::MatrixXd> matrix_compile() {
auto* beginning = &data_.at(0); //double*
Map<Matrix> out(beginning, 1, 0);
return out;
}
Eigen::Map<Eigen::MatrixXd> matrix_dont_compile() const {
auto* beginning = &data_.at(0); // const double*
Map<Matrix> out(beginning, 1, 0);
return out;
}
private:
std::vector<double> data_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment