mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Allow for negative strides.
Note that using a stride of -1 is still not possible because it would clash with the definition of Eigen::Dynamic. This fixes #747.
This commit is contained in:
committed by
David Tellenbach
parent
288d456c29
commit
0668c68b03
@@ -162,6 +162,32 @@ template<int Alignment,typename MatrixType> void map_class_matrix(const MatrixTy
|
||||
VERIFY_IS_APPROX(map,s1*m);
|
||||
}
|
||||
|
||||
// test negative strides
|
||||
{
|
||||
Matrix<Scalar,Dynamic,1>::Map(a_array1, arraysize+1).setRandom();
|
||||
Index outerstride = m.innerSize()+4;
|
||||
Scalar* array = array1;
|
||||
|
||||
{
|
||||
Map<MatrixType, Alignment, OuterStride<> > map1(array, rows, cols, OuterStride<>( outerstride));
|
||||
Map<MatrixType, Unaligned, OuterStride<> > map2(array+(m.outerSize()-1)*outerstride, rows, cols, OuterStride<>(-outerstride));
|
||||
if(MatrixType::IsRowMajor) VERIFY_IS_APPROX(map1.colwise().reverse(), map2);
|
||||
else VERIFY_IS_APPROX(map1.rowwise().reverse(), map2);
|
||||
}
|
||||
|
||||
{
|
||||
Map<MatrixType, Alignment, OuterStride<> > map1(array, rows, cols, OuterStride<>( outerstride));
|
||||
Map<MatrixType, Unaligned, Stride<Dynamic,Dynamic> > map2(array+(m.outerSize()-1)*outerstride+m.innerSize()-1, rows, cols, Stride<Dynamic,Dynamic>(-outerstride,-1));
|
||||
VERIFY_IS_APPROX(map1.reverse(), map2);
|
||||
}
|
||||
|
||||
{
|
||||
Map<MatrixType, Alignment, OuterStride<> > map1(array, rows, cols, OuterStride<>( outerstride));
|
||||
Map<MatrixType, Unaligned, Stride<Dynamic,-1> > map2(array+(m.outerSize()-1)*outerstride+m.innerSize()-1, rows, cols, Stride<Dynamic,-1>(-outerstride,-1));
|
||||
VERIFY_IS_APPROX(map1.reverse(), map2);
|
||||
}
|
||||
}
|
||||
|
||||
internal::aligned_delete(a_array1, arraysize+1);
|
||||
}
|
||||
|
||||
@@ -200,7 +226,7 @@ void bug1453()
|
||||
EIGEN_DECLARE_TEST(mapstride)
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
int maxn = 30;
|
||||
int maxn = 3;
|
||||
CALL_SUBTEST_1( map_class_vector<Aligned>(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_1( map_class_vector<Unaligned>(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( map_class_vector<Aligned>(Vector4d()) );
|
||||
|
||||
Reference in New Issue
Block a user