Incorrect evaluation of Ref
Assigning the result of bottomRows
to Eigen::Ref does not seem to work correctly:
#include <iostream>
#include <Eigen/Dense>
int main() {
constexpr int num_rows = 3;
constexpr int num_columns = 4;
Eigen::MatrixXd y = Eigen::MatrixXd::Random(num_rows, num_columns);
constexpr int num_bottom_rows = 1;
const Eigen::Ref<const Eigen::Matrix<double, num_bottom_rows, num_columns>> z =
y.bottomRows(num_bottom_rows);
// These should be the same but are not.
std::cout << y.bottomRows(num_bottom_rows) << '\n'
<< z << '\n';
}
Example output:
$ clang++ -std=c++17 -I/home/luke/repos/eigen ./eigen_ref_mwe.cpp -o ./eigen_ref_mwe; ./eigen_ref_mwe
0.566198 -0.604897 -0.444451 0.257742
0.566198 0.59688 0.823295 -0.604897
I've tracked this down on the following commit on the 3.3 branch: 7b93328b
The parent commit 6adb70d3 does not exhibit the issue.