3d reordering tests work (still not refactored)
This commit is contained in:
parent
678db24003
commit
b3f7dad655
2 changed files with 93 additions and 11 deletions
|
@ -30,9 +30,9 @@ namespace MultiArrayTools
|
|||
IndexType& iref = dynamic_cast<IndexType&>(*mIibPtr);
|
||||
for(iref = mArrayRef.begin().pos(); iref != mArrayRef.end(); ++iref){
|
||||
// build in vectorization later
|
||||
VCHECK(iref.pos());
|
||||
VCHECK(in.mIibPtr->pos());
|
||||
VCHECK(in.get());
|
||||
//VCHECK(iref.pos());
|
||||
//VCHECK(in.mIibPtr->pos());
|
||||
//VCHECK(in.get());
|
||||
get() = in.get();
|
||||
}
|
||||
return *this;
|
||||
|
@ -43,7 +43,7 @@ namespace MultiArrayTools
|
|||
MultiArrayOperationBase<T,Range>&
|
||||
MultiArrayOperationBase<T,Range>::operator=(const MultiArrayOperationBase<T, Range2>& in)
|
||||
{
|
||||
CHECK;
|
||||
//CHECK;
|
||||
in.linkIndicesTo(mIibPtr);
|
||||
for(*mIibPtr = mArrayRef.begin(); *mIibPtr != mArrayRef.end(); ++(*mIibPtr)){
|
||||
// build in vectorization later
|
||||
|
|
|
@ -54,18 +54,27 @@ namespace {
|
|||
|
||||
typedef MAT::SingleRange<char,MAT::RangeType::ANY> Range1dAny;
|
||||
typedef MAT::MultiRange<Range1dAny,Range1dAny> Range2dAny;
|
||||
typedef MAT::MultiRange<Range1dAny,Range1dAny,Range1dAny> Range3dAny;
|
||||
typedef MAT::MultiArray<int,Range2dAny> MultiArray2dAny;
|
||||
typedef MAT::MultiArray<int,Range3dAny> MultiArray3dAny;
|
||||
|
||||
ReorderTest() : r1({'a','b','c'}), r2({'a','b','c','d'}),
|
||||
ReorderTest() : r1({'a','b','c'}), r2({'a','b','c','d'}), r3({'a','b'}),
|
||||
ra(r1,r2), rb(r2,r1),
|
||||
ma(ra, {-5,6,2,1,9,54,27,-7,-13,32,90,-67}) {}
|
||||
r3da(r1,r2,r3), r3db(r1,r3,r2), r3dc(r3,r1,r2),
|
||||
ma(ra, {-5,6,2,1,9,54,27,-7,-13,32,90,-67}),
|
||||
ma3d(r3da, {-5,6,2,1,9,54,27,-7,-13,32,90,-67,
|
||||
-10,16,-2,101,39,-64,81,-22,14,34,95,-62}) {}
|
||||
|
||||
Range1dAny r1;
|
||||
Range1dAny r2;
|
||||
Range1dAny r3;
|
||||
Range2dAny ra;
|
||||
Range2dAny rb;
|
||||
Range3dAny r3da;
|
||||
Range3dAny r3db;
|
||||
Range3dAny r3dc;
|
||||
MultiArray2dAny ma;
|
||||
|
||||
MultiArray3dAny ma3d;
|
||||
};
|
||||
|
||||
TEST_F(OneDimTest, CorrectExtensions)
|
||||
|
@ -109,20 +118,18 @@ namespace {
|
|||
EXPECT_EQ(ma[i(i1 = 2, i2 = 3)], -67);
|
||||
}
|
||||
|
||||
TEST_F(ReorderTest, ReorderingWorks)
|
||||
TEST_F(ReorderTest, ReorderingWorks2d)
|
||||
{
|
||||
MultiArray2dAny ma2(rb);
|
||||
auto i = ma2.begin();
|
||||
auto i1 = i.template getIndex<0>();
|
||||
auto i2 = i.template getIndex<1>();
|
||||
CHECK;
|
||||
ma2("alpha","beta") = ma("beta","alpha");
|
||||
|
||||
EXPECT_EQ(ma2[i(i1 = 0,i2 = 0)],-5);
|
||||
EXPECT_EQ(ma2[i(i1 = 1,i2 = 0)],6);
|
||||
EXPECT_EQ(ma2[i(i1 = 2,i2 = 0)],2);
|
||||
EXPECT_EQ(ma2[i(i1 = 3,i2 = 0)],1);
|
||||
|
||||
EXPECT_EQ(ma2[i(i1 = 3,i2 = 0)],1);
|
||||
|
||||
EXPECT_EQ(ma2[i(i1 = 0,i2 = 1)],9);
|
||||
EXPECT_EQ(ma2[i(i1 = 1,i2 = 1)],54);
|
||||
|
@ -134,6 +141,81 @@ namespace {
|
|||
EXPECT_EQ(ma2[i(i1 = 2,i2 = 2)],90);
|
||||
EXPECT_EQ(ma2[i(i1 = 3,i2 = 2)],-67);
|
||||
}
|
||||
|
||||
TEST_F(ReorderTest, ReorderingWorks3d_Test1)
|
||||
{
|
||||
MultiArray3dAny ma3d2(r3db);
|
||||
auto i = ma3d2.begin();
|
||||
auto i1 = i.template getIndex<0>();
|
||||
auto i2 = i.template getIndex<1>();
|
||||
auto i3 = i.template getIndex<2>();
|
||||
ma3d2("alpha","beta","gamma") = ma3d("alpha","gamma","beta");
|
||||
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 0)],-5);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 0)],6);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 1)],2);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 1)],1);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 2)],9);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 2)],54);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 3)],27);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 3)],-7);
|
||||
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 0)],-13);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 0)],32);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 1)],90);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 1)],-67);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 2)],-10);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 2)],16);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 3)],-2);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 3)],101);
|
||||
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 0,i3 = 0)],39);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 1,i3 = 0)],-64);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 0,i3 = 1)],81);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 1,i3 = 1)],-22);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 0,i3 = 2)],14);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 1,i3 = 2)],34);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 0,i3 = 3)],95);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 2,i2 = 1,i3 = 3)],-62);
|
||||
}
|
||||
|
||||
TEST_F(ReorderTest, ReorderingWorks3d_Test2)
|
||||
{
|
||||
MultiArray3dAny ma3d2(r3dc);
|
||||
auto i = ma3d2.begin();
|
||||
auto i1 = i.template getIndex<0>();
|
||||
auto i2 = i.template getIndex<1>();
|
||||
auto i3 = i.template getIndex<2>();
|
||||
|
||||
ma3d2("gamma","alpha","beta") = ma3d("alpha","beta","gamma");
|
||||
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 0)],-5);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 0)],6);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 1)],2);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 1)],1);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 2)],9);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 2)],54);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 0,i3 = 3)],27);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 0,i3 = 3)],-7);
|
||||
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 0)],-13);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 0)],32);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 1)],90);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 1)],-67);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 2)],-10);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 2)],16);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 1,i3 = 3)],-2);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 1,i3 = 3)],101);
|
||||
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 0)],39);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 0)],-64);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 1)],81);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 1)],-22);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 2)],14);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 2)],34);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 0,i2 = 2,i3 = 3)],95);
|
||||
EXPECT_EQ(ma3d2[i(i1 = 1,i2 = 2,i3 = 3)],-62);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
|
|
Loading…
Reference in a new issue