type operations (after debugging operation forwarding should be possible)
This commit is contained in:
parent
92bb02be21
commit
451d58c037
2 changed files with 69 additions and 13 deletions
|
@ -26,10 +26,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
template <typename T, class OperationClass>
|
||||
class TypeSpecificOperationSet { /* empty per default; specialize if needed */ };
|
||||
|
||||
template <typename T, class OperationClass>
|
||||
class OperationTemplate : public TypeSpecificOperationSet<T,OperationClass>
|
||||
class OperationBase
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -61,6 +58,12 @@ namespace MultiArrayTools
|
|||
OperationTemplate() = default;
|
||||
};
|
||||
|
||||
template <typename T, class OperationClass>
|
||||
class OperationTemplate : public OperationBase<T,OperationClass>
|
||||
{ /* empty per default; specialize if needed */ };
|
||||
|
||||
#include "type_operations.h"
|
||||
|
||||
template <typename T, class OpClass, class... Ranges>
|
||||
class OperationMaster
|
||||
{
|
||||
|
@ -119,14 +122,12 @@ namespace MultiArrayTools
|
|||
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
class ConstOperationRoot : /*public OperationBase<T>,*/
|
||||
public OperationTemplate<T,ConstOperationRoot<T,Ranges...> >
|
||||
class ConstOperationRoot : public OperationTemplate<T,ConstOperationRoot<T,Ranges...> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef OperationBase<T> OB;
|
||||
typedef OperationTemplate<T,ConstOperationRoot<T,Ranges...> > OT;
|
||||
typedef OperationBase<T,ConstOperationRoot<T,Ranges...> > OT;
|
||||
typedef ContainerRange<T,Ranges...> CRange;
|
||||
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
|
||||
|
||||
|
@ -158,8 +159,7 @@ namespace MultiArrayTools
|
|||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef OperationBase<T> OB;
|
||||
typedef OperationTemplate<T,OperationRoot<T,Ranges...> > OT;
|
||||
typedef OperationBase<T,OperationRoot<T,Ranges...> > OT;
|
||||
typedef ContainerRange<T,Ranges...> CRange;
|
||||
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
|
||||
|
||||
|
@ -236,8 +236,7 @@ namespace MultiArrayTools
|
|||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef OperationBase<T> OB;
|
||||
typedef OperationTemplate<T,Operation<T,OpFunction,Ops...> > OT;
|
||||
typedef OperationBase<T,Operation<T,OpFunction,Ops...> > OT;
|
||||
typedef OpFunction F;
|
||||
|
||||
static constexpr size_t SIZE = RootSum<Ops...>::SIZE;
|
||||
|
@ -278,7 +277,7 @@ namespace MultiArrayTools
|
|||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef OperationTemplate<T,Contraction<T,Op,IndexType> > OT;
|
||||
typedef OperationBase<T,Contraction<T,Op,IndexType> > OT;
|
||||
|
||||
static constexpr size_t SIZE = Op::SIZE;
|
||||
|
||||
|
|
57
src/include/type_operations.h
Normal file
57
src/include/type_operations.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
|
||||
#ifndef __type_operations_h__
|
||||
#define __type_operations_h__
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "base_def.h"
|
||||
#include "mbase_def.h"
|
||||
|
||||
#include "pack_num.h"
|
||||
|
||||
namespace MultiArrayTools
|
||||
{
|
||||
namespace
|
||||
{
|
||||
using namespace MultiArrayHelper;
|
||||
}
|
||||
|
||||
template <typename T, class... Ranges>
|
||||
class operate
|
||||
{
|
||||
public:
|
||||
static constexpr bool FISSTATIC = false;
|
||||
|
||||
operate(const std::shared_ptr<typename Ranges::IndexType>&... inds) : ituple(inds...) {}
|
||||
|
||||
inline auto apply(const MultiArray<T,Ranges...>& ma)
|
||||
-> OperationRoot<T,Ranges...>
|
||||
{
|
||||
return mkElemOperation(ma, ituple); // -> pack_num
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// this is, why non-static
|
||||
std::tuple<std::shared_ptr<typename Ranges::IndexType>...> ituple;
|
||||
}
|
||||
|
||||
template <class OperationClass, typename T, class... Ranges>
|
||||
class OperationTemplate : public OperationBase<MultiArray<T,Ranges...>,OperationClass>
|
||||
{
|
||||
typedef OperationBase<MultiArray<T,Ranges...>,OperationClass> OB;
|
||||
|
||||
auto operator()(const std::shared_ptr<typename Ranges::IndexType>&... indices)
|
||||
-> Operation<OperationRoot<T,Ranges...>,operate,OperationClass>
|
||||
{
|
||||
std::shared_ptr<operate> ff(indices...);
|
||||
return Operation(ff, OB::THIS());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace MultiArrayTools
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue