cnorxz/src/include/ranges/rpack_num.h

340 lines
12 KiB
C
Raw Normal View History

2017-12-17 17:40:55 +01:00
2017-12-18 13:13:13 +01:00
#ifndef __rpack_num_h__
#define __rpack_num_h__
2017-12-17 17:40:55 +01:00
#include <memory>
2018-07-16 00:12:05 +02:00
#include <vector>
#include <cassert>
#include "ranges/rbase_def.h"
#include "ranges/index_base.h"
#include "ranges/x_to_string.h"
2017-12-17 17:40:55 +01:00
namespace MultiArrayHelper
{
using namespace MultiArrayTools;
2018-01-09 22:38:46 +01:00
template <class Index1>
2020-08-27 12:00:47 +02:00
size_t mkTotalDim();
2018-01-09 22:38:46 +01:00
template <class Index1, class Index2, class... Indices>
2020-08-27 12:00:47 +02:00
size_t mkTotalDim();
2018-01-09 22:38:46 +01:00
2018-02-13 16:54:13 +01:00
template <class RangeType, class... Ranges>
struct SubProp
{
static constexpr size_t ISSTATIC = RangeType::ISSTATIC & SubProp<Ranges...>::ISSTATIC;
static constexpr size_t SIZE = RangeType::SIZE * SubProp<Ranges...>::SIZE;
};
template <>
2020-07-09 17:37:28 +02:00
struct SubProp<None>
2018-02-13 16:54:13 +01:00
{
static constexpr size_t ISSTATIC = 1;
static constexpr size_t SIZE = 1;
};
template <class Index>
inline size_t getStepSize(const Index& ii, std::intptr_t j);
2018-07-16 00:12:05 +02:00
template <class Range>
2019-02-13 21:59:13 +01:00
inline void resolveSetRange(std::shared_ptr<Range>& rp, const vector<std::shared_ptr<RangeBase> >& orig,
2020-08-27 12:00:47 +02:00
size_t origpos, size_t size);
template <class Range>
2019-02-13 21:59:13 +01:00
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
2020-08-27 12:00:47 +02:00
std::shared_ptr<Range> r);
2018-01-09 22:38:46 +01:00
2017-12-17 17:40:55 +01:00
template <size_t N>
struct RPackNum
{
template <class... Indices>
static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs,
2020-08-27 12:00:47 +02:00
std::tuple<std::shared_ptr<Indices>...>& ip);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static inline void pp(std::tuple<std::shared_ptr<Indices>...>& ip);
2017-12-17 17:40:55 +01:00
template <class... Indices>
static inline int pp(std::tuple<std::shared_ptr<Indices>...>& ip,
std::array<size_t,sizeof...(Indices)+1>& bs,
2020-08-27 12:00:47 +02:00
std::intptr_t idxPtrNum);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static inline void mm(std::tuple<std::shared_ptr<Indices>...>& ip);
2017-12-17 17:40:55 +01:00
// !!!!
template <class... Indices>
static inline int mm(std::tuple<std::shared_ptr<Indices>...>& ip,
std::array<size_t,sizeof...(Indices)+1>& bs,
2020-08-27 12:00:47 +02:00
std::intptr_t idxPtrNum);
2017-12-17 17:40:55 +01:00
template <class RangeTuple>
2020-08-27 12:00:47 +02:00
static size_t getSize(const RangeTuple& rt);
2017-12-17 17:40:55 +01:00
template <class IndexPack, class MetaType>
static void getMetaPos(MetaType& target,
2020-08-27 12:00:47 +02:00
const IndexPack& source);
2018-11-30 00:16:28 +01:00
2017-12-17 17:40:55 +01:00
template <class IndexPack, typename MetaType>
2020-08-27 12:00:47 +02:00
static void setMeta(IndexPack& target, const MetaType& source);
2018-11-30 00:16:28 +01:00
template <class SpaceClass>
2020-08-27 12:00:47 +02:00
inline static std::shared_ptr<RangeBase> getSub(const SpaceClass& space, size_t num);
2018-11-30 00:16:28 +01:00
2017-12-17 17:40:55 +01:00
template <class IndexPack>
2020-08-27 12:00:47 +02:00
static void setIndexPack(IndexPack& iPack, size_t pos);
2017-12-17 17:40:55 +01:00
template <class MRange, class... Indices>
static void construct(std::tuple<std::shared_ptr<Indices>...>& ip,
2020-08-27 12:00:47 +02:00
const MRange& range);
2017-12-17 17:40:55 +01:00
template <class IndexType, class... Indices>
2017-12-17 17:40:55 +01:00
static void copyInst(std::tuple<std::shared_ptr<Indices>...>& ip,
2020-08-27 12:00:47 +02:00
const IndexType& ind);
2018-12-25 17:48:52 +01:00
template <class IndexType, class... Indices>
static void copyIndex(std::tuple<std::shared_ptr<Indices>...>& ip,
2020-08-27 12:00:47 +02:00
const IndexType& ind);
2018-12-25 17:48:52 +01:00
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup);
2017-12-17 17:40:55 +01:00
template <class... Indices>
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
2020-08-27 12:00:47 +02:00
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
2017-12-17 17:40:55 +01:00
template <class Pack, class IndexType, class... Indices>
static void swapIndices(Pack& ipack, const std::shared_ptr<IndexType>& nind,
2020-08-27 12:00:47 +02:00
const std::shared_ptr<Indices>&... ninds);
2017-12-17 17:40:55 +01:00
template <class Pack, class... Indices>
2020-08-27 12:00:47 +02:00
static void swapIndices(Pack& ipack, const std::tuple<std::shared_ptr<Indices>...>& ninds);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
2017-12-17 17:40:55 +01:00
template <class... Ranges>
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
2020-08-27 12:00:47 +02:00
vector<std::shared_ptr<RangeBase> >& v);
template <class... Ranges>
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
2020-08-27 12:00:47 +02:00
vector<std::intptr_t>& v);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static void printIndex(const std::tuple<std::shared_ptr<Indices>...>& ip, size_t offset);
2017-12-17 17:40:55 +01:00
template <class Range, class... Ranges>
2020-08-27 12:00:47 +02:00
static void checkDefaultable();
2017-12-24 18:14:07 +01:00
template <class IndexPack, class BlockArray, class Exprs>
static auto mkFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
2020-08-27 12:00:47 +02:00
->ifor( 0, RPackNum<N-1>::mkFor(step, ipack, ba, exs) ) );
2018-01-09 22:38:46 +01:00
template <class IndexPack, class BlockArray, class Exprs>
static auto mkForh(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
2020-08-27 12:00:47 +02:00
->iforh( 0, RPackNum<N-1>::mkForh(step, ipack, ba, exs) ) );
2019-01-15 17:41:43 +01:00
template <class IndexPack, class BlockArray, class Exprs>
static auto mkPFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-N-1>(ipack)
2020-08-27 12:00:47 +02:00
->pifor( 0, RPackNum<N-1>::mkFor(step, ipack, ba, exs) ) );
2019-01-15 17:41:43 +01:00
template <class Index>
2020-08-27 12:00:47 +02:00
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
template <class RangeTuple, typename... SIZET>
2019-02-13 21:59:13 +01:00
static inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
2020-08-27 12:00:47 +02:00
RangeTuple& rtp, size_t off, size_t size, SIZET... sizes);
template <class... Ranges>
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
2020-08-27 12:00:47 +02:00
const vector<std::intptr_t>& a);
2019-03-14 14:20:38 +01:00
template <class MIndex>
2020-08-27 12:00:47 +02:00
static inline std::string getStringMeta(const MIndex& mi);
template <class... Ranges>
2019-02-13 21:59:13 +01:00
static inline void fillRangeDataVec(vector<char>& out,
2020-08-27 12:00:47 +02:00
const std::tuple<std::shared_ptr<Ranges>...>& tp);
2018-07-28 15:27:11 +02:00
template <size_t SIZE, class Range, class... Ranges>
2020-08-27 12:00:47 +02:00
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
2018-07-28 15:27:11 +02:00
template <class... Ranges>
2019-02-13 21:59:13 +01:00
static inline void setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
2020-08-27 12:00:47 +02:00
std::tuple<std::shared_ptr<Ranges>...>& stp);
2019-03-14 14:20:38 +01:00
2019-11-12 13:30:26 +01:00
template <class MetaType, class... Ranges>
static inline size_t getCMeta(MetaType* xtarget, size_t pos,
2020-08-27 12:00:47 +02:00
const std::tuple<std::shared_ptr<Ranges>...>& stp, size_t off);
template <class... Ranges>
2020-08-27 12:00:47 +02:00
static inline size_t getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp);
template <class... Ranges>
2020-08-27 12:00:47 +02:00
static inline void getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp);
2017-12-17 17:40:55 +01:00
};
template<>
struct RPackNum<0>
{
template <class... Indices>
static void initBlockSizes(std::array<size_t,sizeof...(Indices)+1>& bs,
2020-08-27 12:00:47 +02:00
std::tuple<std::shared_ptr<Indices>...>& ip);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static inline void pp(std::tuple<std::shared_ptr<Indices>...>& ip);
2017-12-17 17:40:55 +01:00
template <class... Indices>
static inline int pp(std::tuple<std::shared_ptr<Indices>...>& ip,
std::array<size_t,sizeof...(Indices)+1>& bs,
2020-08-27 12:00:47 +02:00
std::intptr_t idxPtrNum);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static inline void mm(std::tuple<std::shared_ptr<Indices>...>& ip);
2017-12-17 17:40:55 +01:00
template <class... Indices>
static inline int mm(std::tuple<std::shared_ptr<Indices>...>& ip,
std::array<size_t,sizeof...(Indices)+1>& bs,
2020-08-27 12:00:47 +02:00
std::intptr_t idxPtrNum);
2017-12-17 17:40:55 +01:00
template <class RangeTuple>
2020-08-27 12:00:47 +02:00
static size_t getSize(const RangeTuple& rt);
2017-12-17 17:40:55 +01:00
template <class IndexPack, class MetaType>
static void getMetaPos(MetaType& target,
2020-08-27 12:00:47 +02:00
const IndexPack& source);
2017-12-17 17:40:55 +01:00
template <class IndexPack, typename MetaType>
2020-08-27 12:00:47 +02:00
static void setMeta(IndexPack& target, const MetaType& source);
2018-11-30 00:16:28 +01:00
template <class SpaceClass>
2020-08-27 12:00:47 +02:00
inline static std::shared_ptr<RangeBase> getSub(const SpaceClass& space, size_t num);
2018-11-30 00:16:28 +01:00
2017-12-17 17:40:55 +01:00
template <class IndexPack>
2020-08-27 12:00:47 +02:00
static void setIndexPack(IndexPack& iPack, size_t pos);
2017-12-17 17:40:55 +01:00
template <class MRange, class... Indices>
static void construct(std::tuple<std::shared_ptr<Indices>...>& ip,
2020-08-27 12:00:47 +02:00
const MRange& range);
2017-12-17 17:40:55 +01:00
template <class IndexType, class... Indices>
2017-12-17 17:40:55 +01:00
static void copyInst(std::tuple<std::shared_ptr<Indices>...>& ip,
2020-08-27 12:00:47 +02:00
const IndexType& ind);
2018-12-25 17:48:52 +01:00
template <class IndexType, class... Indices>
static void copyIndex(std::tuple<std::shared_ptr<Indices>...>& ip,
2020-08-27 12:00:47 +02:00
const IndexType& ind);
2018-12-25 17:48:52 +01:00
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup);
template <class... Indices>
static inline size_t makePos(const std::tuple<std::shared_ptr<Indices>...>& iPtrTup,
2020-08-27 12:00:47 +02:00
const std::array<size_t,sizeof...(Indices)+1>& blockSize);
2017-12-17 17:40:55 +01:00
template <class Pack, class IndexType>
2020-08-27 12:00:47 +02:00
static void swapIndices(Pack& ipack, const std::shared_ptr<IndexType>& nind);
2017-12-17 17:40:55 +01:00
template <class Pack, class... Indices>
2020-08-27 12:00:47 +02:00
static void swapIndices(Pack& ipack, const std::tuple<std::shared_ptr<Indices>...>& ninds);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static size_t blockSize(const std::tuple<std::shared_ptr<Indices>...>& pack);
2017-12-17 17:40:55 +01:00
template <class... Ranges>
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
2020-08-27 12:00:47 +02:00
vector<std::intptr_t>& v);
2017-12-17 17:40:55 +01:00
template <class... Ranges>
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
2020-08-27 12:00:47 +02:00
vector<std::shared_ptr<RangeBase> >& v);
2017-12-17 17:40:55 +01:00
template <class... Indices>
2020-08-27 12:00:47 +02:00
static void printIndex(const std::tuple<std::shared_ptr<Indices>...>& ip, size_t offset);
2017-12-17 17:40:55 +01:00
template <class Range>
2020-08-27 12:00:47 +02:00
static void checkDefaultable();
2017-12-17 17:40:55 +01:00
template <class IndexPack, class BlockArray, class Exprs>
static auto mkFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
2020-08-27 12:00:47 +02:00
->ifor(0,exs) );
template <class IndexPack, class BlockArray, class Exprs>
static auto mkForh(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
2020-08-27 12:00:47 +02:00
->iforh(0,exs) );
2019-01-15 17:41:43 +01:00
template <class IndexPack, class BlockArray, class Exprs>
static auto mkPFor(size_t step, const IndexPack& ipack, const BlockArray& ba, Exprs exs)
-> decltype(std::get<std::tuple_size<IndexPack>::value-1>(ipack)
2020-08-27 12:00:47 +02:00
->pifor(0,exs) );
2019-01-15 17:41:43 +01:00
template <class Index>
2020-08-27 12:00:47 +02:00
static inline void getStepSizeX(const Index& ii, std::intptr_t j, size_t& ss, size_t& sx);
template <class RangeTuple, typename... SIZET>
2019-02-13 21:59:13 +01:00
static inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
2020-08-27 12:00:47 +02:00
RangeTuple& rtp, size_t off, size_t size);
template <class... Ranges>
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
2020-08-27 12:00:47 +02:00
const vector<std::intptr_t>& a);
2019-03-14 14:20:38 +01:00
template <class MIndex>
2020-08-27 12:00:47 +02:00
static inline std::string getStringMeta(const MIndex& mi);
template <class... Ranges>
2019-02-13 21:59:13 +01:00
static inline void fillRangeDataVec(vector<char>& out,
2020-08-27 12:00:47 +02:00
const std::tuple<std::shared_ptr<Ranges>...>& tp);
2018-07-28 15:27:11 +02:00
template <size_t SIZE, class Range>
2020-08-27 12:00:47 +02:00
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec);
2018-07-28 15:27:11 +02:00
template <class... Ranges>
2019-02-13 21:59:13 +01:00
static inline void setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
2020-08-27 12:00:47 +02:00
std::tuple<std::shared_ptr<Ranges>...>& stp);
2018-07-28 15:27:11 +02:00
2019-11-12 13:30:26 +01:00
template <class MetaType, class... Ranges>
static inline size_t getCMeta(MetaType* xtarget, size_t pos,
2020-08-27 12:00:47 +02:00
const std::tuple<std::shared_ptr<Ranges>...>& stp, size_t off);
template <class... Ranges>
2020-08-27 12:00:47 +02:00
static inline size_t getCMetaSize(const std::tuple<std::shared_ptr<Ranges>...>& stp);
template <class... Ranges>
2020-08-27 12:00:47 +02:00
static inline void getTypeNum(vector<size_t>& res, const std::tuple<std::shared_ptr<Ranges>...>& stp);
2019-03-14 14:20:38 +01:00
2017-12-17 17:40:55 +01:00
};
template <IndexType IT>
struct SSG
{
template <class Index>
2020-08-27 12:00:47 +02:00
static inline size_t getStepSize(const Index& ii, std::intptr_t j);
};
template <>
struct SSG<IndexType::SINGLE>
{
template <class Index>
2020-08-27 12:00:47 +02:00
static inline size_t getStepSize(const Index& ii, std::intptr_t j);
};
2017-12-17 17:40:55 +01:00
} // end namespace MultiArrayHelper
2020-08-27 12:00:47 +02:00
//#include "rpack_num.cc.h"
2017-12-17 17:40:55 +01:00
#endif