compiles now; TODO: 'HiddenFor' (no counting of master position therein)
This commit is contained in:
parent
96d9b4808e
commit
8f49ac93f5
6 changed files with 41 additions and 30 deletions
|
@ -31,7 +31,7 @@ namespace MultiArrayTools
|
|||
template <typename T>
|
||||
struct plus
|
||||
{
|
||||
static T&& apply(T&& a1, T&& a2)
|
||||
static T apply(const T& a1, const T& a2)
|
||||
{
|
||||
return a1 + a2;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace MultiArrayTools
|
|||
template <typename T>
|
||||
struct minus
|
||||
{
|
||||
static T&& apply(T&& a1, T&& a2)
|
||||
static T apply(const T& a1, const T& a2)
|
||||
{
|
||||
return a1 - a2;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace MultiArrayTools
|
|||
template <typename T>
|
||||
struct multiplies
|
||||
{
|
||||
static T&& apply(T&& a1, T&& a2)
|
||||
static T apply(const T& a1, const T& a2)
|
||||
{
|
||||
return a1 * a2;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace MultiArrayTools
|
|||
template <typename T>
|
||||
struct divides
|
||||
{
|
||||
static T&& apply(T&& a1, T&& a2)
|
||||
static T apply(const T& a1, const T& a2)
|
||||
{
|
||||
return a1 / a2;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ namespace MultiArrayTools
|
|||
const BlockResult<T>& get() const;
|
||||
|
||||
template <class ET, size_t SITE>
|
||||
inline T&& get(const ET& pos) const;
|
||||
inline T get(const ET& pos) const;
|
||||
|
||||
std::vector<BTSS> block(const IndexInfo* blockIndex, bool init = false) const;
|
||||
const Operation& block() const;
|
||||
|
@ -390,7 +390,7 @@ namespace MultiArrayTools
|
|||
const BlockResult<T>& get() const;
|
||||
|
||||
template <class ET, size_t SITE>
|
||||
inline T&& get(const ET& pos) const;
|
||||
inline T get(const ET& pos) const;
|
||||
|
||||
std::vector<BTSS> block(const IndexInfo* blockIndex, bool init = false) const;
|
||||
const Contraction& block() const;
|
||||
|
@ -527,7 +527,7 @@ namespace MultiArrayTools
|
|||
inline void OperationMaster<T,OpClass,Ranges...>::AssignmentExpr::
|
||||
operator()(size_t start, const ETuple& last)
|
||||
{
|
||||
mM.get(start) = mSec.template get<ETuple,OpClass::SIZE>(last);
|
||||
mM.get(start) = mSec.template get<ETuple,OpClass::SIZE-1>(last);
|
||||
}
|
||||
|
||||
template <typename T, class OpClass, class... Ranges>
|
||||
|
@ -622,12 +622,14 @@ namespace MultiArrayTools
|
|||
template <typename T, class OpClass, class... Ranges>
|
||||
T& OperationMaster<T,OpClass,Ranges...>::get(size_t pos)
|
||||
{
|
||||
VCHECK(pos);
|
||||
return mData[pos];
|
||||
}
|
||||
|
||||
template <typename T, class OpClass, class... Ranges>
|
||||
const T& OperationMaster<T,OpClass,Ranges...>::get(size_t pos) const
|
||||
{
|
||||
VCHECK(pos);
|
||||
return mData[pos];
|
||||
}
|
||||
|
||||
|
@ -840,11 +842,11 @@ namespace MultiArrayTools
|
|||
|
||||
template <typename T, class OpFunction, class... Ops>
|
||||
template <class ET, size_t SITE>
|
||||
inline T&& Operation<T,OpFunction,Ops...>::get(const ET& pos) const
|
||||
inline T Operation<T,OpFunction,Ops...>::get(const ET& pos) const
|
||||
{
|
||||
typedef std::tuple<Ops const&...> OpTuple;
|
||||
return std::forward<T>( PackNum<sizeof...(Ops)-2>::
|
||||
template mkOpExpr<T,ET,OpTuple,OpFunction,SITE>(pos, mOps) );
|
||||
return PackNum<sizeof...(Ops)-2>::
|
||||
template mkOpExpr<T,ET,OpTuple,OpFunction,SITE>(pos, mOps);
|
||||
}
|
||||
|
||||
template <typename T, class OpFunction, class... Ops>
|
||||
|
@ -908,9 +910,9 @@ namespace MultiArrayTools
|
|||
// forward loop !!!!
|
||||
template <typename T, class Op, class IndexType>
|
||||
template <class ET, size_t SITE>
|
||||
inline T&& Contraction<T,Op,IndexType>::get(const ET& pos) const
|
||||
inline T Contraction<T,Op,IndexType>::get(const ET& pos) const
|
||||
{
|
||||
return std::forward<T>( mOp.template get<SITE>(pos) );
|
||||
return mOp.template get<ET,SITE>(pos);
|
||||
}
|
||||
|
||||
template <typename T, class Op, class IndexType>
|
||||
|
|
|
@ -68,12 +68,13 @@ namespace MultiArrayHelper
|
|||
|
||||
// call with -2 (instead of -1)
|
||||
template <typename T, class ETuple, class OpTuple, class OpFunction, size_t START>
|
||||
static T&& mkOpExpr(const ETuple& pos, const OpTuple& ops)
|
||||
static T mkOpExpr(const ETuple& pos, const OpTuple& ops)
|
||||
{
|
||||
static const size_t NEXT = START - std::tuple_element<N+1,OpTuple>::type::SIZE;
|
||||
return std::forward<T>
|
||||
( OpFunction::apply( std::get<N+1>(ops).template get<START>(pos),
|
||||
PackNum<N-1>::template mkOpExpr<ETuple,OpTuple,OpFunction,NEXT>(pos, ops) ) );
|
||||
typedef typename std::tuple_element<N,OpTuple>::type SubOpTypeRef;
|
||||
typedef typename std::remove_reference<SubOpTypeRef>::type SubOpType;
|
||||
static const size_t NEXT = START - SubOpType::SIZE;
|
||||
return OpFunction::apply( std::get<N+1>(ops).template get<ETuple,START>(pos),
|
||||
PackNum<N-1>::template mkOpExpr<ETuple,OpTuple,OpFunction,NEXT>(pos, ops) );
|
||||
}
|
||||
|
||||
template <class OpTuple, class Expr>
|
||||
|
@ -137,12 +138,13 @@ namespace MultiArrayHelper
|
|||
}
|
||||
|
||||
template <typename T, class ETuple, class OpTuple, class OpFunction, size_t START>
|
||||
static T&& mkOpExpr(const ETuple& pos, const OpTuple& ops)
|
||||
static T mkOpExpr(const ETuple& pos, const OpTuple& ops)
|
||||
{
|
||||
static const size_t NEXT = START - std::tuple_element<1,OpTuple>::type::SIZE;
|
||||
return std::forward<T>
|
||||
( OpFunction::apply( std::get<1>(ops).template get<START>(pos),
|
||||
std::get<0>(ops).template get<NEXT>(pos) ) );
|
||||
typedef typename std::tuple_element<1,OpTuple>::type SubOpTypeRef;
|
||||
typedef typename std::remove_reference<SubOpTypeRef>::type SubOpType;
|
||||
static const size_t NEXT = START - SubOpType::SIZE;
|
||||
return OpFunction::apply( std::get<1>(ops).template get<ETuple,START>(pos),
|
||||
std::get<0>(ops).template get<ETuple,NEXT>(pos) );
|
||||
}
|
||||
|
||||
template <class OpTuple, class Expr>
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace MultiArrayTools
|
|||
|
||||
std::vector<IndexInfo> infoVec() const;
|
||||
|
||||
std::string id();
|
||||
std::string id() const;
|
||||
void print(size_t offset);
|
||||
|
||||
template <class Exprs>
|
||||
|
@ -354,7 +354,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
template <class... Indices>
|
||||
std::string ContainerIndex<Indices...>::id()
|
||||
std::string ContainerIndex<Indices...>::id() const
|
||||
{
|
||||
return std::string("con") + std::to_string(IB::mId);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace MultiArrayTools
|
|||
|
||||
std::vector<IndexInfo> infoVec() const;
|
||||
|
||||
std::string id();
|
||||
std::string id() const;
|
||||
void print(size_t offset);
|
||||
|
||||
template <class Exprs>
|
||||
|
@ -398,7 +398,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
template <class... Indices>
|
||||
std::string MultiIndex<Indices...>::id()
|
||||
std::string MultiIndex<Indices...>::id() const
|
||||
{
|
||||
return std::string("mul") + std::to_string(IB::mId);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace MultiArrayTools
|
|||
|
||||
std::vector<IndexInfo> infoVec() const;
|
||||
|
||||
std::string id();
|
||||
std::string id() const;
|
||||
void print(size_t offset);
|
||||
|
||||
template <class Expr>
|
||||
|
@ -232,7 +232,7 @@ namespace MultiArrayTools
|
|||
}
|
||||
|
||||
template <typename U, SpaceType TYPE>
|
||||
std::string SingleIndex<U,TYPE>::id()
|
||||
std::string SingleIndex<U,TYPE>::id() const
|
||||
{
|
||||
return std::string("sin") + std::to_string(IB::mId);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
namespace MultiArrayHelper
|
||||
{
|
||||
|
||||
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
||||
// (NO COUNTING OF MASTER POSITION !!!!!)
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
class For
|
||||
{
|
||||
|
@ -60,6 +63,8 @@ namespace MultiArrayHelper
|
|||
* --- TEMPLATE CODE --- *
|
||||
* ========================= */
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace MultiArrayHelper
|
||||
{
|
||||
|
||||
|
@ -67,19 +72,20 @@ namespace MultiArrayHelper
|
|||
For<IndexClass,Expr>::For(const std::shared_ptr<IndexClass>& indPtr,
|
||||
Expr&& expr) :
|
||||
mIndPtr(indPtr.get()), mExpr(expr),
|
||||
mExt(expr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr.get() ))) {}
|
||||
mExt(expr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr.get() ))) { assert(mIndPtr != nullptr); }
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
For<IndexClass,Expr>::For(const IndexClass* indPtr,
|
||||
Expr&& expr) :
|
||||
mIndPtr(indPtr), mExpr(std::forward<Expr>( expr )),
|
||||
mExt(expr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr ) )) {}
|
||||
mExt(expr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr ) )) { assert(mIndPtr != nullptr); }
|
||||
|
||||
template <class IndexClass, class Expr>
|
||||
inline void For<IndexClass,Expr>::operator()(size_t mlast,
|
||||
const ETuple& last) const
|
||||
{
|
||||
auto& ind = *mIndPtr;
|
||||
std::cout << mIndPtr << std::endl;
|
||||
const size_t max = ind.max(); // blocking
|
||||
for(size_t pos = ind.pos(); pos != max; ++pos){
|
||||
const size_t mnpos = mlast * max + pos;
|
||||
|
@ -93,6 +99,7 @@ namespace MultiArrayHelper
|
|||
{
|
||||
const ETuple last;
|
||||
auto& ind = *mIndPtr;
|
||||
std::cout << mIndPtr << std::endl;
|
||||
const size_t max = ind.max(); // blocking
|
||||
for(size_t pos = ind.pos(); pos != max; ++pos){
|
||||
const size_t mnpos = mlast * max + pos;
|
||||
|
|
Loading…
Reference in a new issue