This commit is contained in:
Christian Zimmermann 2017-08-11 15:26:10 +02:00
parent a9611b40e5
commit 0412be2349
15 changed files with 192 additions and 156 deletions

View file

@ -27,6 +27,9 @@ add_executable(mautest src/ma_unit_test.cc)
target_link_libraries(mautest ${GTEST_BOTH_LIBRARIES})
add_test(NAME mautest COMMAND mautest)
add_executable(oputest src/op_unit_test.cc)
target_link_libraries(oputest ${GTEST_BOTH_LIBRARIES})
add_test(NAME oputest COMMAND oputest)
#install(TARGETS testm DESTINATION install)

View file

@ -26,6 +26,11 @@
__class_name__(__class_name__&& in) = default; \
__class_name__& operator=(__class_name__&& in) = default
#define DEFAULT_MEMBERS_X(__class_name__) __class_name__(const __class_name__& in) = default; \
__class_name__& operator=(const __class_name__& in) = default; \
__class_name__(__class_name__&& in) = default; \
__class_name__& operator=(__class_name__&& in) = default
namespace MultiArrayTools
{
@ -112,31 +117,40 @@ namespace MultiArrayTools
// multi_array.h
template <typename T, class Range>
class MultiArray;
// multi_array_operation.h
template <typename T>
class OperationBase;
// multi_array_operation.h
template <typename T>
class MutableOperationBase;
// multi_array_operation.h
template <class OperationClass>
class OperationTemplate;
// multi_array_operation.h
template <typename T, class... Ranges>
class OperationMaster;
// multi_array_operation.h
template <typename T, class... Ranges>
class OperationRoot;
// multi_array_operation.h
template <typename T, class... Ranges>
class ConstOperationRoot;
// multi_array_operation.h
template <typename T, class OpFunction, class... Ops>
class Operation;
/*
// multi_array_operation.h
template <typename T>
class MultiArrayOperationBase;
// multi_array_operation.h
template <typename T>
class MutableMultiArrayOperationBase;
// multi_array_operation.h
template <typename T, class Range>
class MultiArrayOperationRoot;
// multi_array_operation.h
template <typename T, class Range>
class ConstMultiArrayOperationRoot;
// multi_array_operation.h
template <typename T, class InRange, class TotalInRange, class OutRange, class TotalRange>
class MultiArrayOperationMap;
// multi_array_operation.h
template <typename T, class Operation, class... MAOps>
class MultiArrayOperation;
// multi_array_operation.h
template <typename T, class ContractOperation, class Range, class... MAOps>
class MultiArrayContraction;

View file

@ -17,7 +17,7 @@ namespace MultiArrayTools
template <class... Indices>
ContainerIndex<Indices...>::ContainerIndex(const ContainerIndex& in) :
IndexInterface<std::tuple<decltype(Indices().meta())...> >(in)
IndexInterface<std::tuple<typename Indices::MetaType...> >(in)
{
PackNum<sizeof...(Indices)-1>::copy(mIPack, in);
IB::mPos = PackNum<sizeof...(Indices)-1>::makePos(mIPack);
@ -35,7 +35,7 @@ namespace MultiArrayTools
template <class... Indices>
template <class MRange>
ContainerIndex<Indices...>::ContainerIndex(const std::shared_ptr<MRange>& range) :
IndexInterface<std::tuple<decltype(Indices().meta())...> >(range, 0)
IndexInterface<std::tuple<typename Indices::MetaType...> >(range, 0)
{
PackNum<sizeof...(Indices)-1>::construct(mIPack, *range);
IB::mPos = PackNum<sizeof...(Indices)-1>::makePos(mIPack);
@ -110,6 +110,13 @@ namespace MultiArrayTools
return *std::get<N>( mIPack );
}
template <class... Indices>
template <size_t N>
auto ContainerIndex<Indices...>::getPtr() const -> decltype( std::get<N>( mIPack ) )&
{
return std::get<N>( mIPack );
}
template <class... Indices>
bool ContainerIndex<Indices...>::first() const
{
@ -137,6 +144,12 @@ namespace MultiArrayTools
return sync();
}
template <class... Indices>
const std::shared_ptr<typename ContainerIndex<Indices...>::RangeType>& ContainerIndex<Indices...>::range() const;
{
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
}
/*****************************
* ContainerRangeFactory *
*****************************/
@ -198,6 +211,12 @@ namespace MultiArrayTools
return std::get<N>( mSpace );
}
template <class... Ranges>
const typename ContainerRange<Ranges...>::SpaceType& ContainerRange<Ranges...>::space() const
{
return mSpace;
}
template <class... Ranges>
typename ContainerRange<Ranges...>::IndexType ContainerRange<Ranges...>::begin() const
{

View file

@ -15,21 +15,22 @@ namespace MultiArrayTools
{
template <class... Indices>
class ContainerIndex : public IndexInterface<std::tuple<decltype(Indices().meta())...> >
class ContainerIndex : public IndexInterface<std::tuple<typename Indices::MetaType...> >
{
public:
typedef IndexBase IB;
typedef std::tuple<decltype(Indices().meta())...> MetaType;
typedef std::tuple<typename Indices::MetaType...> MetaType;
typedef std::tuple<std::shared_ptr<Indices>...> IndexPack;
typedef IndexInterface<std::tuple<decltype(Indices().meta())...> > IndexI;
typedef IndexInterface<std::tuple<typename Indices::MetaType...> > IndexI;
typedef ContainerRange<typename Indices::RangeType...> RangeType;
protected:
bool mExternControl = false;
IndexPack mIPack;
public:
ContainerIndex() = default;
ContainerIndex() = delete;
ContainerIndex(const ContainerIndex& in);
ContainerIndex& operator=(const ContainerIndex& in);
@ -54,10 +55,14 @@ namespace MultiArrayTools
template <size_t N>
auto get() const -> decltype( *std::get<N>( mIPack ) )&;
template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mIPack ) )&;
ContainerIndex& operator()(const std::shared_ptr<Indices>&... inds); // control via external indices
ContainerIndex& operator()(); // -> sync; just to shorten the code
const std::shared_ptr<RangeType>& range() const;
};
@ -109,6 +114,8 @@ namespace MultiArrayTools
template <size_t N>
auto getPtr() const -> decltype( std::get<N>( mSpace ) )&;
const SpaceType& space() const;
virtual IndexType begin() const override;
virtual IndexType end() const override;

View file

@ -178,7 +178,7 @@ namespace {
{
MultiArray<double,MATest_MDim::CRange> ma(crptr, vv);
EXPECT_EQ( ma.size(), 24 );
EXPECT_EQ( ma.range().dim(), 2 );
EXPECT_EQ( ma.range()->dim(), 2 );
auto i = ma.beginIndex();
EXPECT_EQ( ma[ i.at( mkt( mkt('x', 'a'), '1' ) ) ], 2.917);

View file

@ -182,9 +182,9 @@ namespace MultiArrayTools
}
template <typename T, class CRange>
const CRange& MultiArrayBase<T,CRange>::range() const
const std::shared_ptr<CRange>& MultiArrayBase<T,CRange>::range() const
{
return *mRange;
return mRange;
}
template <typename T, class CRange>
@ -192,26 +192,15 @@ namespace MultiArrayTools
{
return true;
}
/*
template <typename T, class CRange>
template <class... NameTypes>
ConstMultiArrayOperationRoot<T,CRange> MultiArrayBase<T,CRange>::operator()(const NameTypes&... str) const
{
return ConstMultiArrayOperationRoot<T,CRange>(*this, Name("master", str...));
}
template <typename T, class CRange>
template <class NameType>
ConstMultiArrayOperationRoot<T,CRange> MultiArrayBase<T,CRange>::operator()(const NameType& name, bool master) const
template <class... SubRanges>
ConstOperationRoot<T,SubRanges...>
MultiArrayBase<T,CRange>::operator()(std::shared_ptr<typename SubRanges::IndexType>&... inds) const
{
if(master){
return ConstMultiArrayOperationRoot<T,CRange>(*this, name);
}
else {
return operator()(name);
}
return ConstOperationRoot<T,SubRanges...>(*this, inds...);
}
*/
template <typename T, class CRange>
bool MultiArrayBase<T,CRange>::isInit() const
{
@ -403,47 +392,15 @@ namespace MultiArrayTools
{
return false;
}
/*
template <typename T, class CRange>
template <class... NameTypes>
MultiArrayOperationRoot<T,CRange> MutableMultiArrayBase<T,CRange>::operator()(const NameTypes&... str)
{
return MultiArrayOperationRoot<T,CRange>(*this, Name("master", str...));
}
template <typename T, class CRange>
template <class NameType>
MultiArrayOperationRoot<T,CRange> MutableMultiArrayBase<T,CRange>::operator()(const NameType& name, bool master)
template <class... SubRanges>
OperationRoot<T,SubRanges...>
MutableMultiArrayBase<T,CRange>::operator()(std::shared_ptr<typename SubRanges::IndexType>&... inds)
{
//CHECK;
if(master){
return MultiArrayOperationRoot<T,CRange>(*this, name);
}
else {
return operator()(name);
}
return OperationRoot<T,SubRanges...>(*this, inds...);
}
template <typename T, class CRange>
template <class... NameTypes>
ConstMultiArrayOperationRoot<T,CRange> MutableMultiArrayBase<T,CRange>::operator()(const NameTypes&... str) const
{
return ConstMultiArrayOperationRoot<T,CRange>(*this, Name("master", str...));
}
template <typename T, class CRange>
template <class NameType>
ConstMultiArrayOperationRoot<T,CRange> MutableMultiArrayBase<T,CRange>::operator()(const NameType& name, bool master) const
{
//CHECK;
if(master){
return ConstMultiArrayOperationRoot<T,CRange>(*this, name);
}
else {
return operator()(name);
}
}
*/
/*******************
* MultiArray *
*******************/

View file

@ -18,6 +18,7 @@
namespace MultiArrayTools
{
// Explicitely specify subranges in template argument !!!
template <typename T, class CRange>
class MultiArrayBase
{
@ -88,16 +89,13 @@ namespace MultiArrayTools
virtual typename CRange::IndexType beginIndex() const;
virtual typename CRange::IndexType endIndex() const;
virtual const CRange& range() const;
virtual const std::shared_ptr<CRange>& range() const;
virtual bool isConst() const;
/*
template <class... NameTypes>
ConstMultiArrayOperationRoot<T,CRange> operator()(const NameTypes&... str) const;
template <class NameType>
ConstMultiArrayOperationRoot<T,CRange> operator()(const NameType& name, bool master) const;
*/
template <class... SubRanges>
ConstOperationRoot<T,SubRanges...> operator()(std::shared_ptr<typename SubRanges::IndexType>&... inds) const;
virtual bool isInit() const;
protected:
@ -176,25 +174,9 @@ namespace MultiArrayTools
virtual iterator end();
virtual bool isConst() const override;
/*
template <class... NameTypes>
ConstMultiArrayOperationRoot<T,CRange> operator()(bool x, const NameTypes&... str) const
{
return MAB::operator()(str...);
}
template <class... NameTypes>
ConstMultiArrayOperationRoot<T,CRange> operator()(const NameTypes&... str) const;
template <class NameType>
ConstMultiArrayOperationRoot<T,CRange> operator()(const NameType& name, bool master) const;
template <class... NameTypes>
MultiArrayOperationRoot<T,CRange> operator()(const NameTypes&... str);
template <class NameType>
MultiArrayOperationRoot<T,CRange> operator()(const NameType& name, bool master);
*/
template <class... SubRanges>
OperationRoot<T,SubRanges...> operator()(std::shared_ptr<typename SubRanges::IndexType>&... inds);
};
template <typename T, class CRange>

View file

@ -10,7 +10,7 @@
#include "single_range.h"
#include "multi_range.h"
#include "container_range.h"
//#include "multi_array_operation.h"
#include "multi_array_operation.h"
#include "multi_array.h"
//#include "slice.h"
//#include "manipulator.h"

View file

@ -17,11 +17,15 @@ namespace MultiArrayTools
* OperationTemplate *
***************************/
template <class OperationClass>
OperationTemplate<OperationClass>::OperationTemplate(OperationClass* oc) : mOc(oc) {}
template <class OperationClass>
template <class Second>
Operation<OperationClass,Second> OperationTemplate<OperationClass>::operator+(Second&& in) const
Operation<double,std::plus<double>,OperationClass,Second>
OperationTemplate<OperationClass>::operator+(const Second& in) const
{
return Operation<double,std::plus<double>,OperationClass,Second>(*this, in);
return Operation<double,std::plus<double>,OperationClass,Second>(*mOc, in);
}
/*************************
@ -30,26 +34,31 @@ namespace MultiArrayTools
template <typename T, class... Ranges>
OperationMaster<T,Ranges...>::
OperationMaster(MutableMultiArrayBase& ma,
std::shared_ptr<ContainerRange<Ranges...>::IndexType>& index) :
mArrayRef(ma), mIndex()
OperationMaster(MutableMultiArrayBase<T,CRange>& ma, const OperationBase<T>& second,
std::shared_ptr<typename CRange::IndexType>& index) :
mSecond(second), mArrayRef(ma), mIndex()
{
MultiRangeFactory<Ranges...> mrf( index->range() );
mIndex = mrf.create();
CHECK;
(*mIndex) = *index;
CHECK;
for(*mIndex = 0; mIndex->pos() != mIndex->max(); ++(*mIndex)){
get() = mSecond.get();
}
CHECK;
}
template <typename T, class... Ranges>
T& OperationMaster<T,Ranges...>::get()
{
return mArrayRef.data()[ mIndex.pos() ];
return mArrayRef.data()[ mIndex->pos() ];
}
template <typename T, class... Ranges>
const T& OperationMaster<T,Ranges...>::get() const
{
return mArrayRef.data()[ mIndex.pos() ];
return mArrayRef.data()[ mIndex->pos() ];
}
/****************************
@ -57,18 +66,21 @@ namespace MultiArrayTools
****************************/
template <typename T, class... Ranges>
ConstOperationRoot<T,CRange,Ranges...>::
ConstOperationRoot<T,Ranges...>::
ConstOperationRoot(const MultiArrayBase<T,CRange>& ma,
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
mArrayRef(ma), mIndex(mArrayRef)
OperationBase<T>(), OperationTemplate<ConstOperationRoot<T,Ranges...> >(this),
mArrayRef(ma), mIndex( std::make_shared<IndexType>( mArrayRef.range() ) )
{
CHECK;
mIndex(indices...);
CHECK;
}
template <typename T, class... Ranges>
const T& ConstOperationRoot<T,Ranges...>::get() const
{
return mArrayRef[ mIndex ];
return mArrayRef[ *mIndex ];
}
/***********************
@ -79,9 +91,12 @@ namespace MultiArrayTools
OperationRoot<T,Ranges...>::
OperationRoot(MutableMultiArrayBase<T,CRange>& ma,
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
mArrayRef(ma), mIndex(mArrayRef)
MutableOperationBase<T>(), OperationTemplate<OperationRoot<T,Ranges...> >(this),
mArrayRef(ma), mIndex( std::make_shared<IndexType>( mArrayRef.range() ) )
{
mIndex(indices...);
CHECK;
(*mIndex)(indices...);
CHECK;
}
template <typename T, class... Ranges>
@ -93,13 +108,13 @@ namespace MultiArrayTools
template <typename T, class... Ranges>
const T& OperationRoot<T,Ranges...>::get() const
{
return mArrayRef[ mIndex ];
return mArrayRef[ *mIndex ];
}
template <typename T, class... Ranges>
T& OperationRoot<T,Ranges...>::get()
{
return mArrayRef[ mIndex ];
return mArrayRef[ *mIndex ];
}
/***********************
@ -107,12 +122,14 @@ namespace MultiArrayTools
***********************/
template <typename T, class OpFunction, class... Ops>
Operation<T,OpFunction,Ops...>::Operation(Ops&&... ops) : mOps(ops...) {}
Operation<T,OpFunction,Ops...>::Operation(const Ops&... ops) :
OperationBase<T>(), OperationTemplate<Operation<T,OpFunction,Ops...> >(this),
mOps(ops...) {}
template <typename T, class OpFunction, class... Ops>
const T& Operation<T,OpFunction,Ops...>::get() const
{
mRes = F(mOps);
mRes = PackNum<sizeof...(Ops)-1>::template unpackArgs<T,OpFunction>(mOps);
return mRes;
}
}

View file

@ -8,7 +8,6 @@
#include <cmath>
#include "base_def.h"
#include "index_base.h"
namespace MultiArrayTools
{
@ -26,9 +25,6 @@ namespace MultiArrayTools
*
*/
typedef std::map<Name,std::shared_ptr<IndexBase> > IndexList;
template <typename T>
class OperationBase
{
@ -37,7 +33,7 @@ namespace MultiArrayTools
typedef T value_type;
OperationBase() = default;
virtual ~OperationBase();
virtual ~OperationBase() = default;
//virtual size_t argNum() const = 0;
virtual const T& get() const = 0;
@ -57,8 +53,12 @@ namespace MultiArrayTools
{
public:
OperationTemplate(OperationClass* oc);
template <class Second>
Operation<OperationClass,Second> operator+(const Second& in) const;
Operation<double,std::plus<double>,OperationClass,Second> operator+(const Second& in) const;
private:
OperationClass* mOc;
};
template <typename T, class... Ranges>
@ -67,10 +67,11 @@ namespace MultiArrayTools
public:
typedef OperationBase<T> OB;
typedef ContainerRange<Ranges...> CRange;
typedef typename MultiRange<Ranges...>::IndexType IndexType;
OperationMaster(MutableMultiArrayBase& ma, OperationBase<T>& second,
const ContainerRange<Ranges...>::IndexType& index);
OperationMaster(MutableMultiArrayBase<T,CRange>& ma, const OperationBase<T>& second,
std::shared_ptr<typename CRange::IndexType>& index);
virtual T& get() override;
virtual const T& get() const override;
@ -86,12 +87,12 @@ namespace MultiArrayTools
template <typename T, class... Ranges>
class ConstOperationRoot : public OperationBase<T>,
public OperationTemplate<ConstOperationRoot<T,CRange> >
public OperationTemplate<ConstOperationRoot<T,Ranges...> >
{
public:
typedef OperationBase<T> OB;
typedef OperationTemplate<ConstOperationRoot<T,CRange> > OT;
typedef OperationTemplate<ConstOperationRoot<T,Ranges...> > OT;
typedef ContainerRange<Ranges...> CRange;
typedef typename CRange::IndexType IndexType;
@ -108,12 +109,12 @@ namespace MultiArrayTools
template <typename T, class... Ranges>
class OperationRoot : public MutableOperationBase<T>,
public OperationTemplate<OperationRoot<T,CRange> >
public OperationTemplate<OperationRoot<T,Ranges...> >
{
public:
typedef OperationBase<T> OB;
typedef OperationTemplate<OperationRoot<T,CRange> > OT;
typedef OperationTemplate<OperationRoot<T,Ranges...> > OT;
typedef ContainerRange<Ranges...> CRange;
typedef typename CRange::IndexType IndexType;
@ -141,15 +142,16 @@ namespace MultiArrayTools
typedef OperationTemplate<Operation<T,OpFunction,Ops...> > OT;
typedef OpFunction F;
Operation(Ops&&... ops);
Operation(const Ops&... ops);
virtual const T& get() const override;
protected:
std::tuple<Ops...> mOps;
T res;
mutable T mRes;
};
}
#include "multi_array_operation.cc"

View file

@ -16,7 +16,7 @@ namespace MultiArrayTools
template <class... Indices>
MultiIndex<Indices...>::MultiIndex(const MultiIndex<Indices...>& in) :
IndexInterface<std::tuple<decltype(Indices().meta())...> >(in)
IndexInterface<std::tuple<typename Indices::MetaType...> >(in)
{
PackNum<sizeof...(Indices)-1>::copy(mIPack, in);
IB::mPos = PackNum<sizeof...(Indices)-1>::makePos(mIPack);
@ -34,16 +34,18 @@ namespace MultiArrayTools
template <class... Indices>
MultiIndex<Indices...>& MultiIndex<Indices...>::operator=(ContainerIndex<Indices...>& ci)
{
IndexI::operator=(in);
CHECK;
PackNum<sizeof...(Indices)-1>::copyInst(mIPack, ci);
CHECK;
IB::mPos = PackNum<sizeof...(Indices)-1>::makePos(mIPack);
CHECK;
return *this;
}
template <class... Indices>
template <class MRange>
MultiIndex<Indices...>::MultiIndex(const std::shared_ptr<MRange>& range) :
IndexInterface<std::tuple<decltype(Indices().meta())...> >(range, 0)
IndexInterface<std::tuple<typename Indices::MetaType...> >(range, 0)
{
PackNum<sizeof...(Indices)-1>::construct(mIPack, *range);
IB::mPos = PackNum<sizeof...(Indices)-1>::makePos(mIPack);
@ -152,6 +154,12 @@ namespace MultiArrayTools
return IB::mPos == IB::mRangePtr->size() - 1;
}
template <class... Indices>
const std::shared_ptr<typename MultiIndex<Indices...>::RangeType>& MultiIndex<Indices...>::range() const
{
return std::dynamic_pointer_cast<RangeType>( IB::mRangePtr );
}
/*************************
* MultiRangeFactory *
*************************/
@ -168,6 +176,12 @@ namespace MultiArrayTools
mProd = std::shared_ptr< MultiRange<Ranges...> >( new MultiRange<Ranges...>( st ) );
}
template <class... Ranges>
MultiRangeFactory<Ranges...>::MultiRangeFactory(const std::shared_ptr<ContainerRange<Ranges...> >& cr)
{
mProd = std::shared_ptr< MultiRange<Ranges...> >( new MultiRange<Ranges...>( cr->space() ) );
}
template <class... Ranges>
std::shared_ptr<RangeBase> MultiRangeFactory<Ranges...>::create()
{

View file

@ -15,25 +15,26 @@ namespace MultiArrayTools
{
template <class... Indices>
class MultiIndex : public IndexInterface<std::tuple<decltype(Indices().meta())...> >
class MultiIndex : public IndexInterface<std::tuple<typename Indices::MetaType...> >
{
public:
typedef IndexBase IB;
typedef std::tuple<std::shared_ptr<Indices>...> IndexPack;
typedef std::tuple<decltype(Indices().meta())...> MetaType;
typedef std::tuple<typename Indices::MetaType...> MetaType;
typedef IndexInterface<MetaType> IndexI;
typedef MultiRange<typename Indices::RangeType...> RangeType;
protected:
IndexPack mIPack;
public:
MultiIndex() = default;
MultiIndex() = delete;
// NO DEFAULT HERE !!!
// ( have to assign sub-indices (ptr!) correctly )
MultiIndex(const MultiIndex& in);
MultiIndex& operator=(const MultiIndex& in);
MultiIndex& operator=(const ContainerIndex<Indices...>& ci);
MultiIndex& operator=(ContainerIndex<Indices...>& ci);
template <class MRange>
MultiIndex(const std::shared_ptr<MRange>& range);
@ -63,6 +64,8 @@ namespace MultiArrayTools
virtual bool last() const override;
virtual size_t dim() const override;
const std::shared_ptr<RangeType>& range() const;
};
/*************************
@ -78,6 +81,7 @@ namespace MultiArrayTools
MultiRangeFactory() = delete;
MultiRangeFactory(const std::shared_ptr<Ranges>&... rs);
MultiRangeFactory(const typename MultiRange<Ranges...>::SpaceType& space);
MultiRangeFactory(const std::shared_ptr<ContainerRange<Ranges...> >& cr);
virtual std::shared_ptr<RangeBase> create() override;
};

View file

@ -48,7 +48,7 @@ namespace {
swapFactory<SRF>(rfbptr, {'a', 'l', 'f', 'g'} );
srptr = std::dynamic_pointer_cast<SRange>( rfbptr->create() );
swapMFactory<CRF>(srptr);
swapMFactory<CRF>(rfbptr, srptr);
crptr = std::dynamic_pointer_cast<CRange>( rfbptr->create() );
}
@ -65,8 +65,9 @@ namespace {
MultiArray<double,CRange> ma2(crptr, v2);
MultiArray<double,CRange> res(crptr);
std::map<std::string,std::shared_ptr<SRange::IndexType> > m;
res(m["mu"]) = ma1(m["mu"]) + ma2(m["mu"]);
auto i = std::dynamic_pointer_cast<SRange::IndexType>( srptr->index() );
CHECK;
res.operator()<SRange>(i) = ma1.operator()<SRange>(i) + ma2.operator()<SRange>(i);
}
} // anonymous namspace

View file

@ -148,6 +148,12 @@ namespace MultiArrayHelper
return std::get<sizeof...(Indices)-N-1>(pack)->max() * PackNum<N-1>::blockSize(pack);
}
template <typename T, class Func, class ArgTuple, class... Args>
static T unpackArgs(const ArgTuple& tp, const Args&... args)
{
return PackNum<N-1>::template unpackArgs<T,Func>(tp, std::get<N>(tp).get(), args...);
}
};
template<>
@ -253,6 +259,15 @@ namespace MultiArrayHelper
return std::get<sizeof...(Indices)-1>(pack)->max();
}
template <typename T, class Func, class ArgTuple, class... Args>
static T unpackArgs(const ArgTuple& tp, const Args&... args)
{
static_assert(sizeof...(Args) == std::tuple_size<ArgTuple>::value-1,
"inconsistent number of arguments");
static Func f;
return f(std::get<0>(tp).get(), args...);
}
};
} // end namespace MultiArrayHelper

View file

@ -21,8 +21,9 @@ namespace MultiArrayTools
typedef IndexBase IB;
typedef U MetaType;
typedef SingleRange<U,TYPE> RangeType;
DEFAULT_MEMBERS(SingleIndex);
DEFAULT_MEMBERS_X(SingleIndex);
SingleIndex(const std::shared_ptr<SingleRange<U,TYPE> >& range);