fix slice step size issue

This commit is contained in:
Christian Zimmermann 2018-09-16 18:53:28 +02:00
parent 9229ead298
commit 67492e24b7
6 changed files with 35 additions and 11 deletions

View file

@ -591,6 +591,7 @@ namespace MultiArrayTools
inline void OperationMaster<T,OpClass,Ranges...>::AssignmentExpr::
operator()(size_t start, ExtType last) const
{
//VCHECK(mSec.template get<ExtType>(last));
mM.add(start, mSec.template get<ExtType>(last) );
}

View file

@ -66,6 +66,9 @@ namespace MultiArrayTools
template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mIPack ) )&;
template <size_t N>
size_t getBlockSize() const { return std::get<N>(mBlockSizes); }
const IndexPack& pack() const { return mIPack; }
ContainerIndex& sync(); // recalculate 'IB::mPos' when externalControl == true

View file

@ -75,6 +75,9 @@ namespace MultiArrayTools
template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mIPack ) )&;
template <size_t N>
size_t getBlockSize() const { return std::get<N>(mBlockSizes); }
// raplace instances (in contrast to its analogon in ContainerIndex
// MultiIndices CANNOT be influences be its subindices, so there is

View file

@ -276,7 +276,8 @@ namespace MultiArrayHelper
const auto& ni = ii.template get<N>();
const size_t max = ni.max();
const size_t tmp = getStepSize(ni, j);
ss += tmp * sx;
//ss += tmp * sx;
ss += tmp * ii.template getBlockSize<N+1>();
sx *= max;
RPackNum<N-1>::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;
}

View file

@ -15,6 +15,8 @@ namespace MultiArrayTools
typedef ContainerRange<T,SRanges...> CRange;
typedef MultiArrayBase<T,SRanges...> MAB;
typedef ContainerIndex<T,typename SRanges::IndexType...> IType;
using MultiArrayBase<T,SRanges...>::operator();
DEFAULT_MEMBERS(ConstSlice);
@ -53,6 +55,9 @@ namespace MultiArrayTools
typedef ContainerRange<T,SRanges...> CRange;
typedef MultiArrayBase<T,SRanges...> MAB;
typedef ContainerIndex<T,typename SRanges::IndexType...> IType;
using MultiArrayBase<T,SRanges...>::operator();
using MutableMultiArrayBase<T,SRanges...>::operator();
DEFAULT_MEMBERS(Slice);

View file

@ -469,7 +469,7 @@ namespace {
<< std::endl;
std::cout << "ratio: " << static_cast<double>( end - begin ) / static_cast<double>( end2 - begin2 ) << std::endl;
}
/*
TEST_F(OpTest_Performance, PCheck)
{
MultiArray<double,MRange> 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<double,SRange> ma1(srptr, v1);
@ -675,10 +675,10 @@ namespace {
MultiArray<double,SRange> ma5(sr1ptr, v3);
MultiArray<double,SRange> 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<double,SRange,SRange> sl(sr1ptr,sr3ptr);
sl.define(si2,si3) = ma4(si0,si1,si2,si3);
si0->at('x');
(*si2) = 0;
(*si3) = 0;
Slice<double,SRange,SRange> sl(sr4ptr,sr3ptr);
sl.define(si3,si2) = ma4(si0,si1,si2,si3);
MultiArrayBase<double,SRange,SRange>& slb = sl;
MultiArray<double,SRange,SRange> 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')) ),