Transformation history in MatrixBase <Derived>
What happens when you pass a matrix object to a function as a MatrixBase reference? I don’t understand what is really going on behind the scenes.
Example function code:
#include <Eigen/Core>
#include <iostream>
using namspace Eigen;
template <typename Derived>
void print_size(const MatrixBase<Derived>& b)
{
std::cout << "size (rows, cols): " << b.size() << " (" << b.rows()
<< ", " << b.cols() << ")" << std::endl;
std::cout << sizeof(b) << std::endl;
}
int main() {
Matrix<float, 2, 2> m;
m << 0.0, 0.1,
0.2, 0.3;
print_size(m);
std::cout << sizeof(m) << std::endl;
}
It gives the following result:
size (rows, cols): 4 (2, 2)
1
16
Where does the difference 16 versus 1 come from?
And why do you need a conversion?
Thanks in advance!
+4