diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index de3451b..07a4600 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -591,6 +591,7 @@ namespace MultiArrayTools inline void OperationMaster::AssignmentExpr:: operator()(size_t start, ExtType last) const { + //VCHECK(mSec.template get(last)); mM.add(start, mSec.template get(last) ); } diff --git a/src/include/ranges/container_range.h b/src/include/ranges/container_range.h index a7d6e4f..bff51cf 100644 --- a/src/include/ranges/container_range.h +++ b/src/include/ranges/container_range.h @@ -66,6 +66,9 @@ namespace MultiArrayTools template auto getPtr() const -> decltype( std::get( mIPack ) )&; + template + size_t getBlockSize() const { return std::get(mBlockSizes); } + const IndexPack& pack() const { return mIPack; } ContainerIndex& sync(); // recalculate 'IB::mPos' when externalControl == true diff --git a/src/include/ranges/multi_range.h b/src/include/ranges/multi_range.h index 795013f..ca75474 100644 --- a/src/include/ranges/multi_range.h +++ b/src/include/ranges/multi_range.h @@ -75,6 +75,9 @@ namespace MultiArrayTools template auto getPtr() const -> decltype( std::get( mIPack ) )&; + + template + size_t getBlockSize() const { return std::get(mBlockSizes); } // raplace instances (in contrast to its analogon in ContainerIndex // MultiIndices CANNOT be influences be its subindices, so there is diff --git a/src/include/ranges/rpack_num.h b/src/include/ranges/rpack_num.h index 636a3ed..5288b4a 100644 --- a/src/include/ranges/rpack_num.h +++ b/src/include/ranges/rpack_num.h @@ -276,7 +276,8 @@ namespace MultiArrayHelper const auto& ni = ii.template get(); const size_t max = ni.max(); const size_t tmp = getStepSize(ni, j); - ss += tmp * sx; + //ss += tmp * sx; + ss += tmp * ii.template getBlockSize(); sx *= max; RPackNum::getStepSizeX(ii, j, ss, sx); } @@ -507,7 +508,8 @@ namespace MultiArrayHelper const auto& ni = ii.template get<0>(); const size_t max = ni.max(); const size_t tmp = getStepSize(ni, j); - ss += tmp * sx; + //ss += tmp * sx; + ss += tmp * ii.template getBlockSize<1>(); sx *= max; } diff --git a/src/include/slice.h b/src/include/slice.h index 208e205..12e4ee5 100644 --- a/src/include/slice.h +++ b/src/include/slice.h @@ -15,6 +15,8 @@ namespace MultiArrayTools typedef ContainerRange CRange; typedef MultiArrayBase MAB; typedef ContainerIndex IType; + + using MultiArrayBase::operator(); DEFAULT_MEMBERS(ConstSlice); @@ -53,6 +55,9 @@ namespace MultiArrayTools typedef ContainerRange CRange; typedef MultiArrayBase MAB; typedef ContainerIndex IType; + + using MultiArrayBase::operator(); + using MutableMultiArrayBase::operator(); DEFAULT_MEMBERS(Slice); diff --git a/src/tests/op_unit_test.cc b/src/tests/op_unit_test.cc index 58955ce..69eb9e3 100644 --- a/src/tests/op_unit_test.cc +++ b/src/tests/op_unit_test.cc @@ -469,7 +469,7 @@ namespace { << std::endl; std::cout << "ratio: " << static_cast( end - begin ) / static_cast( end2 - begin2 ) << std::endl; } - + /* TEST_F(OpTest_Performance, PCheck) { MultiArray ma2(mrptr, cv2); @@ -508,7 +508,7 @@ namespace { //EXPECT_EQ( xround( res.at(mkt(700,900)) ), xround(res2[700*vs1 + 900]) ); } - + */ TEST_F(OpTest_1Dim, ExecOp) { MultiArray ma1(srptr, v1); @@ -675,10 +675,10 @@ namespace { MultiArray ma5(sr1ptr, v3); MultiArray ma6(sr3ptr, v2); - auto si0 = MAT::getIndex( sr1ptr ); - auto si1 = MAT::getIndex( sr2ptr ); - auto si2 = MAT::getIndex( sr3ptr ); - auto si3 = MAT::getIndex( sr4ptr ); + auto si0 = MAT::getIndex( sr1ptr ); // 'x' + auto si1 = MAT::getIndex( sr2ptr ); // '1' + auto si2 = MAT::getIndex( sr3ptr ); // 'a' + auto si3 = MAT::getIndex( sr4ptr ); // 'A' auto mi = MAT::getIndex( mr1ptr ); mi->operator()(si1,si2); @@ -704,10 +704,20 @@ namespace { ma7(si1,si3) = ma4(si0,si1,si2,si3).slc(si0,si2); si1->at('1'); - si3->at('A'); - Slice sl(sr1ptr,sr3ptr); - sl.define(si2,si3) = ma4(si0,si1,si2,si3); + si0->at('x'); + (*si2) = 0; + (*si3) = 0; + Slice sl(sr4ptr,sr3ptr); + sl.define(si3,si2) = ma4(si0,si1,si2,si3); + MultiArrayBase& slb = sl; + + MultiArray ma8(sr3ptr,sr4ptr); + //ma8(si2,si3) = ma4(si0,si1,si2,si3); + ma8(si2,si3) = slb(si3,si2); + EXPECT_EQ( xround( ma8.at(mkt('a','A')) ), xround( sl.at(mkt('A','a')) ) ); + EXPECT_EQ( xround( ma8.at(mkt('b','A')) ), xround( sl.at(mkt('A','b')) ) ); + EXPECT_EQ( xround( ma7.at(mkt('1','A')).at(mkt('x','a')) ), xround( ma4.at(mkt('x','1','a','A')) ) ); EXPECT_EQ( xround( ma7.at(mkt('2','A')).at(mkt('x','a')) ),