I don't know if that is intended, or if providing only InnerStride was supposed to work only for 1D-Maps: const double data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; std::cout << "Unexpected behavior:\n"; std::cout << MatrixXd::Map(data, 2, 3, InnerStride<2>()) << "\n\n"; std::cout << MatrixXd::Map(data, 2, 3, InnerStride<>(2)) << "\n\n"; std::cout << "Expected behavior:\n"; std::cout << MatrixXd::Map(data, 2, 3, Stride<Eigen::Dynamic, 2>(2*3, 2)) << "\n\n"; Output: > Unexpected behavior: > 0 2 4 > 2 4 6 > > 0 2 4 > 2 4 6 > > Expected behavior: > 0 6 12 > 2 8 14 The solution would be to multiply the (current) outerStride by the innerStride, unless the outerStride is explicitly given. As this would silently break API (although only in cases which are unlikely intended), I don't want to change it without asking first. An alternative solution would be to prohibit providing InnerStride only, unless the Map is 1-dimensional. This could also break code, but it would result in compile errors (which then could be easily fixed).
Actually, the expected behavior would be given by: Eigen::Stride<Eigen::Dynamic, 2>(2*2, 2) > 0 4 8 > 2 6 10 i.e., OuterStride == InnerStride*InnerSize
This is indeed a bug. If no outer-stride is provided then it is automatically inferred from the sizes of the matrix. This is what says the doc. The problem is that inner-stride is assumed to be 1 in the respective code, which is clearly an unintentional shortcoming that needs to be fixed.
Fixed: https://bitbucket.org/eigen/eigen/commits/9d757a9d16ab/ https://bitbucket.org/eigen/eigen/commits/af00212cf3a4/ (3.3)
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1453.