What happens when you pass a matrix object into a function as a MatrixBase reference? I do not get what really happens behind the scenes.
An example function code would be:
#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 output:
size (rows, cols): 4 (2, 2)
1
16
Where does the 16 vs. 1 difference come from?
And also why would a conversion be necessary?
Thanks in advance!