second mdim op test works

This commit is contained in:
Christian Zimmermann 2017-08-25 22:33:05 +02:00
parent 8a1cc35089
commit c4431a83a9

View file

@ -92,6 +92,7 @@ namespace {
std::shared_ptr<MRange> mr2ptr; std::shared_ptr<MRange> mr2ptr;
std::vector<double> v1 = { 2.917, 9.436, 0.373 }; std::vector<double> v1 = { 2.917, 9.436, 0.373 };
std::vector<double> v2 = { 8.870, 4.790 }; std::vector<double> v2 = { 8.870, 4.790 };
std::vector<double> v3 = { 0.353, 4.005, 1.070, 2.310, 9.243, 2.911 };
}; };
TEST_F(OpTest_1Dim, ExecOp) TEST_F(OpTest_1Dim, ExecOp)
@ -130,6 +131,35 @@ namespace {
EXPECT_EQ( fabs( res.at(mkt('3','B')) - (0.373 + 4.790) ) < 0.0001, true ); EXPECT_EQ( fabs( res.at(mkt('3','B')) - (0.373 + 4.790) ) < 0.0001, true );
} }
TEST_F(OpTest_MDim, ExecOp2)
{
MultiArray<double,MRange,SRange> res(mr1ptr,sr4ptr);
MultiArray<double,MRange> ma1(mr1ptr, v3);
MultiArray<double,SRange> ma2(sr4ptr, v2);
auto i1 = std::dynamic_pointer_cast<MRange::IndexType>( mr1ptr->index() );
auto i2 = std::dynamic_pointer_cast<SRange::IndexType>( sr4ptr->index() );
res(i1,i2) = ma1(i1) + ma2(i2);
EXPECT_EQ( fabs( res.at(mkt(mkt('1','a'),'A')) - (0.353 + 8.870) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('1','a'),'B')) - (0.353 + 4.790) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('1','b'),'A')) - (4.005 + 8.870) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('1','b'),'B')) - (4.005 + 4.790) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('2','a'),'A')) - (1.070 + 8.870) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('2','a'),'B')) - (1.070 + 4.790) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('2','b'),'A')) - (2.310 + 8.870) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('2','b'),'B')) - (2.310 + 4.790) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('3','a'),'A')) - (9.243 + 8.870) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('3','a'),'B')) - (9.243 + 4.790) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('3','b'),'A')) - (2.911 + 8.870) ) < 0.0001, true );
EXPECT_EQ( fabs( res.at(mkt(mkt('3','b'),'B')) - (2.911 + 4.790) ) < 0.0001, true );
}
} // anonymous namspace } // anonymous namspace