Open mshoe opened 4 years ago
this is a good point. Eigen operators also have an eval method you can use to force evaluation of commands. Otherwise eigen does lazy evaluation (waiting until you assign the operations to a variable) in order to maximize performance.
Say you have a matrix that you want to flatten into a vector. You notice that Eigen is column major by default, so just calling .data() will give you the data in column major order. Since you want your flattened vector to be row major order, you instead call .transpose().data(). But .transpose() doesn't actually modify the data of the original matrix, so you will still get a column major ordered vector. Instead you need to call .transposeInPlace() first, then call .data().