Inner vs outer stride on column-major RowArray/RowVector: behaviour OR documentation incorrect
Summary
From the documentation on Stride
, for column-major matrices:
"The inner stride is the pointer increment between two consecutive entries [...] within a given column of a column-major matrix.
The outer stride is the pointer increment between [...] two consecutive columns of a column-major matrix."
This does not hold true for RowArray
/RowVector
types, or could at least be clearer. When RowsAtCompileTime == 1
, then the inner stride decides on the pointer increment between two consecutive columns of a column-major matrix.
Environment
- Operating System : Linux
- Architecture : x64
- Eigen Version : 3.3.9
- Compiler Version : GCC 10.3.0
- Compile Flags : -O3
Minimal Example
#include <Eigen/Dense>
#include <iostream>
int main(){
using namespace Eigen;
ArrayXi arr (12);
arr.setLinSpaced(0, 11);
using RowArrayXi = Array<int, 1, Dynamic>;
Map<RowArrayXi,0,OuterStride<2>> outer { arr.data(), 1, 6 };
Map<RowArrayXi,0,InnerStride<2>> inner { arr.data(), 1, 6 };
std::cout
<< "with outer stride = 2: " << outer
<< "\nwith inner stride = 2: " << inner
<< "\n";
return 0;
}
Expected output:
with outer stride = 2: 0 2 4 6 8 10
with inner stride = 2: 0 1 2 3 4 5
Actual output:
with outer stride = 2: 0 1 2 3 4 5
with inner stride = 2: 0 2 4 6 8 10
Steps to reproduce
See MWE, easily reprodicible.
What is the current bug behavior?
Documentation and behaviour do not match each other.
What is the expected correct behavior?
Documentation and behaviour should match each other. Whether InnerStride
or OuterStride
should be used on column-major row-arrays is a design decision. I can see reasons for either. But it should be reflected in the documentation.
Anything else that might help
Possible addition to the documentation: "For vector-like objects (ColsAtCompileTime==1
or RowsAtCompile==1
), the inner stride decides on the pointer increment between two consecutive entries and the outer stride is ignored."