generalize single range (static size parameter, -> -1 if non-static size)
This commit is contained in:
parent
697aac6b94
commit
f339778a59
14 changed files with 320 additions and 295 deletions
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
project(multi_array)
|
project(multi_array)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11 -Wpedantic -O3 -g -march=native -fopenmp")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -std=c++11 -Wpedantic -O3 -g -march=native -fopenmp -funroll-loops -ftree-vectorize")
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef SingleIndex<size_t,SpaceType::ANON> AnonymousIndex;
|
typedef GenSingleIndex<size_t,SpaceType::ANON,-1> AnonymousIndex;
|
||||||
|
|
||||||
//template <class R>
|
//template <class R>
|
||||||
//using SIZET = size_t;
|
//using SIZET = size_t;
|
||||||
|
|
||||||
typedef SingleRange<size_t,SpaceType::ANON> AnonymousRange;
|
typedef GenSingleRange<size_t,SpaceType::ANON,-1> AnonymousRange;
|
||||||
|
|
||||||
// NOT THREAD SAVE!!
|
// NOT THREAD SAVE!!
|
||||||
class AnonymousRangeFactory : public RangeFactoryBase
|
class AnonymousRangeFactory : public RangeFactoryBase
|
||||||
|
@ -53,7 +53,7 @@ namespace MultiArrayTools
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRange<size_t,SpaceType::ANON> : public RangeInterface<AnonymousIndex>
|
class GenSingleRange<size_t,SpaceType::ANON,-1> : public RangeInterface<AnonymousIndex>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
typedef RangeBase RB;
|
typedef RangeBase RB;
|
||||||
typedef typename RangeInterface<AnonymousIndex>::IndexType IndexType;
|
typedef typename RangeInterface<AnonymousIndex>::IndexType IndexType;
|
||||||
typedef SingleRange<size_t,SpaceType::ANON> RangeType;
|
typedef GenSingleRange<size_t,SpaceType::ANON,-1> RangeType;
|
||||||
typedef size_t MetaType;
|
typedef size_t MetaType;
|
||||||
|
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
|
@ -105,16 +105,16 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SingleRange() = default;
|
GenSingleRange() = default;
|
||||||
SingleRange(const AnonymousRange& in) = default;
|
GenSingleRange(const AnonymousRange& in) = default;
|
||||||
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
SingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
|
GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs);
|
||||||
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
SingleRange(std::shared_ptr<RangeTypes>... origs);
|
GenSingleRange(std::shared_ptr<RangeTypes>... origs);
|
||||||
|
|
||||||
SingleRange(const std::vector<std::shared_ptr<RangeBase>>& origs);
|
GenSingleRange(const std::vector<std::shared_ptr<RangeBase>>& origs);
|
||||||
|
|
||||||
size_t mSize = 1;
|
size_t mSize = 1;
|
||||||
bool mEmpty = true;
|
bool mEmpty = true;
|
||||||
|
@ -203,7 +203,7 @@ namespace MultiArrayTools
|
||||||
***********************/
|
***********************/
|
||||||
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
SingleRange<size_t,SpaceType::ANON>::SingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
GenSingleRange<size_t,SpaceType::ANON,-1>::GenSingleRange(const std::tuple<std::shared_ptr<RangeTypes>...>& origs) :
|
||||||
RangeInterface<AnonymousIndex>()
|
RangeInterface<AnonymousIndex>()
|
||||||
{
|
{
|
||||||
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
|
RPackNum<sizeof...(RangeTypes)-1>::RangesToVec( origs, mOrig );
|
||||||
|
@ -214,7 +214,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
SingleRange<size_t,SpaceType::ANON>::SingleRange(std::shared_ptr<RangeTypes>... origs) :
|
GenSingleRange<size_t,SpaceType::ANON,-1>::GenSingleRange(std::shared_ptr<RangeTypes>... origs) :
|
||||||
RangeInterface<AnonymousIndex>()
|
RangeInterface<AnonymousIndex>()
|
||||||
{
|
{
|
||||||
auto rst = std::make_tuple(origs...);
|
auto rst = std::make_tuple(origs...);
|
||||||
|
@ -226,13 +226,13 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
std::shared_ptr<Range> SingleRange<size_t,SpaceType::ANON>::fullsub(size_t num) const
|
std::shared_ptr<Range> GenSingleRange<size_t,SpaceType::ANON,-1>::fullsub(size_t num) const
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<Range>( mOrig.at(num) );
|
return std::dynamic_pointer_cast<Range>( mOrig.at(num) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
std::shared_ptr<MultiRange<Ranges...> > SingleRange<size_t,SpaceType::ANON>::scast(SIZET<Ranges>... sizes) const
|
std::shared_ptr<MultiRange<Ranges...> > GenSingleRange<size_t,SpaceType::ANON,-1>::scast(SIZET<Ranges>... sizes) const
|
||||||
{
|
{
|
||||||
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
std::tuple<std::shared_ptr<Ranges>...> rtp;
|
||||||
RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
RPackNum<sizeof...(Ranges)-1>::resolveRangeType(mOrig, rtp, 0, sizes...);
|
||||||
|
|
|
@ -12,29 +12,29 @@
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
typedef SingleIndex<size_t,SpaceType::NONE> ClassicIndex;
|
typedef GenSingleIndex<size_t,SpaceType::NONE,-1> ClassicIndex;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRangeFactory<size_t,SpaceType::NONE> : public RangeFactoryBase
|
class GenSingleRangeFactory<size_t,SpaceType::NONE,-1> : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef SingleRange<size_t,SpaceType::NONE> oType;
|
typedef GenSingleRange<size_t,SpaceType::NONE,-1> oType;
|
||||||
|
|
||||||
SingleRangeFactory(size_t size = 0);
|
GenSingleRangeFactory(size_t size = 0);
|
||||||
std::shared_ptr<RangeBase> create();
|
std::shared_ptr<RangeBase> create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRange<size_t,SpaceType::NONE> : public RangeInterface<ClassicIndex>
|
class GenSingleRange<size_t,SpaceType::NONE,-1> : public RangeInterface<ClassicIndex>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef RangeBase RB;
|
typedef RangeBase RB;
|
||||||
typedef typename RangeInterface<SingleIndex<size_t,SpaceType::NONE> >::IndexType IndexType;
|
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::NONE,-1> >::IndexType IndexType;
|
||||||
typedef SingleRange<size_t,SpaceType::NONE> RangeType;
|
typedef GenSingleRange<size_t,SpaceType::NONE,-1> RangeType;
|
||||||
typedef size_t MetaType;
|
typedef size_t MetaType;
|
||||||
typedef SingleRangeFactory<size_t,SpaceType::NONE> FType;
|
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,-1> FType;
|
||||||
|
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
virtual size_t dim() const final;
|
virtual size_t dim() const final;
|
||||||
|
@ -52,28 +52,28 @@ namespace MultiArrayTools
|
||||||
virtual IndexType end() const final;
|
virtual IndexType end() const final;
|
||||||
//virtual std::shared_ptr<VIWB> index() const final;
|
//virtual std::shared_ptr<VIWB> index() const final;
|
||||||
|
|
||||||
friend SingleRangeFactory<size_t,SpaceType::NONE>;
|
friend GenSingleRangeFactory<size_t,SpaceType::NONE,-1>;
|
||||||
|
|
||||||
static constexpr bool defaultable = true;
|
static constexpr bool defaultable = true;
|
||||||
static constexpr size_t ISSTATIC = 0;
|
static constexpr size_t ISSTATIC = 0;
|
||||||
static constexpr size_t SIZE = -1;
|
static constexpr size_t SIZE = -1;
|
||||||
static constexpr bool HASMETACONT = false;
|
static constexpr bool HASMETACONT = false;
|
||||||
|
|
||||||
static SingleRangeFactory<size_t, SpaceType::NONE> factory(size_t size = 0)
|
static GenSingleRangeFactory<size_t,SpaceType::NONE,-1> factory(size_t size = 0)
|
||||||
{ return SingleRangeFactory<size_t, SpaceType::NONE>(size); }
|
{ return GenSingleRangeFactory<size_t,SpaceType::NONE,-1>(size); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
size_t mSize = 0;
|
size_t mSize = 0;
|
||||||
|
|
||||||
SingleRange() = default;
|
GenSingleRange() = default;
|
||||||
SingleRange(const SingleRange& in) = delete;
|
GenSingleRange(const GenSingleRange& in) = delete;
|
||||||
|
|
||||||
SingleRange(size_t size);
|
GenSingleRange(size_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SingleRange<size_t,SpaceType::NONE> ClassicRange;
|
typedef GenSingleRange<size_t,SpaceType::NONE,-1> ClassicRange;
|
||||||
typedef SingleRangeFactory<size_t,SpaceType::NONE> ClassicRF;
|
typedef GenSingleRangeFactory<size_t,SpaceType::NONE,-1> ClassicRF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,19 @@ include_range_type(NUL,-2)
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
typedef SingleIndex<size_t,SpaceType::NUL> NullIndex;
|
typedef GenSingleIndex<size_t,SpaceType::NUL,0> NullIndex;
|
||||||
|
|
||||||
std::shared_ptr<SingleRange<size_t,SpaceType::NUL> > nullr();
|
std::shared_ptr<GenSingleRange<size_t,SpaceType::NUL,0> > nullr();
|
||||||
std::shared_ptr<NullIndex> nulli();
|
std::shared_ptr<NullIndex> nulli();
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRangeFactory<size_t,SpaceType::NUL> : public RangeFactoryBase
|
class GenSingleRangeFactory<size_t,SpaceType::NUL,0> : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef SingleRange<size_t,SpaceType::NUL> oType;
|
typedef GenSingleRange<size_t,SpaceType::NUL,0> oType;
|
||||||
|
|
||||||
SingleRangeFactory();
|
GenSingleRangeFactory();
|
||||||
std::shared_ptr<RangeBase> create();
|
std::shared_ptr<RangeBase> create();
|
||||||
|
|
||||||
friend std::shared_ptr<oType> nullr();
|
friend std::shared_ptr<oType> nullr();
|
||||||
|
@ -34,14 +34,14 @@ namespace MultiArrayTools
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRange<size_t,SpaceType::NUL> : public RangeInterface<NullIndex>
|
class GenSingleRange<size_t,SpaceType::NUL,0> : public RangeInterface<NullIndex>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef RangeBase RB;
|
typedef RangeBase RB;
|
||||||
typedef typename RangeInterface<SingleIndex<size_t,SpaceType::NUL> >::IndexType IndexType;
|
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::NUL,0> >::IndexType IndexType;
|
||||||
typedef SingleRange<size_t,SpaceType::NUL> RangeType;
|
typedef GenSingleRange<size_t,SpaceType::NUL,0> RangeType;
|
||||||
typedef size_t MetaType;
|
typedef size_t MetaType;
|
||||||
typedef SingleRangeFactory<size_t,SpaceType::NUL> FType;
|
typedef GenSingleRangeFactory<size_t,SpaceType::NUL,0> FType;
|
||||||
|
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
virtual size_t dim() const final;
|
virtual size_t dim() const final;
|
||||||
|
@ -59,7 +59,7 @@ namespace MultiArrayTools
|
||||||
virtual IndexType end() const final;
|
virtual IndexType end() const final;
|
||||||
//virtual std::shared_ptr<VIWB> index() const final;
|
//virtual std::shared_ptr<VIWB> index() const final;
|
||||||
|
|
||||||
friend SingleRangeFactory<size_t,SpaceType::NUL>;
|
friend GenSingleRangeFactory<size_t,SpaceType::NUL,0>;
|
||||||
|
|
||||||
static constexpr bool defaultable = true;
|
static constexpr bool defaultable = true;
|
||||||
|
|
||||||
|
@ -67,19 +67,19 @@ namespace MultiArrayTools
|
||||||
static constexpr size_t SIZE = 1;
|
static constexpr size_t SIZE = 1;
|
||||||
static constexpr bool HASMETACONT = false;
|
static constexpr bool HASMETACONT = false;
|
||||||
|
|
||||||
static SingleRangeFactory<size_t,SpaceType::NUL> factory()
|
static GenSingleRangeFactory<size_t,SpaceType::NUL,0> factory()
|
||||||
{ return SingleRangeFactory<size_t,SpaceType::NUL>(); }
|
{ return GenSingleRangeFactory<size_t,SpaceType::NUL,0>(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SingleRange() = default;
|
GenSingleRange() = default;
|
||||||
SingleRange(const SingleRange& in) = delete;
|
GenSingleRange(const GenSingleRange& in) = delete;
|
||||||
|
|
||||||
//SingleRange(size_t spinNum);
|
//GenSingleRange(size_t spinNum);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SingleRange<size_t,SpaceType::NUL> NullRange;
|
typedef GenSingleRange<size_t,SpaceType::NUL,0> NullRange;
|
||||||
typedef SingleRangeFactory<size_t,SpaceType::NUL> NullRF;
|
typedef GenSingleRangeFactory<size_t,SpaceType::NUL,0> NullRF;
|
||||||
|
|
||||||
std::shared_ptr<NullRF> mkNUL(const char* dp, size_t size);
|
std::shared_ptr<NullRF> mkNUL(const char* dp, size_t size);
|
||||||
|
|
||||||
|
|
|
@ -11,29 +11,29 @@ include_range_type(PSPACE,3) // Periodic 1dim space
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
// Periodic 1dim space
|
// Periodic 1dim space
|
||||||
typedef SingleIndex<int,SpaceType::PSPACE> XSpaceIndex;
|
typedef GenSingleIndex<int,SpaceType::PSPACE,-1> XSpaceIndex;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRangeFactory<int,SpaceType::PSPACE> : public RangeFactoryBase
|
class GenSingleRangeFactory<int,SpaceType::PSPACE,-1> : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef SingleRange<int,SpaceType::PSPACE> oType;
|
typedef GenSingleRange<int,SpaceType::PSPACE,-1> oType;
|
||||||
|
|
||||||
SingleRangeFactory(size_t size = 0);
|
GenSingleRangeFactory(size_t size = 0);
|
||||||
std::shared_ptr<RangeBase> create();
|
std::shared_ptr<RangeBase> create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRange<int,SpaceType::PSPACE> : public RangeInterface<XSpaceIndex>
|
class GenSingleRange<int,SpaceType::PSPACE,-1> : public RangeInterface<XSpaceIndex>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef RangeBase RB;
|
typedef RangeBase RB;
|
||||||
typedef typename RangeInterface<SingleIndex<int,SpaceType::PSPACE> >::IndexType IndexType;
|
typedef typename RangeInterface<GenSingleIndex<int,SpaceType::PSPACE,-1> >::IndexType IndexType;
|
||||||
typedef SingleRange<int,SpaceType::PSPACE> RangeType;
|
typedef GenSingleRange<int,SpaceType::PSPACE,-1> RangeType;
|
||||||
typedef int MetaType;
|
typedef int MetaType;
|
||||||
typedef SingleRangeFactory<int,SpaceType::PSPACE> FType;
|
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,-1> FType;
|
||||||
|
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
virtual size_t dim() const final;
|
virtual size_t dim() const final;
|
||||||
|
@ -50,28 +50,28 @@ namespace MultiArrayTools
|
||||||
virtual IndexType begin() const final;
|
virtual IndexType begin() const final;
|
||||||
virtual IndexType end() const final;
|
virtual IndexType end() const final;
|
||||||
|
|
||||||
friend SingleRangeFactory<int,SpaceType::PSPACE>;
|
friend GenSingleRangeFactory<int,SpaceType::PSPACE,-1>;
|
||||||
|
|
||||||
static constexpr bool defaultable = true;
|
static constexpr bool defaultable = true;
|
||||||
static constexpr size_t ISSTATIC = 0;
|
static constexpr size_t ISSTATIC = 0;
|
||||||
static constexpr size_t SIZE = -1;
|
static constexpr size_t SIZE = -1;
|
||||||
static constexpr bool HASMETACONT = false;
|
static constexpr bool HASMETACONT = false;
|
||||||
|
|
||||||
static SingleRangeFactory<int, SpaceType::PSPACE> factory(size_t size = 0)
|
static GenSingleRangeFactory<int,SpaceType::PSPACE,-1> factory(size_t size = 0)
|
||||||
{ return SingleRangeFactory<int, SpaceType::PSPACE>(size); }
|
{ return GenSingleRangeFactory<int,SpaceType::PSPACE,-1>(size); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
size_t mSize = 0;
|
size_t mSize = 0;
|
||||||
|
|
||||||
SingleRange() = default;
|
GenSingleRange() = default;
|
||||||
SingleRange(const SingleRange& in) = delete;
|
GenSingleRange(const GenSingleRange& in) = delete;
|
||||||
|
|
||||||
SingleRange(size_t size);
|
GenSingleRange(size_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SingleRange<int,SpaceType::PSPACE> PSpaceRange;
|
typedef GenSingleRange<int,SpaceType::PSPACE,-1> PSpaceRange;
|
||||||
typedef SingleRangeFactory<int,SpaceType::PSPACE> PSpaceRF;
|
typedef GenSingleRangeFactory<int,SpaceType::PSPACE,-1> PSpaceRF;
|
||||||
|
|
||||||
std::shared_ptr<PSpaceRF> mkPSPACE(const char* dp, size_t size);
|
std::shared_ptr<PSpaceRF> mkPSPACE(const char* dp, size_t size);
|
||||||
|
|
||||||
|
|
|
@ -12,29 +12,29 @@ include_range_type(SPIN,2)
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
typedef SingleIndex<size_t,SpaceType::SPIN> SpinIndex;
|
typedef GenSingleIndex<size_t,SpaceType::SPIN,4> SpinIndex;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRangeFactory<size_t,SpaceType::SPIN> : public RangeFactoryBase
|
class GenSingleRangeFactory<size_t,SpaceType::SPIN,4> : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef SingleRange<size_t,SpaceType::SPIN> oType;
|
typedef GenSingleRange<size_t,SpaceType::SPIN,4> oType;
|
||||||
|
|
||||||
SingleRangeFactory();
|
GenSingleRangeFactory();
|
||||||
std::shared_ptr<RangeBase> create();
|
std::shared_ptr<RangeBase> create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SingleRange<size_t,SpaceType::SPIN> : public RangeInterface<SpinIndex>
|
class GenSingleRange<size_t,SpaceType::SPIN,4> : public RangeInterface<SpinIndex>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef RangeBase RB;
|
typedef RangeBase RB;
|
||||||
typedef typename RangeInterface<SingleIndex<size_t,SpaceType::SPIN> >::IndexType IndexType;
|
typedef typename RangeInterface<GenSingleIndex<size_t,SpaceType::SPIN,4> >::IndexType IndexType;
|
||||||
typedef SingleRange<size_t,SpaceType::SPIN> RangeType;
|
typedef GenSingleRange<size_t,SpaceType::SPIN,4> RangeType;
|
||||||
typedef size_t MetaType;
|
typedef size_t MetaType;
|
||||||
typedef SingleRangeFactory<size_t,SpaceType::SPIN> FType;
|
typedef GenSingleRangeFactory<size_t,SpaceType::SPIN,4> FType;
|
||||||
|
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
virtual size_t dim() const final;
|
virtual size_t dim() const final;
|
||||||
|
@ -52,7 +52,7 @@ namespace MultiArrayTools
|
||||||
virtual IndexType end() const final;
|
virtual IndexType end() const final;
|
||||||
//virtual std::shared_ptr<VIWB> index() const final;
|
//virtual std::shared_ptr<VIWB> index() const final;
|
||||||
|
|
||||||
friend SingleRangeFactory<size_t,SpaceType::SPIN>;
|
friend GenSingleRangeFactory<size_t,SpaceType::SPIN,4>;
|
||||||
|
|
||||||
static constexpr bool defaultable = true;
|
static constexpr bool defaultable = true;
|
||||||
static constexpr size_t mSpinNum = 4;
|
static constexpr size_t mSpinNum = 4;
|
||||||
|
@ -61,19 +61,19 @@ namespace MultiArrayTools
|
||||||
static constexpr size_t SIZE = mSpinNum;
|
static constexpr size_t SIZE = mSpinNum;
|
||||||
static constexpr bool HASMETACONT = false;
|
static constexpr bool HASMETACONT = false;
|
||||||
|
|
||||||
static SingleRangeFactory<size_t, SpaceType::SPIN> factory()
|
static GenSingleRangeFactory<size_t,SpaceType::SPIN,4> factory()
|
||||||
{ return SingleRangeFactory<size_t, SpaceType::SPIN>(); }
|
{ return GenSingleRangeFactory<size_t,SpaceType::SPIN,4>(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SingleRange() = default;
|
GenSingleRange() = default;
|
||||||
SingleRange(const SingleRange& in) = delete;
|
GenSingleRange(const GenSingleRange& in) = delete;
|
||||||
|
|
||||||
//SingleRange(size_t spinNum);
|
//GenSingleRange(size_t spinNum);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SingleRange<size_t,SpaceType::SPIN> SpinRange;
|
typedef GenSingleRange<size_t,SpaceType::SPIN,4> SpinRange;
|
||||||
typedef SingleRangeFactory<size_t,SpaceType::SPIN> SpinRF;
|
typedef GenSingleRangeFactory<size_t,SpaceType::SPIN,4> SpinRF;
|
||||||
|
|
||||||
std::shared_ptr<SpinRF> mkSPIN(const char* dp, size_t size);
|
std::shared_ptr<SpinRF> mkSPIN(const char* dp, size_t size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,16 +44,16 @@ namespace MultiArrayTools
|
||||||
class IndexInterface;
|
class IndexInterface;
|
||||||
|
|
||||||
// single_range.h
|
// single_range.h
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
class SingleRange;
|
class GenSingleRange;
|
||||||
|
|
||||||
// single_range.h
|
// single_range.h
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
class SingleRangeFactory;
|
class GenSingleRangeFactory;
|
||||||
|
|
||||||
// single_range.h
|
// single_range.h
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
class SingleIndex;
|
class GenSingleIndex;
|
||||||
|
|
||||||
// subrange.h
|
// subrange.h
|
||||||
template <class Index>
|
template <class Index>
|
||||||
|
|
|
@ -28,19 +28,19 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
class SingleIndex : public IndexInterface<SingleIndex<U,TYPE>,U>
|
class GenSingleIndex : public IndexInterface<GenSingleIndex<U,TYPE,S>,U>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef IndexInterface<SingleIndex<U,TYPE>,U> IB;
|
typedef IndexInterface<GenSingleIndex<U,TYPE,S>,U> IB;
|
||||||
typedef U MetaType;
|
typedef U MetaType;
|
||||||
typedef SingleRange<U,TYPE> RangeType;
|
typedef GenSingleRange<U,TYPE,S> RangeType;
|
||||||
typedef SingleIndex IType;
|
typedef GenSingleIndex IType;
|
||||||
|
|
||||||
//DEFAULT_MEMBERS_X(SingleIndex);
|
//DEFAULT_MEMBERS_X(GenSingleIndex);
|
||||||
|
|
||||||
SingleIndex(const std::shared_ptr<SingleRange<U,TYPE> >& range);
|
GenSingleIndex(const std::shared_ptr<GenSingleRange<U,TYPE,S> >& range);
|
||||||
|
|
||||||
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
static constexpr IndexType sType() { return IndexType::SINGLE; }
|
||||||
static constexpr size_t totalDim() { return 1; }
|
static constexpr size_t totalDim() { return 1; }
|
||||||
|
@ -53,9 +53,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
IndexType type() const;
|
IndexType type() const;
|
||||||
|
|
||||||
SingleIndex& operator=(size_t pos);
|
GenSingleIndex& operator=(size_t pos);
|
||||||
SingleIndex& operator++();
|
GenSingleIndex& operator++();
|
||||||
SingleIndex& operator--();
|
GenSingleIndex& operator--();
|
||||||
|
|
||||||
int pp(std::intptr_t idxPtrNum);
|
int pp(std::intptr_t idxPtrNum);
|
||||||
int mm(std::intptr_t idxPtrNum);
|
int mm(std::intptr_t idxPtrNum);
|
||||||
|
@ -63,7 +63,7 @@ namespace MultiArrayTools
|
||||||
std::string stringMeta() const;
|
std::string stringMeta() const;
|
||||||
U meta() const;
|
U meta() const;
|
||||||
const U* metaPtr() const;
|
const U* metaPtr() const;
|
||||||
SingleIndex& at(const U& metaPos);
|
GenSingleIndex& at(const U& metaPos);
|
||||||
size_t posAt(const U& metaPos) const;
|
size_t posAt(const U& metaPos) const;
|
||||||
|
|
||||||
bool isMeta(const U& metaPos) const;
|
bool isMeta(const U& metaPos) const;
|
||||||
|
@ -84,30 +84,30 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
auto ifor(size_t step, Expr ex) const
|
auto ifor(size_t step, Expr ex) const
|
||||||
-> For<SingleIndex<U,TYPE>,Expr>;
|
-> For<GenSingleIndex<U,TYPE,S>,Expr>;
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
auto iforh(size_t step, Expr ex) const
|
auto iforh(size_t step, Expr ex) const
|
||||||
-> For<SingleIndex<U,TYPE>,Expr,ForType::HIDDEN>;
|
-> For<GenSingleIndex<U,TYPE,S>,Expr,ForType::HIDDEN>;
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
auto pifor(size_t step, Expr ex) const
|
auto pifor(size_t step, Expr ex) const
|
||||||
-> PFor<SingleIndex<U,TYPE>,Expr>;
|
-> PFor<GenSingleIndex<U,TYPE,S>,Expr>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<RangeType> mExplicitRangePtr;
|
std::shared_ptr<RangeType> mExplicitRangePtr;
|
||||||
const U* mMetaPtr;
|
const U* mMetaPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
class SingleRangeFactory : public RangeFactoryBase
|
class GenSingleRangeFactory : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef SingleRange<U,TYPE> oType;
|
typedef GenSingleRange<U,TYPE,S> oType;
|
||||||
|
|
||||||
SingleRangeFactory() = delete;
|
GenSingleRangeFactory() = delete;
|
||||||
SingleRangeFactory(const std::vector<U>& space);
|
GenSingleRangeFactory(const std::vector<U>& space);
|
||||||
std::shared_ptr<RangeBase> create();
|
std::shared_ptr<RangeBase> create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -187,16 +187,30 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <size_t S>
|
||||||
class SingleRange : public RangeInterface<SingleIndex<U,TYPE> >
|
struct CheckStatic
|
||||||
|
{
|
||||||
|
static constexpr size_t ISSTATIC = true;
|
||||||
|
static constexpr size_t SIZE = S;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct CheckStatic<-1>
|
||||||
|
{
|
||||||
|
static constexpr size_t ISSTATIC = false;
|
||||||
|
static constexpr size_t SIZE = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
|
class GenSingleRange : public RangeInterface<GenSingleIndex<U,TYPE,S> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef RangeBase RB;
|
typedef RangeBase RB;
|
||||||
typedef SingleIndex<U,TYPE> IndexType;
|
typedef GenSingleIndex<U,TYPE,S> IndexType;
|
||||||
typedef SingleRange RangeType;
|
typedef GenSingleRange RangeType;
|
||||||
typedef U MetaType;
|
typedef U MetaType;
|
||||||
typedef SingleRangeFactory<U,TYPE> FType;
|
typedef GenSingleRangeFactory<U,TYPE,S> FType;
|
||||||
//typedef typename RangeInterface<SingleIndex<U,TYPE> >::IndexType IndexType;
|
//typedef typename RangeInterface<GenSingleIndex<U,TYPE,S> >::IndexType IndexType;
|
||||||
|
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
virtual size_t dim() const final;
|
virtual size_t dim() const final;
|
||||||
|
@ -215,25 +229,34 @@ namespace MultiArrayTools
|
||||||
virtual IndexType begin() const final;
|
virtual IndexType begin() const final;
|
||||||
virtual IndexType end() const final;
|
virtual IndexType end() const final;
|
||||||
|
|
||||||
friend SingleRangeFactory<U,TYPE>;
|
friend GenSingleRangeFactory<U,TYPE,S>;
|
||||||
|
|
||||||
static constexpr bool defaultable = false;
|
static constexpr bool defaultable = false;
|
||||||
static constexpr size_t ISSTATIC = 0;
|
static constexpr size_t ISSTATIC = CheckStatic<S>::ISSTATIC;
|
||||||
static constexpr size_t SIZE = -1;
|
static constexpr size_t SIZE = CheckStatic<S>::SIZE;
|
||||||
static constexpr bool HASMETACONT = true;
|
static constexpr bool HASMETACONT = true;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SingleRange() = delete;
|
GenSingleRange() = delete;
|
||||||
SingleRange(const SingleRange& in) = delete;
|
GenSingleRange(const GenSingleRange& in) = delete;
|
||||||
|
|
||||||
SingleRange(const std::vector<U>& space);
|
GenSingleRange(const std::vector<U>& space);
|
||||||
|
|
||||||
std::vector<U> mSpace;
|
std::vector<U> mSpace;
|
||||||
//std::map<U,size_t> mMSpace;
|
//std::map<U,size_t> mMSpace;
|
||||||
MetaMap<U> mMSpace;
|
MetaMap<U> mMSpace;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename U, SpaceType TYPE>
|
||||||
|
using SingleRange = GenSingleRange<U,TYPE,-1>;
|
||||||
|
|
||||||
|
template <typename U, SpaceType TYPE>
|
||||||
|
using SingleIndex = GenSingleIndex<U,TYPE,-1>;
|
||||||
|
|
||||||
|
template <typename U, SpaceType TYPE>
|
||||||
|
using SingleRangeFactory = GenSingleRangeFactory<U,TYPE,-1>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================= *
|
/* ========================= *
|
||||||
|
@ -243,7 +266,7 @@ namespace MultiArrayTools
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
/******************
|
/******************
|
||||||
* SingleIndex *
|
* GenSingleIndex *
|
||||||
******************/
|
******************/
|
||||||
|
|
||||||
template <bool HASMETACONT>
|
template <bool HASMETACONT>
|
||||||
|
@ -278,134 +301,134 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SingleIndex<U,TYPE>::SingleIndex(const std::shared_ptr<SingleRange<U,TYPE> >& range) :
|
GenSingleIndex<U,TYPE,S>::GenSingleIndex(const std::shared_ptr<GenSingleRange<U,TYPE,S> >& range) :
|
||||||
IndexInterface<SingleIndex<U,TYPE>,U>(range, 0),
|
IndexInterface<GenSingleIndex<U,TYPE,S>,U>(range, 0),
|
||||||
mExplicitRangePtr(std::dynamic_pointer_cast<RangeType>(IB::mRangePtr)),
|
mExplicitRangePtr(std::dynamic_pointer_cast<RangeType>(IB::mRangePtr)),
|
||||||
mMetaPtr(MetaPtrHandle<SingleIndex<U,TYPE>::RangeType::HASMETACONT>::set
|
mMetaPtr(MetaPtrHandle<GenSingleIndex<U,TYPE,S>::RangeType::HASMETACONT>::set
|
||||||
( dynamic_cast<RangeType*>(IB::mRangePtr.get() ) ) ) {}
|
( dynamic_cast<RangeType*>(IB::mRangePtr.get() ) ) ) {}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
IndexType SingleIndex<U,TYPE>::type() const
|
IndexType GenSingleIndex<U,TYPE,S>::type() const
|
||||||
{
|
{
|
||||||
return IndexType::SINGLE;
|
return IndexType::SINGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::operator=(size_t pos)
|
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::operator=(size_t pos)
|
||||||
{
|
{
|
||||||
IB::mPos = pos;
|
IB::mPos = pos;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::operator++()
|
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::operator++()
|
||||||
{
|
{
|
||||||
++IB::mPos;
|
++IB::mPos;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::operator--()
|
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::operator--()
|
||||||
{
|
{
|
||||||
--IB::mPos;
|
--IB::mPos;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
int SingleIndex<U,TYPE>::pp(std::intptr_t idxPtrNum)
|
int GenSingleIndex<U,TYPE,S>::pp(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
++(*this);
|
++(*this);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
int SingleIndex<U,TYPE>::mm(std::intptr_t idxPtrNum)
|
int GenSingleIndex<U,TYPE,S>::mm(std::intptr_t idxPtrNum)
|
||||||
{
|
{
|
||||||
--(*this);
|
--(*this);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
std::string SingleIndex<U,TYPE>::stringMeta() const
|
std::string GenSingleIndex<U,TYPE,S>::stringMeta() const
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<SingleRange<U,TYPE> const>( IB::mRangePtr )->stringMeta(IB::mPos);
|
return std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> const>( IB::mRangePtr )->stringMeta(IB::mPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
U SingleIndex<U,TYPE>::meta() const
|
U GenSingleIndex<U,TYPE,S>::meta() const
|
||||||
{
|
{
|
||||||
return MetaPtrHandle<SingleIndex<U,TYPE>::RangeType::HASMETACONT>::getMeta
|
return MetaPtrHandle<GenSingleIndex<U,TYPE,S>::RangeType::HASMETACONT>::getMeta
|
||||||
( mMetaPtr, IB::mPos, mExplicitRangePtr );
|
( mMetaPtr, IB::mPos, mExplicitRangePtr );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
const U* SingleIndex<U,TYPE>::metaPtr() const
|
const U* GenSingleIndex<U,TYPE,S>::metaPtr() const
|
||||||
{
|
{
|
||||||
return mMetaPtr;
|
return mMetaPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
bool SingleIndex<U,TYPE>::isMeta(const U& metaPos) const
|
bool GenSingleIndex<U,TYPE,S>::isMeta(const U& metaPos) const
|
||||||
{
|
{
|
||||||
return mExplicitRangePtr->isMeta(metaPos);
|
return mExplicitRangePtr->isMeta(metaPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SingleIndex<U,TYPE>& SingleIndex<U,TYPE>::at(const U& metaPos)
|
GenSingleIndex<U,TYPE,S>& GenSingleIndex<U,TYPE,S>::at(const U& metaPos)
|
||||||
{
|
{
|
||||||
(*this) = std::dynamic_pointer_cast<SingleRange<U,TYPE> const>( IB::mRangePtr )->getMeta( metaPos );
|
(*this) = std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> const>( IB::mRangePtr )->getMeta( metaPos );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
size_t SingleIndex<U,TYPE>::posAt(const U& metaPos) const
|
size_t GenSingleIndex<U,TYPE,S>::posAt(const U& metaPos) const
|
||||||
{
|
{
|
||||||
return std::dynamic_pointer_cast<SingleRange<U,TYPE> const>( IB::mRangePtr )->getMeta( metaPos );
|
return std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> const>( IB::mRangePtr )->getMeta( metaPos );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
size_t SingleIndex<U,TYPE>::dim() // = 1
|
size_t GenSingleIndex<U,TYPE,S>::dim() // = 1
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
bool SingleIndex<U,TYPE>::last()
|
bool GenSingleIndex<U,TYPE,S>::last()
|
||||||
{
|
{
|
||||||
return IB::mPos == IB::mMax - 1;
|
return IB::mPos == IB::mMax - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
bool SingleIndex<U,TYPE>::first()
|
bool GenSingleIndex<U,TYPE,S>::first()
|
||||||
{
|
{
|
||||||
return IB::mPos == 0;
|
return IB::mPos == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
std::shared_ptr<typename SingleIndex<U,TYPE>::RangeType> SingleIndex<U,TYPE>::range()
|
std::shared_ptr<typename GenSingleIndex<U,TYPE,S>::RangeType> GenSingleIndex<U,TYPE,S>::range()
|
||||||
{
|
{
|
||||||
return mExplicitRangePtr;
|
return mExplicitRangePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
void SingleIndex<U,TYPE>::getPtr() {}
|
void GenSingleIndex<U,TYPE,S>::getPtr() {}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
size_t SingleIndex<U,TYPE>::getStepSize(size_t n)
|
size_t GenSingleIndex<U,TYPE,S>::getStepSize(size_t n)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
std::string SingleIndex<U,TYPE>::id() const
|
std::string GenSingleIndex<U,TYPE,S>::id() const
|
||||||
{
|
{
|
||||||
return std::string("sin") + std::to_string(IB::mId);
|
return std::string("sin") + std::to_string(IB::mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
void SingleIndex<U,TYPE>::print(size_t offset)
|
void GenSingleIndex<U,TYPE,S>::print(size_t offset)
|
||||||
{
|
{
|
||||||
if(offset == 0){
|
if(offset == 0){
|
||||||
std::cout << " === " << std::endl;
|
std::cout << " === " << std::endl;
|
||||||
|
@ -415,31 +438,31 @@ namespace MultiArrayTools
|
||||||
<< "](" << IB::mRangePtr << "): " << meta() << std::endl;
|
<< "](" << IB::mRangePtr << "): " << meta() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
auto SingleIndex<U,TYPE>::ifor(size_t step, Expr ex) const
|
auto GenSingleIndex<U,TYPE,S>::ifor(size_t step, Expr ex) const
|
||||||
-> For<SingleIndex<U,TYPE>,Expr>
|
-> For<GenSingleIndex<U,TYPE,S>,Expr>
|
||||||
{
|
{
|
||||||
//static const size_t LAYER = typename Expr::LAYER;
|
//static const size_t LAYER = typename Expr::LAYER;
|
||||||
return For<SingleIndex<U,TYPE>,Expr>(this, step, ex);
|
return For<GenSingleIndex<U,TYPE,S>,Expr>(this, step, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
auto SingleIndex<U,TYPE>::iforh(size_t step, Expr ex) const
|
auto GenSingleIndex<U,TYPE,S>::iforh(size_t step, Expr ex) const
|
||||||
-> For<SingleIndex<U,TYPE>,Expr,ForType::HIDDEN>
|
-> For<GenSingleIndex<U,TYPE,S>,Expr,ForType::HIDDEN>
|
||||||
{
|
{
|
||||||
//static const size_t LAYER = typename Expr::LAYER;
|
//static const size_t LAYER = typename Expr::LAYER;
|
||||||
return For<SingleIndex<U,TYPE>,Expr,ForType::HIDDEN>(this, step, ex);
|
return For<GenSingleIndex<U,TYPE,S>,Expr,ForType::HIDDEN>(this, step, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
auto SingleIndex<U,TYPE>::pifor(size_t step, Expr ex) const
|
auto GenSingleIndex<U,TYPE,S>::pifor(size_t step, Expr ex) const
|
||||||
-> PFor<SingleIndex<U,TYPE>,Expr>
|
-> PFor<GenSingleIndex<U,TYPE,S>,Expr>
|
||||||
{
|
{
|
||||||
//static const size_t LAYER = typename Expr::LAYER;
|
//static const size_t LAYER = typename Expr::LAYER;
|
||||||
return PFor<SingleIndex<U,TYPE>,Expr>(this, step, ex);
|
return PFor<GenSingleIndex<U,TYPE,S>,Expr>(this, step, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -447,14 +470,14 @@ namespace MultiArrayTools
|
||||||
* SingleRange *
|
* SingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SingleRangeFactory<U,TYPE>::SingleRangeFactory(const std::vector<U>& space)
|
GenSingleRangeFactory<U,TYPE,S>::GenSingleRangeFactory(const std::vector<U>& space)
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new SingleRange<U,TYPE>( space ) );
|
mProd = std::shared_ptr<oType>( new GenSingleRange<U,TYPE,S>( space ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
std::shared_ptr<RangeBase> SingleRangeFactory<U,TYPE>::create()
|
std::shared_ptr<RangeBase> GenSingleRangeFactory<U,TYPE,S>::create()
|
||||||
{
|
{
|
||||||
setSelf();
|
setSelf();
|
||||||
return mProd;
|
return mProd;
|
||||||
|
@ -464,9 +487,9 @@ namespace MultiArrayTools
|
||||||
* SingleRange *
|
* SingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SingleRange<U,TYPE>::SingleRange(const std::vector<U>& space) :
|
GenSingleRange<U,TYPE,S>::GenSingleRange(const std::vector<U>& space) :
|
||||||
RangeInterface<SingleIndex<U,TYPE> >(),
|
RangeInterface<GenSingleIndex<U,TYPE,S> >(),
|
||||||
mSpace(space), mMSpace(mSpace)
|
mSpace(space), mMSpace(mSpace)
|
||||||
{
|
{
|
||||||
//for(size_t i = 0; i != mSpace.size(); ++i){
|
//for(size_t i = 0; i != mSpace.size(); ++i){
|
||||||
|
@ -474,50 +497,50 @@ namespace MultiArrayTools
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
const U& SingleRange<U,TYPE>::get(size_t pos) const
|
const U& GenSingleRange<U,TYPE,S>::get(size_t pos) const
|
||||||
{
|
{
|
||||||
return mSpace[pos];
|
return mSpace[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
size_t SingleRange<U,TYPE>::getMeta(const U& metaPos) const
|
size_t GenSingleRange<U,TYPE,S>::getMeta(const U& metaPos) const
|
||||||
{
|
{
|
||||||
return mMSpace.at(metaPos);
|
return mMSpace.at(metaPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
size_t SingleRange<U,TYPE>::size() const
|
size_t GenSingleRange<U,TYPE,S>::size() const
|
||||||
{
|
{
|
||||||
return mSpace.size();
|
return mSpace.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
size_t SingleRange<U,TYPE>::dim() const
|
size_t GenSingleRange<U,TYPE,S>::dim() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
bool SingleRange<U,TYPE>::isMeta(const U& metaPos) const
|
bool GenSingleRange<U,TYPE,S>::isMeta(const U& metaPos) const
|
||||||
{
|
{
|
||||||
return mMSpace.count(metaPos) != 0;
|
return mMSpace.count(metaPos) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
SpaceType SingleRange<U,TYPE>::spaceType() const
|
SpaceType GenSingleRange<U,TYPE,S>::spaceType() const
|
||||||
{
|
{
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
std::string SingleRange<U,TYPE>::stringMeta(size_t pos) const
|
std::string GenSingleRange<U,TYPE,S>::stringMeta(size_t pos) const
|
||||||
{
|
{
|
||||||
return xToString(get(pos));
|
return xToString(get(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
std::vector<char> SingleRange<U,TYPE>::data() const
|
std::vector<char> GenSingleRange<U,TYPE,S>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
std::vector<char> out;
|
||||||
|
@ -530,8 +553,8 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
DataHeader SingleRange<U,TYPE>::dataHeader() const
|
DataHeader GenSingleRange<U,TYPE,S>::dataHeader() const
|
||||||
{
|
{
|
||||||
DataHeader h;
|
DataHeader h;
|
||||||
h.spaceType = static_cast<int>( TYPE );
|
h.spaceType = static_cast<int>( TYPE );
|
||||||
|
@ -541,19 +564,19 @@ namespace MultiArrayTools
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
typename SingleRange<U,TYPE>::IndexType SingleRange<U,TYPE>::begin() const
|
typename GenSingleRange<U,TYPE,S>::IndexType GenSingleRange<U,TYPE,S>::begin() const
|
||||||
{
|
{
|
||||||
SingleIndex<U,TYPE> i( std::dynamic_pointer_cast<SingleRange<U,TYPE> >
|
GenSingleIndex<U,TYPE,S> i( std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = 0;
|
i = 0;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
typename SingleRange<U,TYPE>::IndexType SingleRange<U,TYPE>::end() const
|
typename GenSingleRange<U,TYPE,S>::IndexType GenSingleRange<U,TYPE,S>::end() const
|
||||||
{
|
{
|
||||||
SingleIndex<U,TYPE> i( std::dynamic_pointer_cast<SingleRange<U,TYPE> >
|
GenSingleIndex<U,TYPE,S> i( std::dynamic_pointer_cast<GenSingleRange<U,TYPE,S> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = size();
|
i = size();
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -196,7 +196,7 @@ namespace MultiArrayTools
|
||||||
return mOrig;
|
return mOrig;
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleRange<size_t,SpaceType::ANON>::SingleRange(const std::vector<std::shared_ptr<RangeBase>>& origs) :
|
GenSingleRange<size_t,SpaceType::ANON,-1>::GenSingleRange(const std::vector<std::shared_ptr<RangeBase>>& origs) :
|
||||||
RangeInterface<AnonymousIndex>(),
|
RangeInterface<AnonymousIndex>(),
|
||||||
mOrig(origs)
|
mOrig(origs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,60 +5,60 @@
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
SingleRangeFactory<size_t,SpaceType::NONE>::SingleRangeFactory(size_t size)
|
GenSingleRangeFactory<size_t,SpaceType::NONE,-1>::GenSingleRangeFactory(size_t size)
|
||||||
{
|
{
|
||||||
// Quasi Singleton
|
// Quasi Singleton
|
||||||
if(not mProd){
|
if(not mProd){
|
||||||
mProd = std::shared_ptr<oType>( new SingleRange<size_t,SpaceType::NONE>(size) );
|
mProd = std::shared_ptr<oType>( new GenSingleRange<size_t,SpaceType::NONE,-1>(size) );
|
||||||
setSelf();
|
setSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> SingleRangeFactory<size_t,SpaceType::NONE>::create()
|
std::shared_ptr<RangeBase> GenSingleRangeFactory<size_t,SpaceType::NONE,-1>::create()
|
||||||
{
|
{
|
||||||
return mProd;
|
return mProd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
SingleRange<size_t,SpaceType::NONE>::SingleRange(size_t size) : mSize(size) {}
|
GenSingleRange<size_t,SpaceType::NONE,-1>::GenSingleRange(size_t size) : mSize(size) {}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NONE>::get(size_t pos) const
|
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::get(size_t pos) const
|
||||||
{
|
{
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NONE>::getMeta(size_t metaPos) const
|
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::getMeta(size_t metaPos) const
|
||||||
{
|
{
|
||||||
return metaPos;
|
return metaPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NONE>::size() const
|
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::size() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NONE>::dim() const
|
size_t GenSingleRange<size_t,SpaceType::NONE,-1>::dim() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpaceType SingleRange<size_t,SpaceType::NONE>::spaceType() const
|
SpaceType GenSingleRange<size_t,SpaceType::NONE,-1>::spaceType() const
|
||||||
{
|
{
|
||||||
return SpaceType::NONE;
|
return SpaceType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleRange<size_t,SpaceType::NONE>::stringMeta(size_t pos) const
|
std::string GenSingleRange<size_t,SpaceType::NONE,-1>::stringMeta(size_t pos) const
|
||||||
{
|
{
|
||||||
return std::to_string(get(pos));
|
return std::to_string(get(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> SingleRange<size_t,SpaceType::NONE>::data() const
|
std::vector<char> GenSingleRange<size_t,SpaceType::NONE,-1>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
std::vector<char> out;
|
||||||
|
@ -70,7 +70,7 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHeader SingleRange<size_t,SpaceType::NONE>::dataHeader() const
|
DataHeader GenSingleRange<size_t,SpaceType::NONE,-1>::dataHeader() const
|
||||||
{
|
{
|
||||||
DataHeader h;
|
DataHeader h;
|
||||||
h.spaceType = static_cast<int>( SpaceType::NONE );
|
h.spaceType = static_cast<int>( SpaceType::NONE );
|
||||||
|
@ -80,17 +80,17 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typename SingleRange<size_t,SpaceType::NONE>::IndexType SingleRange<size_t,SpaceType::NONE>::begin() const
|
typename GenSingleRange<size_t,SpaceType::NONE,-1>::IndexType GenSingleRange<size_t,SpaceType::NONE,-1>::begin() const
|
||||||
{
|
{
|
||||||
SingleIndex<size_t,SpaceType::NONE> i( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NONE> >
|
GenSingleIndex<size_t,SpaceType::NONE,-1> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NONE,-1> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = 0;
|
i = 0;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename SingleRange<size_t,SpaceType::NONE>::IndexType SingleRange<size_t,SpaceType::NONE>::end() const
|
typename GenSingleRange<size_t,SpaceType::NONE,-1>::IndexType GenSingleRange<size_t,SpaceType::NONE,-1>::end() const
|
||||||
{
|
{
|
||||||
SingleIndex<size_t,SpaceType::NONE> i( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NONE> >
|
GenSingleIndex<size_t,SpaceType::NONE,-1> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NONE,-1> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = size();
|
i = size();
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -10,11 +10,11 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
std::shared_ptr<SingleRange<size_t,SpaceType::NUL>>
|
std::shared_ptr<GenSingleRange<size_t,SpaceType::NUL,0>>
|
||||||
SingleRangeFactory<size_t,SpaceType::NUL>::mRInstance = nullptr;
|
GenSingleRangeFactory<size_t,SpaceType::NUL,0>::mRInstance = nullptr;
|
||||||
|
|
||||||
std::shared_ptr<NullRange> nullr()
|
std::shared_ptr<NullRange> nullr()
|
||||||
{
|
{
|
||||||
|
@ -28,12 +28,12 @@ namespace MultiArrayTools
|
||||||
return std::make_shared<NullIndex>(nullr());
|
return std::make_shared<NullIndex>(nullr());
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleRangeFactory<size_t,SpaceType::NUL>::SingleRangeFactory()
|
GenSingleRangeFactory<size_t,SpaceType::NUL,0>::GenSingleRangeFactory()
|
||||||
{
|
{
|
||||||
// Singleton
|
// Singleton
|
||||||
if(not mRInstance){
|
if(not mRInstance){
|
||||||
if(not mProd){
|
if(not mProd){
|
||||||
mProd = std::shared_ptr<oType>( new SingleRange<size_t,SpaceType::NUL>() );
|
mProd = std::shared_ptr<oType>( new GenSingleRange<size_t,SpaceType::NUL,0>() );
|
||||||
setSelf();
|
setSelf();
|
||||||
}
|
}
|
||||||
mRInstance = std::dynamic_pointer_cast<NullRange>( mProd );
|
mRInstance = std::dynamic_pointer_cast<NullRange>( mProd );
|
||||||
|
@ -42,46 +42,46 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> SingleRangeFactory<size_t,SpaceType::NUL>::create()
|
std::shared_ptr<RangeBase> GenSingleRangeFactory<size_t,SpaceType::NUL,0>::create()
|
||||||
{
|
{
|
||||||
return mProd;
|
return mProd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NUL>::get(size_t pos) const
|
size_t GenSingleRange<size_t,SpaceType::NUL,0>::get(size_t pos) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NUL>::getMeta(size_t metapos) const
|
size_t GenSingleRange<size_t,SpaceType::NUL,0>::getMeta(size_t metapos) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NUL>::size() const
|
size_t GenSingleRange<size_t,SpaceType::NUL,0>::size() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::NUL>::dim() const
|
size_t GenSingleRange<size_t,SpaceType::NUL,0>::dim() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpaceType SingleRange<size_t,SpaceType::NUL>::spaceType() const
|
SpaceType GenSingleRange<size_t,SpaceType::NUL,0>::spaceType() const
|
||||||
{
|
{
|
||||||
return SpaceType::NUL;
|
return SpaceType::NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleRange<size_t,SpaceType::NUL>::stringMeta(size_t pos) const
|
std::string GenSingleRange<size_t,SpaceType::NUL,0>::stringMeta(size_t pos) const
|
||||||
{
|
{
|
||||||
return std::to_string(get(pos));
|
return std::to_string(get(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> SingleRange<size_t,SpaceType::NUL>::data() const
|
std::vector<char> GenSingleRange<size_t,SpaceType::NUL,0>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
std::vector<char> out;
|
||||||
|
@ -91,7 +91,7 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHeader SingleRange<size_t,SpaceType::NUL>::dataHeader() const
|
DataHeader GenSingleRange<size_t,SpaceType::NUL,0>::dataHeader() const
|
||||||
{
|
{
|
||||||
DataHeader h;
|
DataHeader h;
|
||||||
h.spaceType = static_cast<int>( SpaceType::NUL );
|
h.spaceType = static_cast<int>( SpaceType::NUL );
|
||||||
|
@ -100,17 +100,17 @@ namespace MultiArrayTools
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename SingleRange<size_t,SpaceType::NUL>::IndexType SingleRange<size_t,SpaceType::NUL>::begin() const
|
typename GenSingleRange<size_t,SpaceType::NUL,0>::IndexType GenSingleRange<size_t,SpaceType::NUL,0>::begin() const
|
||||||
{
|
{
|
||||||
SingleIndex<size_t,SpaceType::NUL> i( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NUL> >
|
GenSingleIndex<size_t,SpaceType::NUL,0> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NUL,0> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = 0;
|
i = 0;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename SingleRange<size_t,SpaceType::NUL>::IndexType SingleRange<size_t,SpaceType::NUL>::end() const
|
typename GenSingleRange<size_t,SpaceType::NUL,0>::IndexType GenSingleRange<size_t,SpaceType::NUL,0>::end() const
|
||||||
{
|
{
|
||||||
SingleIndex<size_t,SpaceType::NUL> i( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NUL> >
|
GenSingleIndex<size_t,SpaceType::NUL,0> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NUL,0> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = size();
|
i = size();
|
||||||
return i;
|
return i;
|
||||||
|
@ -118,12 +118,12 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
// put this in the interface class !!!
|
// put this in the interface class !!!
|
||||||
/*
|
/*
|
||||||
std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::NUL>::index() const
|
std::shared_ptr<VIWB> GenSingleRange<size_t,SpaceType::NUL,0>::index() const
|
||||||
{
|
{
|
||||||
typedef IndexWrapper<IndexType> IW;
|
typedef IndexWrapper<IndexType> IW;
|
||||||
return std::make_shared<IW>
|
return std::make_shared<IW>
|
||||||
( std::make_shared<IndexType>
|
( std::make_shared<IndexType>
|
||||||
( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::NUL> >
|
( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::NUL,0> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,60 +11,60 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
SingleRangeFactory<int,SpaceType::PSPACE>::SingleRangeFactory(size_t size)
|
GenSingleRangeFactory<int,SpaceType::PSPACE,-1>::GenSingleRangeFactory(size_t size)
|
||||||
{
|
{
|
||||||
// Quasi Singleton
|
// Quasi Singleton
|
||||||
if(not mProd){
|
if(not mProd){
|
||||||
mProd = std::shared_ptr<oType>( new SingleRange<int,SpaceType::PSPACE>(size) );
|
mProd = std::shared_ptr<oType>( new GenSingleRange<int,SpaceType::PSPACE,-1>(size) );
|
||||||
setSelf();
|
setSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> SingleRangeFactory<int,SpaceType::PSPACE>::create()
|
std::shared_ptr<RangeBase> GenSingleRangeFactory<int,SpaceType::PSPACE,-1>::create()
|
||||||
{
|
{
|
||||||
return mProd;
|
return mProd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
SingleRange<int,SpaceType::PSPACE>::SingleRange(size_t size) : mSize(size) { }
|
GenSingleRange<int,SpaceType::PSPACE,-1>::GenSingleRange(size_t size) : mSize(size) { }
|
||||||
|
|
||||||
int SingleRange<int,SpaceType::PSPACE>::get(size_t pos) const
|
int GenSingleRange<int,SpaceType::PSPACE,-1>::get(size_t pos) const
|
||||||
{
|
{
|
||||||
return pos > mSize / 2 ? pos - mSize : pos;
|
return pos > mSize / 2 ? pos - mSize : pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<int,SpaceType::PSPACE>::getMeta(int metaPos) const
|
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::getMeta(int metaPos) const
|
||||||
{
|
{
|
||||||
return metaPos < 0 ? metaPos + mSize : metaPos;
|
return metaPos < 0 ? metaPos + mSize : metaPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<int,SpaceType::PSPACE>::size() const
|
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::size() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<int,SpaceType::PSPACE>::dim() const
|
size_t GenSingleRange<int,SpaceType::PSPACE,-1>::dim() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpaceType SingleRange<int,SpaceType::PSPACE>::spaceType() const
|
SpaceType GenSingleRange<int,SpaceType::PSPACE,-1>::spaceType() const
|
||||||
{
|
{
|
||||||
return SpaceType::PSPACE;
|
return SpaceType::PSPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleRange<int,SpaceType::PSPACE>::stringMeta(size_t pos) const
|
std::string GenSingleRange<int,SpaceType::PSPACE,-1>::stringMeta(size_t pos) const
|
||||||
{
|
{
|
||||||
return std::to_string(get(pos));
|
return std::to_string(get(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> SingleRange<int,SpaceType::PSPACE>::data() const
|
std::vector<char> GenSingleRange<int,SpaceType::PSPACE,-1>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
std::vector<char> out;
|
||||||
|
@ -76,7 +76,7 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHeader SingleRange<int,SpaceType::PSPACE>::dataHeader() const
|
DataHeader GenSingleRange<int,SpaceType::PSPACE,-1>::dataHeader() const
|
||||||
{
|
{
|
||||||
DataHeader h;
|
DataHeader h;
|
||||||
h.spaceType = static_cast<int>( SpaceType::PSPACE );
|
h.spaceType = static_cast<int>( SpaceType::PSPACE );
|
||||||
|
@ -85,17 +85,17 @@ namespace MultiArrayTools
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename SingleRange<int,SpaceType::PSPACE>::IndexType SingleRange<int,SpaceType::PSPACE>::begin() const
|
typename GenSingleRange<int,SpaceType::PSPACE,-1>::IndexType GenSingleRange<int,SpaceType::PSPACE,-1>::begin() const
|
||||||
{
|
{
|
||||||
SingleIndex<int,SpaceType::PSPACE> i( std::dynamic_pointer_cast<SingleRange<int,SpaceType::PSPACE> >
|
GenSingleIndex<int,SpaceType::PSPACE,-1> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,-1> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = 0;
|
i = 0;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename SingleRange<int,SpaceType::PSPACE>::IndexType SingleRange<int,SpaceType::PSPACE>::end() const
|
typename GenSingleRange<int,SpaceType::PSPACE,-1>::IndexType GenSingleRange<int,SpaceType::PSPACE,-1>::end() const
|
||||||
{
|
{
|
||||||
SingleIndex<int,SpaceType::PSPACE> i( std::dynamic_pointer_cast<SingleRange<int,SpaceType::PSPACE> >
|
GenSingleIndex<int,SpaceType::PSPACE,-1> i( std::dynamic_pointer_cast<GenSingleRange<int,SpaceType::PSPACE,-1> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = size();
|
i = size();
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -10,58 +10,58 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
SingleRangeFactory<size_t,SpaceType::SPIN>::SingleRangeFactory()
|
GenSingleRangeFactory<size_t,SpaceType::SPIN,4>::GenSingleRangeFactory()
|
||||||
{
|
{
|
||||||
// Quasi Singleton
|
// Quasi Singleton
|
||||||
if(not mProd){
|
if(not mProd){
|
||||||
mProd = std::shared_ptr<oType>( new SingleRange<size_t,SpaceType::SPIN>() );
|
mProd = std::shared_ptr<oType>( new GenSingleRange<size_t,SpaceType::SPIN,4>() );
|
||||||
setSelf();
|
setSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> SingleRangeFactory<size_t,SpaceType::SPIN>::create()
|
std::shared_ptr<RangeBase> GenSingleRangeFactory<size_t,SpaceType::SPIN,4>::create()
|
||||||
{
|
{
|
||||||
return mProd;
|
return mProd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* GenSingleRange *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::SPIN>::get(size_t pos) const
|
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::get(size_t pos) const
|
||||||
{
|
{
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::SPIN>::getMeta(size_t metaPos) const
|
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::getMeta(size_t metaPos) const
|
||||||
{
|
{
|
||||||
return metaPos;
|
return metaPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::SPIN>::size() const
|
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::size() const
|
||||||
{
|
{
|
||||||
return mSpinNum;
|
return mSpinNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SingleRange<size_t,SpaceType::SPIN>::dim() const
|
size_t GenSingleRange<size_t,SpaceType::SPIN,4>::dim() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpaceType SingleRange<size_t,SpaceType::SPIN>::spaceType() const
|
SpaceType GenSingleRange<size_t,SpaceType::SPIN,4>::spaceType() const
|
||||||
{
|
{
|
||||||
return SpaceType::SPIN;
|
return SpaceType::SPIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SingleRange<size_t,SpaceType::SPIN>::stringMeta(size_t pos) const
|
std::string GenSingleRange<size_t,SpaceType::SPIN,4>::stringMeta(size_t pos) const
|
||||||
{
|
{
|
||||||
return std::to_string(get(pos));
|
return std::to_string(get(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> SingleRange<size_t,SpaceType::SPIN>::data() const
|
std::vector<char> GenSingleRange<size_t,SpaceType::SPIN,4>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
std::vector<char> out;
|
||||||
|
@ -71,7 +71,7 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHeader SingleRange<size_t,SpaceType::SPIN>::dataHeader() const
|
DataHeader GenSingleRange<size_t,SpaceType::SPIN,4>::dataHeader() const
|
||||||
{
|
{
|
||||||
DataHeader h;
|
DataHeader h;
|
||||||
h.spaceType = static_cast<int>( SpaceType::SPIN );
|
h.spaceType = static_cast<int>( SpaceType::SPIN );
|
||||||
|
@ -80,17 +80,17 @@ namespace MultiArrayTools
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename SingleRange<size_t,SpaceType::SPIN>::IndexType SingleRange<size_t,SpaceType::SPIN>::begin() const
|
typename GenSingleRange<size_t,SpaceType::SPIN,4>::IndexType GenSingleRange<size_t,SpaceType::SPIN,4>::begin() const
|
||||||
{
|
{
|
||||||
SingleIndex<size_t,SpaceType::SPIN> i( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::SPIN> >
|
GenSingleIndex<size_t,SpaceType::SPIN,4> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::SPIN,4> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = 0;
|
i = 0;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename SingleRange<size_t,SpaceType::SPIN>::IndexType SingleRange<size_t,SpaceType::SPIN>::end() const
|
typename GenSingleRange<size_t,SpaceType::SPIN,4>::IndexType GenSingleRange<size_t,SpaceType::SPIN,4>::end() const
|
||||||
{
|
{
|
||||||
SingleIndex<size_t,SpaceType::SPIN> i( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::SPIN> >
|
GenSingleIndex<size_t,SpaceType::SPIN,4> i( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::SPIN,4> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) );
|
||||||
i = size();
|
i = size();
|
||||||
return i;
|
return i;
|
||||||
|
@ -98,12 +98,12 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
// put this in the interface class !!!
|
// put this in the interface class !!!
|
||||||
/*
|
/*
|
||||||
std::shared_ptr<VIWB> SingleRange<size_t,SpaceType::SPIN>::index() const
|
std::shared_ptr<VIWB> GenSingleRange<size_t,SpaceType::SPIN,4>::index() const
|
||||||
{
|
{
|
||||||
typedef IndexWrapper<IndexType> IW;
|
typedef IndexWrapper<IndexType> IW;
|
||||||
return std::make_shared<IW>
|
return std::make_shared<IW>
|
||||||
( std::make_shared<IndexType>
|
( std::make_shared<IndexType>
|
||||||
( std::dynamic_pointer_cast<SingleRange<size_t,SpaceType::SPIN> >
|
( std::dynamic_pointer_cast<GenSingleRange<size_t,SpaceType::SPIN,4> >
|
||||||
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
|
( std::shared_ptr<RangeBase>( RB::mThis ) ) ) );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -134,13 +134,14 @@ namespace {
|
||||||
typedef MultiRangeFactory<SR,SR,SR,SR,SR,SR,SR,SR> SR8F;
|
typedef MultiRangeFactory<SR,SR,SR,SR,SR,SR,SR,SR> SR8F;
|
||||||
typedef SR8F::oType SR8;
|
typedef SR8F::oType SR8;
|
||||||
|
|
||||||
static const size_t os = 3000;
|
static const size_t os = 30;
|
||||||
static const size_t s = 65536*os;
|
static const size_t is = 65536;
|
||||||
|
static const size_t s = is*os;
|
||||||
|
|
||||||
OpTest_Spin()
|
OpTest_Spin()
|
||||||
{
|
{
|
||||||
data.resize(s);
|
data.resize(is);
|
||||||
for(size_t i = 0; i != s; ++i){
|
for(size_t i = 0; i != is; ++i){
|
||||||
double arg = static_cast<double>( i - s ) - 0.1;
|
double arg = static_cast<double>( i - s ) - 0.1;
|
||||||
data[i] = sin(arg);
|
data[i] = sin(arg);
|
||||||
//VCHECK(data[i]);
|
//VCHECK(data[i]);
|
||||||
|
@ -162,7 +163,7 @@ namespace {
|
||||||
|
|
||||||
void OpTest_Spin::contract()
|
void OpTest_Spin::contract()
|
||||||
{
|
{
|
||||||
MultiArray<double,CR,SR,SR,SR,SR,SR,SR,SR,SR> ma( cr, sr, sr, sr, sr, sr, sr, sr, sr, data);
|
MultiArray<double,SR,SR,SR,SR,SR,SR,SR,SR> ma( sr, sr, sr, sr, sr, sr, sr, sr, data);
|
||||||
MultiArray<double,CR,SR,SR> res1( cr, sr, sr );
|
MultiArray<double,CR,SR,SR> res1( cr, sr, sr );
|
||||||
|
|
||||||
auto ii = MAT::getIndex<CR>(cr);
|
auto ii = MAT::getIndex<CR>(cr);
|
||||||
|
@ -177,7 +178,8 @@ namespace {
|
||||||
|
|
||||||
std::clock_t begin = std::clock();
|
std::clock_t begin = std::clock();
|
||||||
//for(size_t i = 0; i != os; ++i){
|
//for(size_t i = 0; i != os; ++i){
|
||||||
res1(ii ,delta, deltap).par() += ma(ii, delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
|
//res1(ii ,delta, deltap).par() += ma(ii, delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
|
||||||
|
res1(ii ,delta, deltap) += ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
|
||||||
//}
|
//}
|
||||||
std::clock_t end = std::clock();
|
std::clock_t end = std::clock();
|
||||||
std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC
|
std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC
|
||||||
|
@ -199,7 +201,7 @@ namespace {
|
||||||
for(size_t d = 0; d != 4; ++d){
|
for(size_t d = 0; d != 4; ++d){
|
||||||
for(size_t p = 0; p != 4; ++p){
|
for(size_t p = 0; p != 4; ++p){
|
||||||
const size_t tidx = i*4*4 + d*4 + p;
|
const size_t tidx = i*4*4 + d*4 + p;
|
||||||
const size_t sidx = i*65536 + d*4*4*4*4*4*4*4 + a*5*4*4*4*4*4 + b*5*4*4*4 + c*5*4 + p;
|
const size_t sidx = /*i*65536 +*/ d*4*4*4*4*4*4*4 + a*5*4*4*4*4*4 + b*5*4*4*4 + c*5*4 + p;
|
||||||
vres[tidx] += data[sidx];
|
vres[tidx] += data[sidx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue