Merge branch 'dev' into merge
This commit is contained in:
commit
b0063bb9e2
52 changed files with 1207 additions and 652 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 -g -Wpedantic -Ofast -march=native -funroll-loops -fopenmp")
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
|
|
74
src/include/allocator.h
Normal file
74
src/include/allocator.h
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
|
||||||
|
#ifndef __ma_allocator__
|
||||||
|
#define __ma_allocator__
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <new>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace MultiArrayHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct Allocator
|
||||||
|
{
|
||||||
|
typedef T value_type;
|
||||||
|
static constexpr size_t type_size = sizeof(value_type);
|
||||||
|
static constexpr size_t N = 32;
|
||||||
|
|
||||||
|
Allocator() = default;
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
Allocator(const Allocator<U>& x) {}
|
||||||
|
|
||||||
|
T* allocate(size_t n)
|
||||||
|
{
|
||||||
|
//constexpr size_t NN = N*type_size;
|
||||||
|
const size_t nn = n*type_size;
|
||||||
|
if(n > static_cast<size_t>(-1-N)) throw std::bad_alloc();
|
||||||
|
auto p = static_cast<char*>(std::malloc(nn + N));
|
||||||
|
if(not p) throw std::bad_alloc();
|
||||||
|
auto ip = reinterpret_cast<std::intptr_t>(p);
|
||||||
|
auto diff = N - (ip % N);
|
||||||
|
p += diff;
|
||||||
|
//auto ipx = reinterpret_cast<std::intptr_t>(p);
|
||||||
|
//std::cout << "ixp: " << ipx << std::endl;
|
||||||
|
//std::cout << "ixp %: " << ipx % N << std::endl;
|
||||||
|
auto ps = reinterpret_cast<std::intptr_t*>(p);
|
||||||
|
ps[-1] = diff;
|
||||||
|
return reinterpret_cast<T*>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocate(T* p, size_t n)
|
||||||
|
{
|
||||||
|
auto ps = reinterpret_cast<std::intptr_t*>(p);
|
||||||
|
std::free(reinterpret_cast<char*>(p)-ps[-1]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator==(const Allocator<T>& a, const Allocator<U>& b)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator!=(const Allocator<T>& a, const Allocator<U>& b)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace MultiArrayHelper
|
||||||
|
|
||||||
|
namespace MultiArrayTools
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
using vector = std::vector<T,MultiArrayHelper::Allocator<T>>;
|
||||||
|
|
||||||
|
} // namespace MultiArrayTools
|
||||||
|
|
||||||
|
#endif
|
62
src/include/allocator.h~
Normal file
62
src/include/allocator.h~
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
#ifndef __ma_allocator__
|
||||||
|
#define __ma_allocator__
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <new>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace MultiArrayHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T, size_t N>
|
||||||
|
struct Allocator
|
||||||
|
{
|
||||||
|
typedef T value_type;
|
||||||
|
static constexpr type_size = sizeof(value_type);
|
||||||
|
|
||||||
|
Allocator() = default;
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
Allocator(const Allocator<U>& x) {}
|
||||||
|
|
||||||
|
T* allocate(size_t n)
|
||||||
|
{
|
||||||
|
//constexpr size_t NN = N*type_size;
|
||||||
|
const size_t nn = n*type_size;
|
||||||
|
if(n > static_cast<size_t>(-1-NN)) throw std::bad_alloc();
|
||||||
|
auto p = static_cast<char*>(std::malloc(nn + N));
|
||||||
|
if(not p) throw std::bad_alloc();
|
||||||
|
auto ip = static_cast<std::intptr_t>(p);
|
||||||
|
mDiff = N - (ip % N);
|
||||||
|
p += mDiff;
|
||||||
|
return static_cast<T*>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void deacllocate(T* p, size_t n)
|
||||||
|
{
|
||||||
|
std::free(p-mDiff);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::intptr_t mDiff;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator==(const Allocator<T>& a, const Allocator<T>& b)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator!=(const Allocator<T>& a, const Allocator<T>& b)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using vector = vector<T,Allocator>;
|
||||||
|
|
||||||
|
} // namespace MultiArrayHelper
|
||||||
|
|
||||||
|
#endif
|
122
src/include/conversions.h
Normal file
122
src/include/conversions.h
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
|
||||||
|
#ifndef __ma_conversions_h__
|
||||||
|
#define __ma_conversions_h__
|
||||||
|
|
||||||
|
#include "multi_array.h"
|
||||||
|
#include "slice.h"
|
||||||
|
|
||||||
|
namespace MultiArrayTools
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace ConversionSizes
|
||||||
|
{
|
||||||
|
template <size_t N>
|
||||||
|
struct OrigSize
|
||||||
|
{
|
||||||
|
template <typename C, typename T>
|
||||||
|
struct FromTo
|
||||||
|
{
|
||||||
|
static void check() { static_assert( not N % (sizeof(T) / sizeof(C)), "conversion does not fit" ); }
|
||||||
|
static constexpr size_t SIZE = N * sizeof(T) / sizeof(C);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct OrigSize<-1>
|
||||||
|
{
|
||||||
|
template <typename C, typename T>
|
||||||
|
struct FromTo
|
||||||
|
{
|
||||||
|
static void check() {}
|
||||||
|
static constexpr size_t SIZE = -1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
template <typename C, typename T, size_t N>
|
||||||
|
using SC = typename ConversionSizes::OrigSize<N>::template FromTo<C,T>;
|
||||||
|
|
||||||
|
template <typename C, typename T, class Range>
|
||||||
|
using SCR = SC<C,T,Range::SIZE>;
|
||||||
|
|
||||||
|
template <typename C, typename T, class Range>
|
||||||
|
using SCRR = GenSingleRange<typename Range::MetaType,SpaceType::NONE,SCR<C,T,Range>::SIZE>;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <size_t N>
|
||||||
|
struct SubTuple
|
||||||
|
{
|
||||||
|
template <class RTP, class... Ranges>
|
||||||
|
static inline auto mk(const RTP& rtp, const Ranges&... rs)
|
||||||
|
-> decltype(SubTuple<N-1>::mk(rtp, std::get<N>(rtp), rs...))
|
||||||
|
{
|
||||||
|
return SubTuple<N-1>::mk(rtp, std::get<N>(rtp), rs...);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct SubTuple<0>
|
||||||
|
{
|
||||||
|
template <class RTP, class... Ranges>
|
||||||
|
static inline auto mk(const RTP& rtp, const Ranges&... rs)
|
||||||
|
-> decltype(std::make_tuple(std::get<0>(rtp), rs...))
|
||||||
|
{
|
||||||
|
return std::make_tuple(std::get<0>(rtp), rs...);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class... Ranges>
|
||||||
|
using LastR = typename std::tuple_element<sizeof...(Ranges)-1,std::tuple<Ranges...>>::type;
|
||||||
|
|
||||||
|
template <typename C, typename T, class... Ranges>
|
||||||
|
auto rtcast(const std::tuple<std::shared_ptr<Ranges>...>& rtp)
|
||||||
|
-> decltype(std::tuple_cat(SubTuple<sizeof...(Ranges)-2>::mk(rtp),
|
||||||
|
std::make_tuple( std::dynamic_pointer_cast<SCRR<C,T,LastR<Ranges...>>>
|
||||||
|
( SCRR<C,T,LastR<Ranges...>>::factory().create() ) ) ))
|
||||||
|
{
|
||||||
|
return std::tuple_cat(SubTuple<sizeof...(Ranges)-2>::mk(rtp),
|
||||||
|
std::make_tuple( std::dynamic_pointer_cast<SCRR<C,T,LastR<Ranges...>>>
|
||||||
|
( SCRR<C,T,LastR<Ranges...>>::factory().create() ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
inline Slice<T,Ranges...> rangeTpToSlice( const std::tuple<std::shared_ptr<Ranges>...>& rtp, T* data )
|
||||||
|
{
|
||||||
|
return Slice<T,Ranges...>(rtp, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
inline ConstSlice<T,Ranges...> rangeTpToSlice( const std::tuple<std::shared_ptr<Ranges>...>& rtp, const T* data )
|
||||||
|
{
|
||||||
|
return ConstSlice<T,Ranges...>(rtp, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename C, typename T, class... Ranges>
|
||||||
|
auto tcast(MultiArray<T,Ranges...>& ma)
|
||||||
|
-> decltype(rangeTpToSlice
|
||||||
|
( rtcast<C,T>( ma.range()->space() ),
|
||||||
|
reinterpret_cast<C*>( ma.data() ) ))
|
||||||
|
{
|
||||||
|
// VCHECK(reinterpret_cast<std::intptr_t>(ma.data()) % 32);
|
||||||
|
//VCHECK(reinterpret_cast<std::intptr_t>(reinterpret_cast<C*>(ma.data())) % 32);
|
||||||
|
return rangeTpToSlice
|
||||||
|
( rtcast<C,T>( ma.range()->space() ),
|
||||||
|
reinterpret_cast<C*>( ma.data() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename C, typename T, class... Ranges>
|
||||||
|
auto tcast(const MultiArray<T,Ranges...>& ma)
|
||||||
|
-> decltype(rangeTpToSlice
|
||||||
|
( rtcast<C,T>( ma.range()->space() ),
|
||||||
|
reinterpret_cast<const C*>( ma.data() ) ))
|
||||||
|
{
|
||||||
|
//VCHECK(reinterpret_cast<std::intptr_t>(ma.data()) % 32);
|
||||||
|
//VCHECK(reinterpret_cast<std::intptr_t>(reinterpret_cast<C*>(ma.data())) % 32);
|
||||||
|
return rangeTpToSlice
|
||||||
|
( rtcast<C,T>( ma.range()->space() ),
|
||||||
|
reinterpret_cast<const C*>( ma.data() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -15,7 +15,7 @@ namespace MultiArrayTools
|
||||||
static auto mk(const std::shared_ptr<Index>& i)
|
static auto mk(const std::shared_ptr<Index>& i)
|
||||||
-> MultiArray<typename Index::MetaType, typename Index::RangeType>
|
-> MultiArray<typename Index::MetaType, typename Index::RangeType>
|
||||||
{
|
{
|
||||||
std::vector<typename Index::MetaType> vv(i->range()->size());
|
vector<typename Index::MetaType> vv(i->range()->size());
|
||||||
for(Index j = (*i); j.pos() != j.max(); ++j){
|
for(Index j = (*i); j.pos() != j.max(); ++j){
|
||||||
vv[j.pos()] = j.meta();
|
vv[j.pos()] = j.meta();
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
auto createRange(const std::vector<char>& cvec)
|
auto createRange(const vector<char>& cvec)
|
||||||
-> std::shared_ptr<Range>
|
-> std::shared_ptr<Range>
|
||||||
{
|
{
|
||||||
const char* dp = cvec.data();
|
const char* dp = cvec.data();
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace MultiArrayTools
|
||||||
-> std::shared_ptr<typename RangeFactory::oType>;
|
-> std::shared_ptr<typename RangeFactory::oType>;
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
auto createRange(const std::vector<char>& cvec)
|
auto createRange(const vector<char>& cvec)
|
||||||
-> std::shared_ptr<Range>;
|
-> std::shared_ptr<Range>;
|
||||||
|
|
||||||
template <size_t N, class MArray>
|
template <size_t N, class MArray>
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||||
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast,
|
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast,
|
||||||
ExtType last) const
|
ExtType last)
|
||||||
{
|
{
|
||||||
constexpr size_t NEXT = Op::SIZE;
|
constexpr size_t NEXT = Op::SIZE;
|
||||||
const ExtType nxpos = last;
|
const ExtType nxpos = last;
|
||||||
|
@ -42,7 +42,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
template <class MapF, class IndexPack, class Expr, SpaceType STYPE>
|
||||||
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast) const
|
inline void OpExpr<MapF,IndexPack,Expr,STYPE>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
const ExtType last;
|
const ExtType last;
|
||||||
constexpr size_t NEXT = Op::SIZE;
|
constexpr size_t NEXT = Op::SIZE;
|
||||||
|
@ -347,7 +347,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(not check){
|
if(not check){
|
||||||
std::vector<std::intptr_t> pv(sizeof...(Ranges));
|
vector<std::intptr_t> pv(sizeof...(Ranges));
|
||||||
RPackNum<sizeof...(Ranges)-1>::RangesToVec(ptp, pv);
|
RPackNum<sizeof...(Ranges)-1>::RangesToVec(ptp, pv);
|
||||||
pv.push_back( reinterpret_cast<std::intptr_t>
|
pv.push_back( reinterpret_cast<std::intptr_t>
|
||||||
( &std::dynamic_pointer_cast<oType>( mProd )->mMapf ) );
|
( &std::dynamic_pointer_cast<oType>( mProd )->mMapf ) );
|
||||||
|
@ -376,8 +376,8 @@ namespace MultiArrayTools
|
||||||
mult[mapf[ii]]++;
|
mult[mapf[ii]]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<typename MapF::value_type> outmeta(mult.size());
|
vector<typename MapF::value_type> outmeta(mult.size());
|
||||||
std::vector<size_t> outmult(mult.size());
|
vector<size_t> outmult(mult.size());
|
||||||
|
|
||||||
size_t cnt = 0;
|
size_t cnt = 0;
|
||||||
for(auto& x: mult){
|
for(auto& x: mult){
|
||||||
|
@ -404,12 +404,12 @@ namespace MultiArrayTools
|
||||||
for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) {
|
for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) {
|
||||||
max = mapf[ii]+1 > max ? mapf[ii]+1 : max;
|
max = mapf[ii]+1 > max ? mapf[ii]+1 : max;
|
||||||
}
|
}
|
||||||
std::vector<size_t> mult(max,0);
|
vector<size_t> mult(max,0);
|
||||||
for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) {
|
for(auto ii = mapf.begin(); ii.max() != ii.pos(); ++ii) {
|
||||||
mult[mapf[ii]]++;
|
mult[mapf[ii]]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<size_t> outmult(mult.size());
|
vector<size_t> outmult(mult.size());
|
||||||
|
|
||||||
size_t cnt = 0;
|
size_t cnt = 0;
|
||||||
for(auto& x: mult){
|
for(auto& x: mult){
|
||||||
|
@ -505,10 +505,10 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
template <class MapF, SpaceType XSTYPE, class... Ranges>
|
||||||
std::vector<char> GenMapRange<MapF,XSTYPE,Ranges...>::data() const
|
vector<char> GenMapRange<MapF,XSTYPE,Ranges...>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
//out.reserve(h.metaSize + sizeof(DataHeader));
|
//out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
|
|
|
@ -66,8 +66,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
OpExpr(const MapF& mapf, const IndexPack& ipack, const std::shared_ptr<OIType>& oind, size_t step, Expr ex);
|
OpExpr(const MapF& mapf, const IndexPack& ipack, const std::shared_ptr<OIType>& oind, size_t step, Expr ex);
|
||||||
|
|
||||||
inline void operator()(size_t mlast, ExtType last) const;
|
inline void operator()(size_t mlast, ExtType last);
|
||||||
inline void operator()(size_t mlast = 0) const;
|
inline void operator()(size_t mlast = 0);
|
||||||
|
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
const Space& space() const;
|
const Space& space() const;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace MultiArrayTools
|
||||||
friend class GenMapRangeFactory;
|
friend class GenMapRangeFactory;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > mAleadyCreated;
|
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define __mbase_def_h__
|
#define __mbase_def_h__
|
||||||
|
|
||||||
#include "ranges/rbase_def.h"
|
#include "ranges/rbase_def.h"
|
||||||
|
#include "allocator.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace MultiArrayTools
|
||||||
Scalar<T> scalar(const T& in)
|
Scalar<T> scalar(const T& in)
|
||||||
{
|
{
|
||||||
NullRF nrf;
|
NullRF nrf;
|
||||||
return Scalar<T>( std::dynamic_pointer_cast<NullRange>( nrf.create() ), std::vector<T>( { in } ) );
|
return Scalar<T>( std::dynamic_pointer_cast<NullRange>( nrf.create() ), vector<T>( { in } ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
|
@ -24,7 +24,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <typename T, class... SRanges>
|
template <typename T, class... SRanges>
|
||||||
MultiArray<T,SRanges...>::MultiArray(const typename CRange::Space& space,
|
MultiArray<T,SRanges...>::MultiArray(const typename CRange::Space& space,
|
||||||
std::vector<T>&& vec) :
|
vector<T>&& vec) :
|
||||||
MutableMultiArrayBase<T,SRanges...>(space),
|
MutableMultiArrayBase<T,SRanges...>(space),
|
||||||
mCont(vec)
|
mCont(vec)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... SRanges>
|
template <typename T, class... SRanges>
|
||||||
MultiArray<T,SRanges...>::MultiArray(const std::shared_ptr<SRanges>&... ranges, const std::vector<T>& vec) :
|
MultiArray<T,SRanges...>::MultiArray(const std::shared_ptr<SRanges>&... ranges, const vector<T>& vec) :
|
||||||
MutableMultiArrayBase<T,SRanges...>(ranges...),
|
MutableMultiArrayBase<T,SRanges...>(ranges...),
|
||||||
mCont(vec)
|
mCont(vec)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... SRanges>
|
template <typename T, class... SRanges>
|
||||||
MultiArray<T,SRanges...>::MultiArray(const std::shared_ptr<SRanges>&... ranges, std::vector<T>&& vec) :
|
MultiArray<T,SRanges...>::MultiArray(const std::shared_ptr<SRanges>&... ranges, vector<T>&& vec) :
|
||||||
MutableMultiArrayBase<T,SRanges...>(ranges...),
|
MutableMultiArrayBase<T,SRanges...>(ranges...),
|
||||||
mCont(vec)
|
mCont(vec)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T, class... SRanges>
|
template <typename T, class... SRanges>
|
||||||
class MultiArray : public MutableMultiArrayBase<T,SRanges...>
|
class MultiArray : public MutableMultiArrayBase<T,SRanges...>
|
||||||
{
|
{
|
||||||
|
@ -41,15 +40,15 @@ namespace MultiArrayTools
|
||||||
DEFAULT_MEMBERS(MultiArray);
|
DEFAULT_MEMBERS(MultiArray);
|
||||||
MultiArray(const std::shared_ptr<SRanges>&... ranges);
|
MultiArray(const std::shared_ptr<SRanges>&... ranges);
|
||||||
MultiArray(const std::shared_ptr<SRanges>&... ranges, const T& val);
|
MultiArray(const std::shared_ptr<SRanges>&... ranges, const T& val);
|
||||||
MultiArray(const std::shared_ptr<SRanges>&... ranges, const std::vector<T>& vec);
|
MultiArray(const std::shared_ptr<SRanges>&... ranges, const vector<T>& vec);
|
||||||
MultiArray(const std::shared_ptr<SRanges>&... ranges, std::vector<T>&& vec);
|
MultiArray(const std::shared_ptr<SRanges>&... ranges, vector<T>&& vec);
|
||||||
MultiArray(const typename CRange::Space& space);
|
MultiArray(const typename CRange::Space& space);
|
||||||
MultiArray(const typename CRange::Space& space, std::vector<T>&& vec);
|
MultiArray(const typename CRange::Space& space, vector<T>&& vec);
|
||||||
MultiArray(MultiArray<T,AnonymousRange>&& ama, SIZET<SRanges>... sizes);
|
MultiArray(MultiArray<T,AnonymousRange>&& ama, SIZET<SRanges>... sizes);
|
||||||
|
|
||||||
// Only if ALL ranges have default extensions:
|
// Only if ALL ranges have default extensions:
|
||||||
//MultiArray(const std::vector<T>& vec);
|
//MultiArray(const vector<T>& vec);
|
||||||
//MultiArray(std::vector<T>&& vec);
|
//MultiArray(vector<T>&& vec);
|
||||||
|
|
||||||
// template <class Range2, class Range3>
|
// template <class Range2, class Range3>
|
||||||
// MultiArray(const MultiArray<MultiArray<T,Range2>,Range3> in);
|
// MultiArray(const MultiArray<MultiArray<T,Range2>,Range3> in);
|
||||||
|
@ -76,8 +75,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
virtual const T* data() const override;
|
virtual const T* data() const override;
|
||||||
virtual T* data() override;
|
virtual T* data() override;
|
||||||
virtual std::vector<T>& vdata() { return mCont; }
|
virtual vector<T>& vdata() { return mCont; }
|
||||||
virtual const std::vector<T>& vdata() const { return mCont; }
|
virtual const vector<T>& vdata() const { return mCont; }
|
||||||
|
|
||||||
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
|
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymous(bool slice = false) const override;
|
||||||
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymousMove() override;
|
virtual std::shared_ptr<MultiArrayBase<T,AnonymousRange> > anonymousMove() override;
|
||||||
|
@ -99,7 +98,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<T> mCont;
|
vector<T> mCont;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -119,7 +118,7 @@ namespace MultiArrayTools
|
||||||
const size_t smas = sma.size();
|
const size_t smas = sma.size();
|
||||||
const size_t mas = ma.size();
|
const size_t mas = ma.size();
|
||||||
auto cr = ma.range()->cat(sma.range());
|
auto cr = ma.range()->cat(sma.range());
|
||||||
std::vector<T> ov;
|
vector<T> ov;
|
||||||
ov.reserve(mas * smas);
|
ov.reserve(mas * smas);
|
||||||
|
|
||||||
for(auto& x: ma){
|
for(auto& x: ma){
|
||||||
|
|
|
@ -120,18 +120,25 @@ namespace MultiArrayTools
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* OperationMaster::AssignmentExpr *
|
* OperationMaster::AssignmentExpr *
|
||||||
*****************************************/
|
*****************************************/
|
||||||
|
/*
|
||||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
||||||
AssignmentExpr(OperationMaster& m, const OpClass& sec) :
|
AssignmentExpr(OperationMaster& m, const OpClass& sec) :
|
||||||
mM(m), mSec(sec) {}
|
mM(m), mSec(sec) {}
|
||||||
|
*/
|
||||||
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
|
OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
||||||
|
AssignmentExpr(T* dataPtr, const OpClass& sec) :
|
||||||
|
mSec(sec), mDataPtr(dataPtr) {}
|
||||||
|
|
||||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
inline void OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
inline void OperationMaster<T,AOp,OpClass,Ranges...>::AssignmentExpr::
|
||||||
operator()(size_t start, ExtType last) const
|
operator()(size_t start, ExtType last)
|
||||||
{
|
{
|
||||||
//VCHECK(mSec.template get<ExtType>(last));
|
//VCHECK(mSec.template get<ExtType>(last));
|
||||||
mM.set(start, mSec.template get<ExtType>(last) );
|
//mM.set(start, mSec.template get<ExtType>(last) );
|
||||||
|
mDataPtr[start] = mSec.template get<ExtType>(last);
|
||||||
|
//AOp::sapply(mDataPtr[start], mSec.template get<ExtType>(last));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
|
@ -142,6 +149,29 @@ namespace MultiArrayTools
|
||||||
return mSec.rootSteps(iPtrNum);
|
return mSec.rootSteps(iPtrNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
|
OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::
|
||||||
|
AddExpr(T* dataPtr, const OpClass& sec) :
|
||||||
|
mSec(sec), mDataPtr(dataPtr) {}
|
||||||
|
|
||||||
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
|
inline void OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::
|
||||||
|
operator()(size_t start, ExtType last)
|
||||||
|
{
|
||||||
|
//VCHECK(mSec.template get<ExtType>(last));
|
||||||
|
//mM.set(start, mSec.template get<ExtType>(last) );
|
||||||
|
mDataPtr[start] += mSec.template get<ExtType>(last);
|
||||||
|
//AOp::sapply(mDataPtr[start], mSec.template get<ExtType>(last));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
|
typename OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::ExtType
|
||||||
|
OperationMaster<T,AOp,OpClass,Ranges...>::AddExpr::
|
||||||
|
rootSteps(std::intptr_t iPtrNum) const
|
||||||
|
{
|
||||||
|
return mSec.rootSteps(iPtrNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
* OperationMaster *
|
* OperationMaster *
|
||||||
|
@ -170,15 +200,17 @@ namespace MultiArrayTools
|
||||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
void OperationMaster<T,AOp,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum)
|
void OperationMaster<T,AOp,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
AssignmentExpr ae(*this, mSecond); // Expression to be executed within loop
|
AssignmentExpr ae(*this, mSecond); // Expression to be executed within loop
|
||||||
if(mDoParallel){
|
if(mDoParallel){
|
||||||
const auto ploop = mIndex.pifor( 1, mSecond.loop(ae) );
|
auto ploop = mIndex.pifor( 1, mSecond.loop(ae) );
|
||||||
ploop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
ploop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const auto loop = mIndex.ifor( 1, mSecond.loop(ae) );
|
auto loop = mIndex.ifor( 1, mSecond.loop(ae) );
|
||||||
loop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
loop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class AOp, class OpClass, class... Ranges>
|
template <typename T, class AOp, class OpClass, class... Ranges>
|
||||||
|
@ -197,11 +229,12 @@ namespace MultiArrayTools
|
||||||
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||||
mDataPtr(ma.data()),
|
mDataPtr(ma.data()),
|
||||||
|
mOrigDataPtr(ma.data()),
|
||||||
mIndex( ma.begin() )
|
mIndex( ma.begin() )
|
||||||
{
|
{
|
||||||
//VCHECK(ma.data());
|
//VCHECK(ma.data());
|
||||||
mIndex(indices...);
|
mIndex(indices...);
|
||||||
mOff = mIndex.pos();
|
//mOff = mIndex.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
@ -209,35 +242,37 @@ namespace MultiArrayTools
|
||||||
ConstOperationRoot(std::shared_ptr<MultiArrayBase<T,Ranges...> > maptr,
|
ConstOperationRoot(std::shared_ptr<MultiArrayBase<T,Ranges...> > maptr,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||||
mDataPtr(maptr->data()),
|
mDataPtr(maptr->data()),
|
||||||
|
mOrigDataPtr(maptr->data()),
|
||||||
mIndex(maptr->begin()),
|
mIndex(maptr->begin()),
|
||||||
mMaPtr(maptr)
|
mMaPtr(maptr)
|
||||||
{
|
{
|
||||||
mIndex(indices...);
|
mIndex(indices...);
|
||||||
mOff = mIndex.pos();
|
//mOff = mIndex.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
ConstOperationRoot<T,Ranges...>::
|
ConstOperationRoot<T,Ranges...>::
|
||||||
ConstOperationRoot(const T* data, const IndexType& ind) :
|
ConstOperationRoot(const T* data, const IndexType& ind) :
|
||||||
mDataPtr(data),
|
mDataPtr(data),
|
||||||
|
mOrigDataPtr(data),
|
||||||
mIndex( ind )
|
mIndex( ind )
|
||||||
{
|
{
|
||||||
mOff = mIndex.pos();
|
//mOff = mIndex.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T ConstOperationRoot<T,Ranges...>::get(ET pos) const
|
inline const T& ConstOperationRoot<T,Ranges...>::get(ET pos) const
|
||||||
{
|
{
|
||||||
return mDataPtr[pos.val()+mOff];
|
return mDataPtr[pos.val()/*+mOff*/];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::set(ET pos) const
|
inline ConstOperationRoot<T,Ranges...>& ConstOperationRoot<T,Ranges...>::set(ET pos)
|
||||||
{
|
{
|
||||||
mIndex = pos.val();
|
mIndex = pos.val();
|
||||||
mOff = mIndex.pos();
|
mDataPtr = mOrigDataPtr + mIndex.pos();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +313,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <typename T, class Op>
|
template <typename T, class Op>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const StaticCast<T,Op>& StaticCast<T,Op>::set(ET pos) const
|
inline StaticCast<T,Op>& StaticCast<T,Op>::set(ET pos)
|
||||||
{
|
{
|
||||||
mOp.set(pos);
|
mOp.set(pos);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -322,7 +357,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const MetaOperationRoot<Range>& MetaOperationRoot<Range>::set(ET pos) const
|
inline MetaOperationRoot<Range>& MetaOperationRoot<Range>::set(ET pos)
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
//(*mIndex) = pos.val();
|
//(*mIndex) = pos.val();
|
||||||
|
@ -353,38 +388,65 @@ namespace MultiArrayTools
|
||||||
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||||
mDataPtr(ma.data()),
|
mDataPtr(ma.data()),
|
||||||
|
mOrigDataPtr(ma.data()),
|
||||||
mIndex( ma.begin() )
|
mIndex( ma.begin() )
|
||||||
{
|
{
|
||||||
mIndex(indices...);
|
mIndex(indices...);
|
||||||
mOff = mIndex.pos();
|
//mOff = mIndex.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
OperationRoot<T,Ranges...>::
|
OperationRoot<T,Ranges...>::
|
||||||
OperationRoot(T* data, const IndexType& ind) :
|
OperationRoot(T* data, const IndexType& ind) :
|
||||||
mDataPtr(data),
|
mDataPtr(data),
|
||||||
|
mOrigDataPtr(data),
|
||||||
mIndex( ind )
|
mIndex( ind )
|
||||||
{
|
{
|
||||||
mOff = mIndex.pos();
|
//mOff = mIndex.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||||
|
//OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||||
{
|
{
|
||||||
return OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
typename OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...>::AssignmentExpr ae(mDataPtr, in);
|
||||||
|
// Expression to be executed within loop
|
||||||
|
if(mDoParallel){
|
||||||
|
auto ploop = mIndex.pifor( 1, in.loop(ae) );
|
||||||
|
ploop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto loop = mIndex.ifor( 1, in.loop(ae) );
|
||||||
|
loop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
//return OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationMaster<T,plus<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
||||||
|
//OperationMaster<T,plus<T>,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator+=(const OpClass& in)
|
||||||
{
|
{
|
||||||
return OperationMaster<T,plus<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
typename OperationMaster<T,plus<T>,OpClass,Ranges...>::AddExpr ae(mDataPtr, in);
|
||||||
|
// Expression to be executed within loop
|
||||||
|
if(mDoParallel){
|
||||||
|
auto ploop = mIndex.pifor( 1, in.loop(ae) );
|
||||||
|
ploop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto loop = mIndex.ifor( 1, in.loop(ae) );
|
||||||
|
loop(); // execute overall loop(s) and so internal hidden loops and so the inherited expressions
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
//return OperationMaster<T,plus<T>,OpClass,Ranges...>(mDataPtr, in, mIndex, mDoParallel);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
OperationMaster<T,SelfIdentity<T>,OperationRoot<T,Ranges...>,Ranges...>
|
OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::operator=(const OperationRoot<T,Ranges...>& in)
|
||||||
OperationRoot<T,Ranges...>::operator=(const OperationRoot<T,Ranges...>& in)
|
//OperationMaster<T,SelfIdentity<T>,OperationRoot<T,Ranges...>,Ranges...>
|
||||||
|
//OperationRoot<T,Ranges...>::operator=(const OperationRoot<T,Ranges...>& in)
|
||||||
{
|
{
|
||||||
return operator=<OperationRoot<T,Ranges...> >(in);
|
return operator=<OperationRoot<T,Ranges...> >(in);
|
||||||
}
|
}
|
||||||
|
@ -398,17 +460,17 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T OperationRoot<T,Ranges...>::get(ET pos) const
|
inline T& OperationRoot<T,Ranges...>::get(ET pos) const
|
||||||
{
|
{
|
||||||
return mDataPtr[pos.val()+mOff];
|
return mDataPtr[pos.val()/*+mOff*/];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::set(ET pos) const
|
inline OperationRoot<T,Ranges...>& OperationRoot<T,Ranges...>::set(ET pos)
|
||||||
{
|
{
|
||||||
mIndex = pos.val();
|
mIndex = pos.val();
|
||||||
mOff = mIndex.pos();
|
mDataPtr = mOrigDataPtr + mIndex.pos();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +491,8 @@ namespace MultiArrayTools
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
T* OperationRoot<T,Ranges...>::data() const
|
T* OperationRoot<T,Ranges...>::data() const
|
||||||
{
|
{
|
||||||
return mDataPtr + mIndex().pos();
|
auto i = mIndex;
|
||||||
|
return mDataPtr + i().pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
@ -452,14 +515,14 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T OperationValue<T>::get(ET pos) const
|
inline const T& OperationValue<T>::get(ET pos) const
|
||||||
{
|
{
|
||||||
return mVal;
|
return mVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const OperationValue<T>& OperationValue<T>::set(ET pos) const
|
inline OperationValue<T>& OperationValue<T>::set(ET pos)
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -509,7 +572,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <typename T, class OpFunction, class... Ops>
|
template <typename T, class OpFunction, class... Ops>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::set(ET pos) const
|
inline Operation<T,OpFunction,Ops...>& Operation<T,OpFunction,Ops...>::set(ET pos)
|
||||||
{
|
{
|
||||||
PackNum<sizeof...(Ops)-1>::setOpPos(mOps,pos);
|
PackNum<sizeof...(Ops)-1>::setOpPos(mOps,pos);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -543,14 +606,15 @@ namespace MultiArrayTools
|
||||||
// forward loop !!!!
|
// forward loop !!!!
|
||||||
template <typename T, class Op, class IndexType>
|
template <typename T, class Op, class IndexType>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T Contraction<T,Op,IndexType>::get(ET pos) const
|
inline auto Contraction<T,Op,IndexType>::get(ET pos) const
|
||||||
|
-> decltype(mOp.template get<ET>(pos))
|
||||||
{
|
{
|
||||||
return mOp.template get<ET>(pos);
|
return mOp.template get<ET>(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class Op, class IndexType>
|
template <typename T, class Op, class IndexType>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const Contraction<T,Op,IndexType>& Contraction<T,Op,IndexType>::set(ET pos) const
|
inline Contraction<T,Op,IndexType>& Contraction<T,Op,IndexType>::set(ET pos)
|
||||||
{
|
{
|
||||||
mOp.set(pos);
|
mOp.set(pos);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -597,7 +661,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <typename T, class Op, class... Indices>
|
template <typename T, class Op, class... Indices>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const SliceContraction<T,Op,Indices...>& SliceContraction<T,Op,Indices...>::set(ET pos) const
|
inline SliceContraction<T,Op,Indices...>& SliceContraction<T,Op,Indices...>::set(ET pos)
|
||||||
{
|
{
|
||||||
mOp.set(pos);
|
mOp.set(pos);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -95,9 +95,9 @@ namespace MultiArrayTools
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct SelfIdentity
|
struct SelfIdentity
|
||||||
{
|
{
|
||||||
static inline T apply(const T& a, const T& b)
|
static inline T& sapply(T& a, T b)
|
||||||
{
|
{
|
||||||
return b;
|
return a = b;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,8 +111,9 @@ namespace MultiArrayTools
|
||||||
private:
|
private:
|
||||||
AssignmentExpr() = default;
|
AssignmentExpr() = default;
|
||||||
|
|
||||||
OperationMaster& mM;
|
//OperationMaster mM;
|
||||||
const OpClass& mSec;
|
OpClass mSec;
|
||||||
|
T* mDataPtr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -120,13 +121,42 @@ namespace MultiArrayTools
|
||||||
static constexpr size_t SIZE = OpClass::SIZE;
|
static constexpr size_t SIZE = OpClass::SIZE;
|
||||||
typedef decltype(mSec.rootSteps()) ExtType;
|
typedef decltype(mSec.rootSteps()) ExtType;
|
||||||
|
|
||||||
AssignmentExpr(OperationMaster& m, const OpClass& sec);
|
//AssignmentExpr(OperationMaster& m, const OpClass& sec);
|
||||||
|
AssignmentExpr(T* dataPtr, const OpClass& sec);
|
||||||
|
|
||||||
AssignmentExpr(const AssignmentExpr& in) = default;
|
AssignmentExpr(const AssignmentExpr& in) = default;
|
||||||
AssignmentExpr(AssignmentExpr&& in) = default;
|
AssignmentExpr(AssignmentExpr&& in) = default;
|
||||||
|
|
||||||
inline void operator()(size_t start = 0) const;
|
inline void operator()(size_t start = 0);
|
||||||
inline void operator()(size_t start, ExtType last) const;
|
inline void operator()(size_t start, ExtType last);
|
||||||
|
|
||||||
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class AddExpr
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
AddExpr() = default;
|
||||||
|
|
||||||
|
//OperationMaster mM;
|
||||||
|
OpClass mSec;
|
||||||
|
T* mDataPtr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
static constexpr size_t LAYER = 0;
|
||||||
|
static constexpr size_t SIZE = OpClass::SIZE;
|
||||||
|
typedef decltype(mSec.rootSteps()) ExtType;
|
||||||
|
|
||||||
|
//AssignmentExpr(OperationMaster& m, const OpClass& sec);
|
||||||
|
AddExpr(T* dataPtr, const OpClass& sec);
|
||||||
|
|
||||||
|
AddExpr(const AddExpr& in) = default;
|
||||||
|
AddExpr(AddExpr&& in) = default;
|
||||||
|
|
||||||
|
inline void operator()(size_t start = 0);
|
||||||
|
inline void operator()(size_t start, ExtType last);
|
||||||
|
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
auto rootSteps(std::intptr_t iPtrNum = 0) const -> ExtType;
|
||||||
|
|
||||||
|
@ -144,7 +174,7 @@ namespace MultiArrayTools
|
||||||
OperationMaster(T* data, const OpClass& second,
|
OperationMaster(T* data, const OpClass& second,
|
||||||
IndexType& index, bool doParallel = false);
|
IndexType& index, bool doParallel = false);
|
||||||
|
|
||||||
inline void set(size_t pos, T val) { mDataPtr[pos] = AOp::apply(mDataPtr[pos],val); }
|
inline void set(size_t pos, T val) { AOp::sapply(mDataPtr[pos],val); }
|
||||||
|
|
||||||
//inline void add(size_t pos, T val) { mDataPtr[pos] += val; }
|
//inline void add(size_t pos, T val) { mDataPtr[pos] += val; }
|
||||||
inline T get(size_t pos) const;
|
inline T get(size_t pos) const;
|
||||||
|
@ -171,6 +201,7 @@ namespace MultiArrayTools
|
||||||
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
|
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
|
||||||
|
|
||||||
static constexpr size_t SIZE = 1;
|
static constexpr size_t SIZE = 1;
|
||||||
|
static constexpr bool CONT = true;
|
||||||
|
|
||||||
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
||||||
|
@ -181,10 +212,10 @@ namespace MultiArrayTools
|
||||||
ConstOperationRoot(const T* data, const IndexType& ind);
|
ConstOperationRoot(const T* data, const IndexType& ind);
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T get(ET pos) const;
|
inline const T& get(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const ConstOperationRoot& set(ET pos) const;
|
inline ConstOperationRoot& set(ET pos);
|
||||||
|
|
||||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||||
|
|
||||||
|
@ -197,8 +228,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
//MultiArrayBase<T,Ranges...> const& mArrayRef;
|
//MultiArrayBase<T,Ranges...> const& mArrayRef;
|
||||||
const T* mDataPtr;
|
const T* mDataPtr;
|
||||||
mutable IndexType mIndex;
|
const T* mOrigDataPtr;
|
||||||
mutable size_t mOff = 0;
|
IndexType mIndex;
|
||||||
|
//size_t mOff = 0;
|
||||||
std::shared_ptr<MultiArrayBase<T,Ranges...> > mMaPtr; // never remove this ptr, otherwise we lose temporary container instances!
|
std::shared_ptr<MultiArrayBase<T,Ranges...> > mMaPtr; // never remove this ptr, otherwise we lose temporary container instances!
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -206,7 +238,7 @@ namespace MultiArrayTools
|
||||||
class StaticCast : public OperationTemplate<T,StaticCast<T,Op> >
|
class StaticCast : public OperationTemplate<T,StaticCast<T,Op> >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const Op& mOp;
|
Op mOp;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -216,6 +248,7 @@ namespace MultiArrayTools
|
||||||
typedef typename Op::IndexType IndexType;
|
typedef typename Op::IndexType IndexType;
|
||||||
|
|
||||||
static constexpr size_t SIZE = Op::SIZE;
|
static constexpr size_t SIZE = Op::SIZE;
|
||||||
|
static constexpr bool CONT = false;
|
||||||
|
|
||||||
StaticCast(const Op& op);
|
StaticCast(const Op& op);
|
||||||
|
|
||||||
|
@ -223,7 +256,7 @@ namespace MultiArrayTools
|
||||||
inline T get(ET pos) const;
|
inline T get(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const StaticCast& set(ET pos) const;
|
inline StaticCast& set(ET pos);
|
||||||
|
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const
|
auto rootSteps(std::intptr_t iPtrNum = 0) const
|
||||||
-> decltype(mOp.rootSteps(iPtrNum));
|
-> decltype(mOp.rootSteps(iPtrNum));
|
||||||
|
@ -250,6 +283,7 @@ namespace MultiArrayTools
|
||||||
typedef OperationBase<value_type,MetaOperationRoot<Range> > OT;
|
typedef OperationBase<value_type,MetaOperationRoot<Range> > OT;
|
||||||
|
|
||||||
static constexpr size_t SIZE = 1;
|
static constexpr size_t SIZE = 1;
|
||||||
|
static constexpr bool CONT = false;
|
||||||
|
|
||||||
MetaOperationRoot(const std::shared_ptr<IndexType>& ind);
|
MetaOperationRoot(const std::shared_ptr<IndexType>& ind);
|
||||||
|
|
||||||
|
@ -257,7 +291,7 @@ namespace MultiArrayTools
|
||||||
inline value_type get(ET pos) const;
|
inline value_type get(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const MetaOperationRoot& set(ET pos) const;
|
inline MetaOperationRoot& set(ET pos);
|
||||||
|
|
||||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||||
|
|
||||||
|
@ -283,12 +317,13 @@ namespace MultiArrayTools
|
||||||
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
|
typedef ContainerIndex<T,typename Ranges::IndexType...> IndexType;
|
||||||
|
|
||||||
static constexpr size_t SIZE = 1;
|
static constexpr size_t SIZE = 1;
|
||||||
|
static constexpr bool CONT = true;
|
||||||
|
|
||||||
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
||||||
|
|
||||||
OperationRoot(T* data, const IndexType& ind);
|
OperationRoot(T* data, const IndexType& ind);
|
||||||
|
/*
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...> operator=(const OpClass& in);
|
OperationMaster<T,SelfIdentity<T>,OpClass,Ranges...> operator=(const OpClass& in);
|
||||||
|
|
||||||
|
@ -296,14 +331,23 @@ namespace MultiArrayTools
|
||||||
OperationMaster<T,plus<T>,OpClass,Ranges...> operator+=(const OpClass& in);
|
OperationMaster<T,plus<T>,OpClass,Ranges...> operator+=(const OpClass& in);
|
||||||
|
|
||||||
OperationMaster<T,SelfIdentity<T>,OperationRoot,Ranges...> operator=(const OperationRoot& in);
|
OperationMaster<T,SelfIdentity<T>,OperationRoot,Ranges...> operator=(const OperationRoot& in);
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class OpClass>
|
||||||
|
OperationRoot& operator=(const OpClass& in);
|
||||||
|
|
||||||
|
template <class OpClass>
|
||||||
|
OperationRoot& operator+=(const OpClass& in);
|
||||||
|
|
||||||
|
OperationRoot& operator=(const OperationRoot& in);
|
||||||
|
|
||||||
OperationRoot& par();
|
OperationRoot& par();
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T get(ET pos) const;
|
inline T& get(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const OperationRoot& set(ET pos) const;
|
inline OperationRoot& set(ET pos);
|
||||||
|
|
||||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||||
|
|
||||||
|
@ -320,8 +364,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
//MutableMultiArrayBase<T,Ranges...>& mArrayRef;
|
//MutableMultiArrayBase<T,Ranges...>& mArrayRef;
|
||||||
T* mDataPtr;
|
T* mDataPtr;
|
||||||
mutable IndexType mIndex;
|
T* mOrigDataPtr;
|
||||||
mutable size_t mOff = 0;
|
IndexType mIndex;
|
||||||
|
//size_t mOff = 0;
|
||||||
bool mDoParallel = false;
|
bool mDoParallel = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -335,14 +380,15 @@ namespace MultiArrayTools
|
||||||
typedef ContainerIndex<T,NullIndex> IndexType;
|
typedef ContainerIndex<T,NullIndex> IndexType;
|
||||||
|
|
||||||
static constexpr size_t SIZE = 1;
|
static constexpr size_t SIZE = 1;
|
||||||
|
static constexpr bool CONT = true;
|
||||||
|
|
||||||
OperationValue(const T& val);
|
OperationValue(const T& val);
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T get(ET pos) const;
|
inline const T& get(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const OperationValue& set(ET pos) const;
|
inline OperationValue& set(ET pos);
|
||||||
|
|
||||||
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
MExt<void> rootSteps(std::intptr_t iPtrNum = 0) const; // nullptr for simple usage with decltype
|
||||||
|
|
||||||
|
@ -404,6 +450,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
static constexpr size_t SIZE = RootSum<Ops...>::SIZE;
|
static constexpr size_t SIZE = RootSum<Ops...>::SIZE;
|
||||||
static constexpr bool FISSTATIC = OpFunction::FISSTATIC;
|
static constexpr bool FISSTATIC = OpFunction::FISSTATIC;
|
||||||
|
static constexpr bool CONT = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::tuple<Ops...> mOps;
|
std::tuple<Ops...> mOps;
|
||||||
|
@ -419,7 +466,7 @@ namespace MultiArrayTools
|
||||||
inline T get(ET pos) const;
|
inline T get(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const Operation& set(ET pos) const;
|
inline Operation& set(ET pos);
|
||||||
|
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
||||||
-> decltype(PackNum<sizeof...(Ops)-1>::mkSteps(iPtrNum, mOps));
|
-> decltype(PackNum<sizeof...(Ops)-1>::mkSteps(iPtrNum, mOps));
|
||||||
|
@ -464,7 +511,6 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T, class Op, class IndexType>
|
template <typename T, class Op, class IndexType>
|
||||||
class Contraction : public OperationTemplate<T,Contraction<T,Op,IndexType> >
|
class Contraction : public OperationTemplate<T,Contraction<T,Op,IndexType> >
|
||||||
{
|
{
|
||||||
|
@ -474,10 +520,11 @@ namespace MultiArrayTools
|
||||||
typedef OperationBase<T,Contraction<T,Op,IndexType> > OT;
|
typedef OperationBase<T,Contraction<T,Op,IndexType> > OT;
|
||||||
|
|
||||||
static constexpr size_t SIZE = Op::SIZE;
|
static constexpr size_t SIZE = Op::SIZE;
|
||||||
|
static constexpr bool CONT = Op::CONT;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const Op& mOp;
|
Op mOp;
|
||||||
std::shared_ptr<IndexType> mInd;
|
std::shared_ptr<IndexType> mInd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -486,10 +533,11 @@ namespace MultiArrayTools
|
||||||
Contraction(const Op& op, std::shared_ptr<IndexType> ind);
|
Contraction(const Op& op, std::shared_ptr<IndexType> ind);
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T get(ET pos) const;
|
inline auto get(ET pos) const
|
||||||
|
-> decltype(mOp.template get<ET>(pos));
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const Contraction& set(ET pos) const;
|
inline Contraction& set(ET pos);
|
||||||
|
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
||||||
-> decltype(mOp.rootSteps(iPtrNum));
|
-> decltype(mOp.rootSteps(iPtrNum));
|
||||||
|
@ -510,10 +558,11 @@ namespace MultiArrayTools
|
||||||
typedef OperationTemplate<T,SliceContraction<T,Op,Indices...> > OT;
|
typedef OperationTemplate<T,SliceContraction<T,Op,Indices...> > OT;
|
||||||
|
|
||||||
static constexpr size_t SIZE = Op::SIZE;
|
static constexpr size_t SIZE = Op::SIZE;
|
||||||
|
static constexpr bool CONT = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const Op& mOp;
|
mutable Op mOp;
|
||||||
mutable std::shared_ptr<MultiArray<T,typename Indices::RangeType...> > mCont;
|
mutable std::shared_ptr<MultiArray<T,typename Indices::RangeType...> > mCont;
|
||||||
mutable OperationRoot<T,typename Indices::RangeType...> mTarOp;
|
mutable OperationRoot<T,typename Indices::RangeType...> mTarOp;
|
||||||
|
|
||||||
|
@ -526,7 +575,7 @@ namespace MultiArrayTools
|
||||||
inline const value_type& get(ET pos) const;
|
inline const value_type& get(ET pos) const;
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline const SliceContraction& set(ET pos) const;
|
inline SliceContraction& set(ET pos);
|
||||||
|
|
||||||
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
auto rootSteps(std::intptr_t iPtrNum = 0) const // nullptr for simple usage with decltype
|
||||||
-> decltype(mOp.rootSteps(iPtrNum));
|
-> decltype(mOp.rootSteps(iPtrNum));
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t LAST, typename T, class ETuple, class OpTuple, class OpFunction, typename... Args>
|
template <size_t LAST, typename T, class ETuple, class OpTuple, class OpFunction, typename... Args>
|
||||||
static inline T mkOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, const Args&... args)
|
static inline T mkOpExpr(std::shared_ptr<OpFunction> f, const ETuple& pos, const OpTuple& ops, Args... args)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_reference<decltype(std::get<N>(ops))>::type NextOpType;
|
typedef typename std::remove_reference<decltype(std::get<N>(ops))>::type NextOpType;
|
||||||
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
||||||
|
@ -116,7 +116,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t LAST,class OpTuple, class ETuple>
|
template <size_t LAST,class OpTuple, class ETuple>
|
||||||
static inline void setOpPos(const OpTuple& ot, const ETuple& et)
|
static inline void setOpPos(OpTuple& ot, const ETuple& et)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_reference<decltype(std::get<N>(ot))>::type NextOpType;
|
typedef typename std::remove_reference<decltype(std::get<N>(ot))>::type NextOpType;
|
||||||
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
||||||
|
@ -203,7 +203,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t LAST,class OpTuple, class ETuple>
|
template <size_t LAST,class OpTuple, class ETuple>
|
||||||
static inline void setOpPos(const OpTuple& ot, const ETuple& et)
|
static inline void setOpPos(OpTuple& ot, const ETuple& et)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_reference<decltype(std::get<0>(et))>::type NextOpType;
|
typedef typename std::remove_reference<decltype(std::get<0>(et))>::type NextOpType;
|
||||||
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
static_assert(LAST > NextOpType::SIZE, "inconsistent array positions");
|
||||||
|
|
|
@ -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
|
||||||
|
@ -36,7 +36,7 @@ namespace MultiArrayTools
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
AnonymousRangeFactory(std::shared_ptr<RangeTypes>... origs);
|
AnonymousRangeFactory(std::shared_ptr<RangeTypes>... origs);
|
||||||
|
|
||||||
AnonymousRangeFactory(const std::vector<std::shared_ptr<RangeBase>>& origs);
|
AnonymousRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs);
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
void append(std::shared_ptr<Range> r);
|
void append(std::shared_ptr<Range> r);
|
||||||
|
@ -45,15 +45,15 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> checkIfCreated(const std::vector<std::shared_ptr<RangeBase> >& pvec);
|
std::shared_ptr<RangeBase> checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec);
|
||||||
|
|
||||||
static std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > mAleadyCreated;
|
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
|
||||||
|
|
||||||
bool mProductCreated = false;
|
bool mProductCreated = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
@ -81,7 +81,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> sub(size_t num) const;
|
std::shared_ptr<RangeBase> sub(size_t num) const;
|
||||||
|
|
||||||
|
@ -91,10 +91,10 @@ namespace MultiArrayTools
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
||||||
|
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& orig() const;
|
const vector<std::shared_ptr<RangeBase> >& orig() const;
|
||||||
|
|
||||||
std::shared_ptr<AnonymousRange> sreplace(const std::shared_ptr<RangeBase> in, size_t num) const;
|
std::shared_ptr<AnonymousRange> sreplace(const std::shared_ptr<RangeBase> in, size_t num) const;
|
||||||
std::shared_ptr<AnonymousRange> sreplace(const std::vector<std::shared_ptr<RangeBase>>& in, size_t num) const;
|
std::shared_ptr<AnonymousRange> sreplace(const vector<std::shared_ptr<RangeBase>>& in, size_t num) const;
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
@ -105,21 +105,21 @@ 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 vector<std::shared_ptr<RangeBase>>& origs);
|
||||||
|
|
||||||
size_t mSize = 1;
|
size_t mSize = 1;
|
||||||
bool mEmpty = true;
|
bool mEmpty = true;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<RangeBase> > mOrig;
|
vector<std::shared_ptr<RangeBase> > mOrig;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void resolveSetRange<AnonymousRange>(std::shared_ptr<AnonymousRange>& rp,
|
inline void resolveSetRange<AnonymousRange>(std::shared_ptr<AnonymousRange>& rp,
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& orig,
|
const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
size_t origpos, size_t size)
|
size_t origpos, size_t size)
|
||||||
{
|
{
|
||||||
AnonymousRangeFactory arf;
|
AnonymousRangeFactory arf;
|
||||||
|
@ -184,7 +184,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void setRangeToVec<AnonymousRange>(std::vector<std::shared_ptr<RangeBase> >& v,
|
inline void setRangeToVec<AnonymousRange>(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
std::shared_ptr<AnonymousRange> r)
|
std::shared_ptr<AnonymousRange> r)
|
||||||
{
|
{
|
||||||
if(not r->isEmpty()){
|
if(not r->isEmpty()){
|
||||||
|
@ -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...);
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -14,7 +16,7 @@ namespace MultiArrayTools
|
||||||
struct DynamicMetaSetter
|
struct DynamicMetaSetter
|
||||||
{
|
{
|
||||||
template <typename... Us>
|
template <typename... Us>
|
||||||
static inline void set(const std::tuple<Us...>& in, std::vector<DynamicMetaElem>& meta)
|
static inline void set(const std::tuple<Us...>& in, vector<DynamicMetaElem>& meta)
|
||||||
{
|
{
|
||||||
typedef typename std::tuple_element<N,std::tuple<Us...>>::type elemtype;
|
typedef typename std::tuple_element<N,std::tuple<Us...>>::type elemtype;
|
||||||
meta[N].first = reinterpret_cast<const char*>( &std::get<N>(in) );
|
meta[N].first = reinterpret_cast<const char*>( &std::get<N>(in) );
|
||||||
|
@ -27,7 +29,7 @@ namespace MultiArrayTools
|
||||||
struct DynamicMetaSetter<0>
|
struct DynamicMetaSetter<0>
|
||||||
{
|
{
|
||||||
template <typename... Us>
|
template <typename... Us>
|
||||||
static inline void set(const std::tuple<Us...>& in, std::vector<DynamicMetaElem>& meta)
|
static inline void set(const std::tuple<Us...>& in, vector<DynamicMetaElem>& meta)
|
||||||
{
|
{
|
||||||
typedef typename std::tuple_element<0,std::tuple<Us...>>::type elemtype;
|
typedef typename std::tuple_element<0,std::tuple<Us...>>::type elemtype;
|
||||||
meta[0].first = reinterpret_cast<const char*>( &std::get<0>(in) );
|
meta[0].first = reinterpret_cast<const char*>( &std::get<0>(in) );
|
||||||
|
@ -39,7 +41,7 @@ namespace MultiArrayTools
|
||||||
class DynamicMetaT
|
class DynamicMetaT
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<DynamicMetaElem> mMeta;
|
vector<DynamicMetaElem> mMeta;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DynamicMetaT() = default;
|
DynamicMetaT() = default;
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
DynamicRangeFactory<EC>::DynamicRangeFactory(const std::vector<std::shared_ptr<RangeBase>>& origs)
|
DynamicRangeFactory<EC>::DynamicRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs)
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs ) );
|
mProd = std::shared_ptr<oType>( new DynamicRange<EC>( origs ) );
|
||||||
}
|
}
|
||||||
|
@ -99,10 +99,10 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
// INSTANCIATE IF NEEDED!!
|
// INSTANCIATE IF NEEDED!!
|
||||||
template <class EC>
|
template <class EC>
|
||||||
std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > DynamicRangeFactory<EC>::mAleadyCreated;
|
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > DynamicRangeFactory<EC>::mAleadyCreated;
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
std::shared_ptr<RangeBase> DynamicRangeFactory<EC>::checkIfCreated(const std::vector<std::shared_ptr<RangeBase> >& pvec)
|
std::shared_ptr<RangeBase> DynamicRangeFactory<EC>::checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec)
|
||||||
{
|
{
|
||||||
std::shared_ptr<RangeBase> out;
|
std::shared_ptr<RangeBase> out;
|
||||||
bool check = false;
|
bool check = false;
|
||||||
|
@ -122,7 +122,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(not check){
|
if(not check){
|
||||||
std::vector<std::intptr_t> app(pvec.size());
|
vector<std::intptr_t> app(pvec.size());
|
||||||
for(size_t i = 0; i != app.size(); ++i){
|
for(size_t i = 0; i != app.size(); ++i){
|
||||||
app[i] = reinterpret_cast<std::intptr_t>( pvec[i].get() );
|
app[i] = reinterpret_cast<std::intptr_t>( pvec[i].get() );
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const std::vector<std::shared_ptr<IndexW<EC>>>& ivec)
|
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const vector<std::shared_ptr<IndexW<EC>>>& ivec)
|
||||||
{
|
{
|
||||||
assert(mIVec.size() == ivec.size());
|
assert(mIVec.size() == ivec.size());
|
||||||
for(size_t i = 0; i != mIVec.size(); ++i){
|
for(size_t i = 0; i != mIVec.size(); ++i){
|
||||||
|
@ -237,7 +237,7 @@ namespace MultiArrayTools
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const std::shared_ptr<Indices>&... is)
|
DynamicIndex<EC>& DynamicIndex<EC>::operator()(const std::shared_ptr<Indices>&... is)
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<IndexW<EC>>> tmp =
|
vector<std::shared_ptr<IndexW<EC>>> tmp =
|
||||||
{ std::make_shared<IndexWrapper<Indices,EC>>(is)... };
|
{ std::make_shared<IndexWrapper<Indices,EC>>(is)... };
|
||||||
|
|
||||||
assert(mIVec.size() == tmp.size());
|
assert(mIVec.size() == tmp.size());
|
||||||
|
@ -489,10 +489,10 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
std::vector<char> DynamicRange<EC>::data() const
|
vector<char> DynamicRange<EC>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
for(auto& x: mOrig){
|
for(auto& x: mOrig){
|
||||||
|
@ -571,7 +571,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
DynamicRange<EC>::DynamicRange(const std::vector<std::shared_ptr<RangeBase>>& origs) :
|
DynamicRange<EC>::DynamicRange(const vector<std::shared_ptr<RangeBase>>& origs) :
|
||||||
RangeInterface<DynamicIndex<EC>>(),
|
RangeInterface<DynamicIndex<EC>>(),
|
||||||
mOrig(origs)
|
mOrig(origs)
|
||||||
{
|
{
|
||||||
|
@ -602,7 +602,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& DynamicRange<EC>::orig() const
|
const vector<std::shared_ptr<RangeBase> >& DynamicRange<EC>::orig() const
|
||||||
{
|
{
|
||||||
return mOrig;
|
return mOrig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace MultiArrayTools
|
||||||
class DynamicIndex : public IndexInterface<DynamicIndex<EC>,DynamicMetaT>
|
class DynamicIndex : public IndexInterface<DynamicIndex<EC>,DynamicMetaT>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef std::vector<std::pair<std::shared_ptr<IndexW<EC>>,size_t>> IVecT;
|
typedef vector<std::pair<std::shared_ptr<IndexW<EC>>,size_t>> IVecT;
|
||||||
|
|
||||||
IVecT mIVec;
|
IVecT mIVec;
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ namespace MultiArrayTools
|
||||||
DynamicIndex& operator--();
|
DynamicIndex& operator--();
|
||||||
|
|
||||||
DynamicIndex& operator()(const IVecT& ivec);
|
DynamicIndex& operator()(const IVecT& ivec);
|
||||||
DynamicIndex& operator()(const std::vector<std::shared_ptr<IndexW<EC>>>& ivec);
|
DynamicIndex& operator()(const vector<std::shared_ptr<IndexW<EC>>>& ivec);
|
||||||
|
|
||||||
template <class... Indices>
|
template <class... Indices>
|
||||||
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
DynamicIndex& operator()(const std::shared_ptr<Indices>&... is);
|
||||||
|
@ -259,7 +259,7 @@ namespace MultiArrayTools
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs);
|
DynamicRangeFactory(std::shared_ptr<RangeTypes>... origs);
|
||||||
|
|
||||||
DynamicRangeFactory(const std::vector<std::shared_ptr<RangeBase>>& origs);
|
DynamicRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs);
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
void append(std::shared_ptr<Range> r);
|
void append(std::shared_ptr<Range> r);
|
||||||
|
@ -268,9 +268,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> checkIfCreated(const std::vector<std::shared_ptr<RangeBase> >& pvec);
|
std::shared_ptr<RangeBase> checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec);
|
||||||
|
|
||||||
static std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > mAleadyCreated;
|
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
|
||||||
|
|
||||||
bool mProductCreated = false;
|
bool mProductCreated = false;
|
||||||
};
|
};
|
||||||
|
@ -299,12 +299,12 @@ namespace MultiArrayTools
|
||||||
template <class... RangeTypes>
|
template <class... RangeTypes>
|
||||||
DynamicRange(std::shared_ptr<RangeTypes>... origs);
|
DynamicRange(std::shared_ptr<RangeTypes>... origs);
|
||||||
|
|
||||||
DynamicRange(const std::vector<std::shared_ptr<RangeBase>>& origs);
|
DynamicRange(const vector<std::shared_ptr<RangeBase>>& origs);
|
||||||
|
|
||||||
size_t mSize = 1;
|
size_t mSize = 1;
|
||||||
bool mEmpty = true;
|
bool mEmpty = true;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<RangeBase> > mOrig;
|
vector<std::shared_ptr<RangeBase> > mOrig;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual size_t size() const final;
|
virtual size_t size() const final;
|
||||||
|
@ -320,7 +320,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> sub(size_t num) const;
|
std::shared_ptr<RangeBase> sub(size_t num) const;
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ namespace MultiArrayTools
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
std::shared_ptr<MultiRange<Ranges...> > scast(SIZET<Ranges>... sizes) const; // save cast
|
||||||
|
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& orig() const;
|
const vector<std::shared_ptr<RangeBase> >& orig() const;
|
||||||
|
|
||||||
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
void sreplace(const std::shared_ptr<RangeBase> in, size_t num);
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
inline void resolveSetRange(std::shared_ptr<DynamicRange<EC>>& rp,
|
inline void resolveSetRange(std::shared_ptr<DynamicRange<EC>>& rp,
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& orig,
|
const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
size_t origpos, size_t size)
|
size_t origpos, size_t size)
|
||||||
{
|
{
|
||||||
DynamicRangeFactory<EC> arf;
|
DynamicRangeFactory<EC> arf;
|
||||||
|
@ -364,7 +364,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EC>
|
template <class EC>
|
||||||
inline void setRangeToVec(std::vector<std::shared_ptr<RangeBase> >& v,
|
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
std::shared_ptr<DynamicRange<EC>> r)
|
std::shared_ptr<DynamicRange<EC>> r)
|
||||||
{
|
{
|
||||||
if(not r->isEmpty()){
|
if(not r->isEmpty()){
|
||||||
|
|
|
@ -201,7 +201,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
const Space& space() const;
|
const Space& space() const;
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(not check){
|
if(not check){
|
||||||
std::vector<std::intptr_t> pv(sizeof...(Ranges));
|
vector<std::intptr_t> pv(sizeof...(Ranges));
|
||||||
RPackNum<sizeof...(Ranges)-1>::RangesToVec(ptp, pv);
|
RPackNum<sizeof...(Ranges)-1>::RangesToVec(ptp, pv);
|
||||||
MultiRangeFactoryProductMap::mAleadyCreated[mProd] = pv;
|
MultiRangeFactoryProductMap::mAleadyCreated[mProd] = pv;
|
||||||
out = mProd;
|
out = mProd;
|
||||||
|
@ -590,10 +590,10 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
std::vector<char> MultiRange<Ranges...>::data() const
|
vector<char> MultiRange<Ranges...>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
//out.reserve(h.metaSize + sizeof(DataHeader));
|
//out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MultiArrayTools
|
||||||
friend class MultiRangeFactory;
|
friend class MultiRangeFactory;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > mAleadyCreated;
|
static std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > mAleadyCreated;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace MultiArrayTools
|
||||||
std::intptr_t id() const;
|
std::intptr_t id() const;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const = 0;
|
virtual std::string stringMeta(size_t pos) const = 0;
|
||||||
virtual std::vector<char> data() const = 0; // usefull when writing to files, etc...
|
virtual vector<char> data() const = 0; // usefull when writing to files, etc...
|
||||||
|
|
||||||
virtual SpaceType spaceType() const = 0;
|
virtual SpaceType spaceType() const = 0;
|
||||||
virtual DataHeader dataHeader() const = 0;
|
virtual DataHeader dataHeader() const = 0;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -43,7 +43,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
size_t get(size_t pos) const;
|
size_t get(size_t pos) const;
|
||||||
size_t getMeta(size_t metaPos) const;
|
size_t getMeta(size_t metaPos) const;
|
||||||
|
@ -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,20 +34,20 @@ 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;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
virtual SpaceType spaceType() const final;
|
virtual SpaceType spaceType() const final;
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() 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,35 +11,35 @@ 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;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
virtual SpaceType spaceType() const final;
|
virtual SpaceType spaceType() const final;
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() 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,35 +12,35 @@ 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;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
virtual SpaceType spaceType() const final;
|
virtual SpaceType spaceType() const final;
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<< " in " << __func__ << ": " << #a << " = " << a << std::endl;
|
<< " in " << __func__ << ": " << #a << " = " << a << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
@ -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>
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
inline void resolveSetRange(std::shared_ptr<Range>& rp, const std::vector<std::shared_ptr<RangeBase> >& orig,
|
inline void resolveSetRange(std::shared_ptr<Range>& rp, const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
size_t origpos, size_t size)
|
size_t origpos, size_t size)
|
||||||
{
|
{
|
||||||
assert(size == 1);
|
assert(size == 1);
|
||||||
|
@ -54,7 +54,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
inline void setRangeToVec(std::vector<std::shared_ptr<RangeBase> >& v,
|
inline void setRangeToVec(vector<std::shared_ptr<RangeBase> >& v,
|
||||||
std::shared_ptr<Range> r)
|
std::shared_ptr<Range> r)
|
||||||
{
|
{
|
||||||
v.insert(v.begin(), r);
|
v.insert(v.begin(), r);
|
||||||
|
@ -251,7 +251,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
||||||
std::vector<std::shared_ptr<RangeBase> >& v)
|
vector<std::shared_ptr<RangeBase> >& v)
|
||||||
{
|
{
|
||||||
setRangeToVec(v, std::get<N>(rst));
|
setRangeToVec(v, std::get<N>(rst));
|
||||||
RPackNum<N-1>::RangesToVec(rst, v);
|
RPackNum<N-1>::RangesToVec(rst, v);
|
||||||
|
@ -259,7 +259,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
||||||
std::vector<std::intptr_t>& v)
|
vector<std::intptr_t>& v)
|
||||||
{
|
{
|
||||||
v[N] = reinterpret_cast<std::intptr_t>( std::get<N>(rst).get() );
|
v[N] = reinterpret_cast<std::intptr_t>( std::get<N>(rst).get() );
|
||||||
RPackNum<N-1>::RangesToVec(rst, v);
|
RPackNum<N-1>::RangesToVec(rst, v);
|
||||||
|
@ -324,7 +324,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class RangeTuple, typename... SIZET>
|
template <class RangeTuple, typename... SIZET>
|
||||||
static inline void resolveRangeType(const std::vector<std::shared_ptr<RangeBase> >& orig,
|
static inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
RangeTuple& rtp, size_t off, size_t size, SIZET... sizes)
|
RangeTuple& rtp, size_t off, size_t size, SIZET... sizes)
|
||||||
{
|
{
|
||||||
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
||||||
|
@ -334,7 +334,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
||||||
const std::vector<std::intptr_t>& a)
|
const vector<std::intptr_t>& a)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<std::intptr_t>( std::get<N>(p).get() ) == a[N] and
|
return reinterpret_cast<std::intptr_t>( std::get<N>(p).get() ) == a[N] and
|
||||||
RPackNum<N-1>::checkIfCreated(p,a);
|
RPackNum<N-1>::checkIfCreated(p,a);
|
||||||
|
@ -347,22 +347,22 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void fillRangeDataVec(std::vector<char>& out,
|
static inline void fillRangeDataVec(vector<char>& out,
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& tp)
|
const std::tuple<std::shared_ptr<Ranges>...>& tp)
|
||||||
{
|
{
|
||||||
std::vector<char> part = std::get<sizeof...(Ranges)-N-1>(tp)->data();
|
vector<char> part = std::get<sizeof...(Ranges)-N-1>(tp)->data();
|
||||||
out.insert(out.end(), part.begin(), part.end());
|
out.insert(out.end(), part.begin(), part.end());
|
||||||
RPackNum<N-1>::fillRangeDataVec(out, tp);
|
RPackNum<N-1>::fillRangeDataVec(out, tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t SIZE, class Range, class... Ranges>
|
template <size_t SIZE, class Range, class... Ranges>
|
||||||
static inline bool compareSpaceTypes(const std::vector<std::shared_ptr<RangeBase> >& rbvec)
|
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
||||||
{
|
{
|
||||||
return rbvec[SIZE-N-1]->spaceType() == Range::STYPE and RPackNum<N-1>::template compareSpaceTypes<SIZE,Ranges...>(rbvec);
|
return rbvec[SIZE-N-1]->spaceType() == Range::STYPE and RPackNum<N-1>::template compareSpaceTypes<SIZE,Ranges...>(rbvec);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void setSpace(const std::vector<std::shared_ptr<RangeBase> >& rbvec,
|
static inline void setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
|
||||||
std::tuple<std::shared_ptr<Ranges>...>& stp)
|
std::tuple<std::shared_ptr<Ranges>...>& stp)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_reference<decltype(*std::get<N>( stp ))>::type RType;
|
typedef typename std::remove_reference<decltype(*std::get<N>( stp ))>::type RType;
|
||||||
|
@ -529,14 +529,14 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
||||||
std::vector<std::intptr_t>& v)
|
vector<std::intptr_t>& v)
|
||||||
{
|
{
|
||||||
v[0] = reinterpret_cast<std::intptr_t>( std::get<0>(rst).get() );;
|
v[0] = reinterpret_cast<std::intptr_t>( std::get<0>(rst).get() );;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
static inline void RangesToVec(const std::tuple<std::shared_ptr<Ranges>...>& rst,
|
||||||
std::vector<std::shared_ptr<RangeBase> >& v)
|
vector<std::shared_ptr<RangeBase> >& v)
|
||||||
{
|
{
|
||||||
setRangeToVec(v, std::get<0>(rst));
|
setRangeToVec(v, std::get<0>(rst));
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class RangeTuple, typename... SIZET>
|
template <class RangeTuple, typename... SIZET>
|
||||||
static inline void resolveRangeType(const std::vector<std::shared_ptr<RangeBase> >& orig,
|
static inline void resolveRangeType(const vector<std::shared_ptr<RangeBase> >& orig,
|
||||||
RangeTuple& rtp, size_t off, size_t size)
|
RangeTuple& rtp, size_t off, size_t size)
|
||||||
{
|
{
|
||||||
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
constexpr size_t tps = std::tuple_size<RangeTuple>::value;
|
||||||
|
@ -605,7 +605,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
static inline bool checkIfCreated(const std::tuple<std::shared_ptr<Ranges>...>& p,
|
||||||
const std::vector<std::intptr_t>& a)
|
const vector<std::intptr_t>& a)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<std::intptr_t>( std::get<0>(p).get() ) == a[0];
|
return reinterpret_cast<std::intptr_t>( std::get<0>(p).get() ) == a[0];
|
||||||
}
|
}
|
||||||
|
@ -617,21 +617,21 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void fillRangeDataVec(std::vector<char>& out,
|
static inline void fillRangeDataVec(vector<char>& out,
|
||||||
const std::tuple<std::shared_ptr<Ranges>...>& tp)
|
const std::tuple<std::shared_ptr<Ranges>...>& tp)
|
||||||
{
|
{
|
||||||
std::vector<char> part = std::get<sizeof...(Ranges)-1>(tp)->data();
|
vector<char> part = std::get<sizeof...(Ranges)-1>(tp)->data();
|
||||||
out.insert(out.end(), part.begin(), part.end());
|
out.insert(out.end(), part.begin(), part.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t SIZE, class Range>
|
template <size_t SIZE, class Range>
|
||||||
static inline bool compareSpaceTypes(const std::vector<std::shared_ptr<RangeBase> >& rbvec)
|
static inline bool compareSpaceTypes(const vector<std::shared_ptr<RangeBase> >& rbvec)
|
||||||
{
|
{
|
||||||
return rbvec[SIZE-1]->spaceType() == Range::STYPE;
|
return rbvec[SIZE-1]->spaceType() == Range::STYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
static inline void setSpace(const std::vector<std::shared_ptr<RangeBase> >& rbvec,
|
static inline void setSpace(const vector<std::shared_ptr<RangeBase> >& rbvec,
|
||||||
std::tuple<std::shared_ptr<Ranges>...>& stp)
|
std::tuple<std::shared_ptr<Ranges>...>& stp)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_reference<decltype(*std::get<0>( stp ))>::type RType;
|
typedef typename std::remove_reference<decltype(*std::get<0>( stp ))>::type RType;
|
||||||
|
|
|
@ -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,32 +84,31 @@ 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 vector<U>& space);
|
||||||
std::shared_ptr<RangeBase> create();
|
std::shared_ptr<RangeBase> create();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
|
@ -125,7 +124,7 @@ namespace MultiArrayTools
|
||||||
MetaMap& operator=(MetaMap&& in) = default;
|
MetaMap& operator=(MetaMap&& in) = default;
|
||||||
|
|
||||||
//MetaMap(const std::map<U,size_t>& in) : mMap(in) {}
|
//MetaMap(const std::map<U,size_t>& in) : mMap(in) {}
|
||||||
MetaMap(const std::vector<U>& in)
|
MetaMap(const vector<U>& in)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i != in.size(); ++i){
|
for(size_t i = 0; i != in.size(); ++i){
|
||||||
mMap[in[i]] = i;
|
mMap[in[i]] = i;
|
||||||
|
@ -140,7 +139,7 @@ namespace MultiArrayTools
|
||||||
class MetaMap<std::array<int,2> >
|
class MetaMap<std::array<int,2> >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<size_t> mMap;
|
vector<size_t> mMap;
|
||||||
int min1;
|
int min1;
|
||||||
int min2;
|
int min2;
|
||||||
int max1;
|
int max1;
|
||||||
|
@ -156,7 +155,7 @@ namespace MultiArrayTools
|
||||||
MetaMap& operator=(const MetaMap& in) = default;
|
MetaMap& operator=(const MetaMap& in) = default;
|
||||||
MetaMap& operator=(MetaMap&& in) = default;
|
MetaMap& operator=(MetaMap&& in) = default;
|
||||||
|
|
||||||
MetaMap(const std::vector<U>& in) : min1(in[0][0]),
|
MetaMap(const vector<U>& in) : min1(in[0][0]),
|
||||||
min2(in[0][1]),
|
min2(in[0][1]),
|
||||||
max1(in[0][0]),
|
max1(in[0][0]),
|
||||||
max2(in[0][1])
|
max2(in[0][1])
|
||||||
|
@ -187,16 +186,44 @@ 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 <SpaceType TYPE>
|
||||||
|
struct CheckDefault
|
||||||
|
{
|
||||||
|
static constexpr size_t ISDEFAULT = false;
|
||||||
|
static constexpr size_t HASMETACONT = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct CheckDefault<SpaceType::NONE>
|
||||||
|
{
|
||||||
|
static constexpr size_t ISDEFAULT = true;
|
||||||
|
static constexpr size_t HASMETACONT = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -205,7 +232,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
bool isMeta(const U& metaPos) const;
|
bool isMeta(const U& metaPos) const;
|
||||||
|
|
||||||
|
@ -215,25 +242,41 @@ 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 GenSingleRangeFactory<U,TYPE,S> factory()
|
||||||
static constexpr size_t ISSTATIC = 0;
|
{
|
||||||
static constexpr size_t SIZE = -1;
|
static_assert( not CheckDefault<TYPE>::HASMETACONT,
|
||||||
static constexpr bool HASMETACONT = true;
|
"asked for default factory for meta data containing range" );
|
||||||
|
return GenSingleRangeFactory<U,TYPE,S>(vector<U>());
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr bool defaultable = CheckDefault<TYPE>::ISDEFAULT;
|
||||||
|
static constexpr size_t ISSTATIC = CheckStatic<S>::ISSTATIC;
|
||||||
|
static constexpr size_t SIZE = CheckStatic<S>::SIZE;
|
||||||
|
static constexpr bool HASMETACONT = CheckDefault<TYPE>::HASMETACONT;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SingleRange() = delete;
|
GenSingleRange() = delete;
|
||||||
SingleRange(const SingleRange& in) = delete;
|
GenSingleRange(const GenSingleRange& in) = delete;
|
||||||
|
|
||||||
SingleRange(const std::vector<U>& space);
|
GenSingleRange(const vector<U>& space);
|
||||||
|
|
||||||
std::vector<U> mSpace;
|
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 +286,7 @@ namespace MultiArrayTools
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
/******************
|
/******************
|
||||||
* SingleIndex *
|
* GenSingleIndex *
|
||||||
******************/
|
******************/
|
||||||
|
|
||||||
template <bool HASMETACONT>
|
template <bool HASMETACONT>
|
||||||
|
@ -278,134 +321,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 +458,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 +490,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 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 +507,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 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,53 +517,65 @@ 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 <size_t SIZE>
|
||||||
size_t SingleRange<U,TYPE>::size() const
|
inline size_t getStatSizeOrDyn(size_t size)
|
||||||
{
|
{
|
||||||
return mSpace.size();
|
return SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U, SpaceType TYPE>
|
template <>
|
||||||
size_t SingleRange<U,TYPE>::dim() const
|
inline size_t getStatSizeOrDyn<-1>(size_t size)
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
|
size_t GenSingleRange<U,TYPE,S>::size() const
|
||||||
|
{
|
||||||
|
return getStatSizeOrDyn<S>(mSpace.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U, SpaceType TYPE, size_t S>
|
||||||
|
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
|
vector<char> GenSingleRange<U,TYPE,S>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
|
@ -530,8 +585,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 +596,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;
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
SubRangeFactory() = delete;
|
SubRangeFactory() = delete;
|
||||||
SubRangeFactory(const std::shared_ptr<Range>& fullRange,
|
SubRangeFactory(const std::shared_ptr<Range>& fullRange,
|
||||||
const std::vector<size_t>& subset);
|
const vector<size_t>& subset);
|
||||||
std::shared_ptr<RangeBase> create();
|
std::shared_ptr<RangeBase> create();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
bool isMeta(const MetaType& metaPos) const;
|
bool isMeta(const MetaType& metaPos) const;
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace MultiArrayTools
|
||||||
virtual IndexType end() const final;
|
virtual IndexType end() const final;
|
||||||
|
|
||||||
std::shared_ptr<Range> fullRange() const;
|
std::shared_ptr<Range> fullRange() const;
|
||||||
const std::vector<size_t>& subset() const;
|
const vector<size_t>& subset() const;
|
||||||
std::shared_ptr<SingleRange<MetaType,SpaceType::ANY>> outRange() const;
|
std::shared_ptr<SingleRange<MetaType,SpaceType::ANY>> outRange() const;
|
||||||
|
|
||||||
friend SubRangeFactory<Range>;
|
friend SubRangeFactory<Range>;
|
||||||
|
@ -147,10 +147,10 @@ namespace MultiArrayTools
|
||||||
SubRange() = delete;
|
SubRange() = delete;
|
||||||
SubRange(const SubRange& in) = delete;
|
SubRange(const SubRange& in) = delete;
|
||||||
|
|
||||||
SubRange(const std::shared_ptr<Range>& fullRange, const std::vector<size_t>& subset);
|
SubRange(const std::shared_ptr<Range>& fullRange, const vector<size_t>& subset);
|
||||||
|
|
||||||
std::shared_ptr<Range> mFullRange;
|
std::shared_ptr<Range> mFullRange;
|
||||||
std::vector<size_t> mSubSet;
|
vector<size_t> mSubSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
@ -350,7 +350,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
SubRangeFactory<Range>::SubRangeFactory(const std::shared_ptr<Range>& fullRange,
|
SubRangeFactory<Range>::SubRangeFactory(const std::shared_ptr<Range>& fullRange,
|
||||||
const std::vector<size_t>& subset)
|
const vector<size_t>& subset)
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new SubRange<Range>( fullRange, subset ) );
|
mProd = std::shared_ptr<oType>( new SubRange<Range>( fullRange, subset ) );
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
SubRange<Range>::SubRange(const std::shared_ptr<Range>& fullRange,
|
SubRange<Range>::SubRange(const std::shared_ptr<Range>& fullRange,
|
||||||
const std::vector<size_t>& subset) :
|
const vector<size_t>& subset) :
|
||||||
RangeInterface<SubIndex<typename Range::IndexType>>(),
|
RangeInterface<SubIndex<typename Range::IndexType>>(),
|
||||||
mFullRange(fullRange), mSubSet(subset) {}
|
mFullRange(fullRange), mSubSet(subset) {}
|
||||||
|
|
||||||
|
@ -408,14 +408,14 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
std::vector<char> SubRange<Range>::data() const
|
vector<char> SubRange<Range>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
std::vector<MetaType> subvec(mSubSet.size());
|
vector<MetaType> subvec(mSubSet.size());
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for(auto& x: mSubSet){
|
for(auto& x: mSubSet){
|
||||||
subvec[i++] = mFullRange->get(x);
|
subvec[i++] = mFullRange->get(x);
|
||||||
|
@ -477,7 +477,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Range>
|
template <class Range>
|
||||||
const std::vector<size_t>& SubRange<Range>::subset() const
|
const vector<size_t>& SubRange<Range>::subset() const
|
||||||
{
|
{
|
||||||
return mSubSet;
|
return mSubSet;
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ namespace MultiArrayTools
|
||||||
template <class Range>
|
template <class Range>
|
||||||
std::shared_ptr<SingleRange<typename SubRange<Range>::MetaType,SpaceType::ANY>> SubRange<Range>::outRange() const
|
std::shared_ptr<SingleRange<typename SubRange<Range>::MetaType,SpaceType::ANY>> SubRange<Range>::outRange() const
|
||||||
{
|
{
|
||||||
std::vector<MetaType> ometa(mSubSet.size());
|
vector<MetaType> ometa(mSubSet.size());
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for(auto& x: mSubSet){
|
for(auto& x: mSubSet){
|
||||||
ometa[i++] = mFullRange->get(x);
|
ometa[i++] = mFullRange->get(x);
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ namespace MultiArrayTools
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void stringCat(std::vector<char>& out, const std::vector<T>& in)
|
inline void stringCat(vector<char>& out, const vector<T>& in)
|
||||||
{
|
{
|
||||||
//for(auto& x: in) { std::cout << x << std::endl; }
|
//for(auto& x: in) { std::cout << x << std::endl; }
|
||||||
const char* scp = reinterpret_cast<const char*>(in.data());
|
const char* scp = reinterpret_cast<const char*>(in.data());
|
||||||
|
@ -31,20 +33,20 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline size_t metaSize(const std::vector<T>& in)
|
inline size_t metaSize(const vector<T>& in)
|
||||||
{
|
{
|
||||||
return in.size() * sizeof(T);
|
return in.size() * sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void metaCat(std::vector<T>& vec, const char* begin, size_t size)
|
inline void metaCat(vector<T>& vec, const char* begin, size_t size)
|
||||||
{
|
{
|
||||||
const T* tp = reinterpret_cast<const T*>( begin );
|
const T* tp = reinterpret_cast<const T*>( begin );
|
||||||
vec.insert(vec.end(), tp, tp + size / sizeof(T));
|
vec.insert(vec.end(), tp, tp + size / sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void stringCat<std::string>(std::vector<char>& out, const std::vector<std::string>& in)
|
inline void stringCat<std::string>(vector<char>& out, const vector<std::string>& in)
|
||||||
{
|
{
|
||||||
//for(auto& x: in) { std::cout << x << std::endl; }
|
//for(auto& x: in) { std::cout << x << std::endl; }
|
||||||
std::string tmp = "";
|
std::string tmp = "";
|
||||||
|
@ -56,7 +58,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline size_t metaSize<std::string>(const std::vector<std::string>& in)
|
inline size_t metaSize<std::string>(const vector<std::string>& in)
|
||||||
{
|
{
|
||||||
size_t out = 0;
|
size_t out = 0;
|
||||||
for(auto& x: in){
|
for(auto& x: in){
|
||||||
|
@ -66,7 +68,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void metaCat<std::string>(std::vector<std::string>& vec, const char* begin, size_t size)
|
inline void metaCat<std::string>(vector<std::string>& vec, const char* begin, size_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string tmp(begin, size);
|
std::string tmp(begin, size);
|
||||||
|
@ -92,10 +94,10 @@ namespace MultiArrayTools
|
||||||
include_type(float,4)
|
include_type(float,4)
|
||||||
include_type(double,5)
|
include_type(double,5)
|
||||||
include_type(std::string,6)
|
include_type(std::string,6)
|
||||||
include_type(std::vector<size_t>,101)
|
include_type(vector<size_t>,101)
|
||||||
include_type(std::vector<int>,102)
|
include_type(vector<int>,102)
|
||||||
include_type(std::vector<double>,105)
|
include_type(vector<double>,105)
|
||||||
include_type(std::vector<std::string>,106)
|
include_type(vector<std::string>,106)
|
||||||
include_type(std::array<size_t XCOMMAX() 2>,201)
|
include_type(std::array<size_t XCOMMAX() 2>,201)
|
||||||
include_type(std::array<int XCOMMAX() 2>,202)
|
include_type(std::array<int XCOMMAX() 2>,202)
|
||||||
include_type(std::array<size_t XCOMMAX() 3>,301)
|
include_type(std::array<size_t XCOMMAX() 3>,301)
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace MultiArrayTools
|
||||||
virtual DataHeader dataHeader() const final;
|
virtual DataHeader dataHeader() const final;
|
||||||
|
|
||||||
virtual std::string stringMeta(size_t pos) const final;
|
virtual std::string stringMeta(size_t pos) const final;
|
||||||
virtual std::vector<char> data() const final;
|
virtual vector<char> data() const final;
|
||||||
|
|
||||||
U get(size_t pos) const;
|
U get(size_t pos) const;
|
||||||
|
|
||||||
|
@ -361,11 +361,11 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
std::vector<char> ValueRange<U>::data() const
|
vector<char> ValueRange<U>::data() const
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace MultiArrayHelper
|
||||||
inline std::string xToString<DynamicMetaT>(const DynamicMetaT& x);
|
inline std::string xToString<DynamicMetaT>(const DynamicMetaT& x);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline std::string xToString(const std::vector<T>& x);
|
inline std::string xToString(const vector<T>& x);
|
||||||
|
|
||||||
template <typename T, size_t N>
|
template <typename T, size_t N>
|
||||||
inline std::string xToString(const std::array<T,N>& x);
|
inline std::string xToString(const std::array<T,N>& x);
|
||||||
|
@ -90,7 +90,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline std::string xToString(const std::vector<T>& x)
|
inline std::string xToString(const vector<T>& x)
|
||||||
{
|
{
|
||||||
std::string out = "[";
|
std::string out = "[";
|
||||||
for(auto& y: x){
|
for(auto& y: x){
|
||||||
|
|
|
@ -116,6 +116,15 @@ namespace MultiArrayTools
|
||||||
MutableMultiArrayBase<T,SRanges...>(ranges...),
|
MutableMultiArrayBase<T,SRanges...>(ranges...),
|
||||||
mData(data) {}
|
mData(data) {}
|
||||||
|
|
||||||
|
template <typename T, class... SRanges>
|
||||||
|
Slice<T,SRanges...>::Slice(const std::tuple<std::shared_ptr<SRanges>...>& ranges,
|
||||||
|
T* data) :
|
||||||
|
MutableMultiArrayBase<T,SRanges...>(ranges),
|
||||||
|
mData(data)
|
||||||
|
{
|
||||||
|
MAB::mInit = true;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class... SRanges>
|
template <typename T, class... SRanges>
|
||||||
const T& Slice<T,SRanges...>::operator[](const IType& i) const
|
const T& Slice<T,SRanges...>::operator[](const IType& i) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,6 +66,8 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
DEFAULT_MEMBERS(Slice);
|
DEFAULT_MEMBERS(Slice);
|
||||||
|
|
||||||
|
Slice(const std::tuple<std::shared_ptr<SRanges>...>& ranges,
|
||||||
|
T* data = nullptr);
|
||||||
Slice(const std::shared_ptr<SRanges>&... ranges, T* data = nullptr);
|
Slice(const std::shared_ptr<SRanges>&... ranges, T* data = nullptr);
|
||||||
|
|
||||||
virtual const T& operator[](const IType& i) const final;
|
virtual const T& operator[](const IType& i) const final;
|
||||||
|
|
|
@ -70,24 +70,77 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
getter(size_t i) : mPos(i) {}
|
getter(size_t i) : mPos(i) {}
|
||||||
|
|
||||||
inline T operator()(const std::vector<T>& in)
|
inline T operator()(const vector<T>& in)
|
||||||
{
|
{
|
||||||
return in[mPos];
|
return in[mPos];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::vector<T>& operator+=(std::vector<T>& a, const std::vector<T>& b)
|
vector<T>& operator+=(vector<T>& a, const vector<T>& b)
|
||||||
{
|
{
|
||||||
std::transform(a.begin(), a.end(), b.begin(), a.begin(), std::plus<T>());
|
std::transform(a.begin(), a.end(), b.begin(), a.begin(), std::plus<T>());
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
vector<T>& operator-=(vector<T>& a, const vector<T>& b)
|
||||||
|
{
|
||||||
|
std::transform(a.begin(), a.end(), b.begin(), a.begin(), std::minus<T>());
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
vector<T>& operator*=(vector<T>& a, const vector<T>& b)
|
||||||
|
{
|
||||||
|
std::transform(a.begin(), a.end(), b.begin(), a.begin(), std::multiplies<T>());
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
vector<T>& operator/=(vector<T>& a, const vector<T>& b)
|
||||||
|
{
|
||||||
|
std::transform(a.begin(), a.end(), b.begin(), a.begin(), std::divides<T>());
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
vector<T> operator+(vector<T>& a, const vector<T>& b)
|
||||||
|
{
|
||||||
|
vector<T> out(a.size());
|
||||||
|
std::transform(a.begin(), a.end(), b.begin(), out.begin(), std::plus<T>());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
vector<T> operator-(vector<T>& a, const vector<T>& b)
|
||||||
|
{
|
||||||
|
vector<T> out(a.size());
|
||||||
|
std::transform(a.begin(), a.end(), b.begin(), out.begin(), std::minus<T>());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
vector<T> operator*(vector<T>& a, const vector<T>& b)
|
||||||
|
{
|
||||||
|
vector<T> out(a.size());
|
||||||
|
std::transform(a.begin(), a.end(), b.begin(), out.begin(), std::multiplies<T>());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
vector<T> operator/(vector<T>& a, const vector<T>& b)
|
||||||
|
{
|
||||||
|
vector<T> out(a.size());
|
||||||
|
std::transform(a.begin(), a.end(), b.begin(), out.begin(), std::divides<T>());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
template <class OperationClass, typename T>
|
template <class OperationClass, typename T>
|
||||||
class OperationTemplate<std::vector<T>,OperationClass> : public OperationBase<std::vector<T>,OperationClass>
|
class OperationTemplate<vector<T>,OperationClass> : public OperationBase<vector<T>,OperationClass>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef OperationBase<std::vector<T>,OperationClass> OB;
|
typedef OperationBase<vector<T>,OperationClass> OB;
|
||||||
|
|
||||||
auto operator[](size_t i)
|
auto operator[](size_t i)
|
||||||
-> Operation<T,getter<T>,OperationClass>
|
-> Operation<T,getter<T>,OperationClass>
|
||||||
|
@ -101,29 +154,75 @@ namespace MultiArrayTools
|
||||||
friend OperationClass;
|
friend OperationClass;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::array<int,2>& operator+=(std::array<int,2>& a, const std::array<int,2>& b)
|
struct v256
|
||||||
{
|
{
|
||||||
std::get<0>(a) += std::get<0>(b);
|
alignas(32) double _x[4];
|
||||||
std::get<1>(a) += std::get<1>(b);
|
};
|
||||||
return a;
|
|
||||||
|
template <int N>
|
||||||
|
inline void xadd(double* o, const double* a, const double* b)
|
||||||
|
{
|
||||||
|
#pragma omp simd aligned(o, a, b: 32)
|
||||||
|
for(int i = 0; i < N; i++) {
|
||||||
|
o[i] = a[i] + b[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::array<int,3>& operator+=(std::array<int,3>& a, const std::array<int,3>& b)
|
template <int N>
|
||||||
|
inline void xsadd(double* o, const double* a)
|
||||||
{
|
{
|
||||||
std::get<0>(a) += std::get<0>(b);
|
#pragma omp simd aligned(o, a: 32)
|
||||||
std::get<1>(a) += std::get<1>(b);
|
for(int i = 0; i < N; i++) {
|
||||||
std::get<2>(a) += std::get<2>(b);
|
o[i] += a[i];
|
||||||
return a;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::tuple<int,int,int>& operator+=(std::tuple<int,int,int>& a, const std::tuple<int,int,int>& b)
|
inline v256 operator+(const v256& a, const v256& b)
|
||||||
{
|
{
|
||||||
std::get<0>(a) += std::get<0>(b);
|
v256 o;
|
||||||
std::get<1>(a) += std::get<1>(b);
|
xadd<4>( o._x, a._x, b._x );
|
||||||
std::get<2>(a) += std::get<2>(b);
|
return o;
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline v256& operator+=(v256& o, const v256& a)
|
||||||
|
{
|
||||||
|
//xsadd<4>( reinterpret_cast<double*>(&o), reinterpret_cast<const double*>(&a) );
|
||||||
|
xsadd<4>( o._x, a._x );
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
inline v256 operator-(const v256& a, const v256& b)
|
||||||
|
{
|
||||||
|
v256 out;
|
||||||
|
#pragma omp simd aligned(outp, ap, bp: 32)
|
||||||
|
for(int i = 0; i < IN; ++i){
|
||||||
|
outp[i] = ap[i] - bp[i];
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v256 operator*(const v256& a, const v256& b)
|
||||||
|
{
|
||||||
|
v256 out;
|
||||||
|
#pragma omp simd aligned(outp, ap, bp: 32)
|
||||||
|
for(int i = 0; i < IN; ++i){
|
||||||
|
outp[i] = ap[i] * bp[i];
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline v256 operator/(const v256& a, const v256& b)
|
||||||
|
{
|
||||||
|
v256 out;
|
||||||
|
#pragma omp simd aligned(outp, ap, bp: 32)
|
||||||
|
for(int i = 0; i < IN; ++i){
|
||||||
|
outp[i] = ap[i] / bp[i];
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace MultiArrayHelper
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline MExt(const std::array<size_t,N>& arr);
|
inline MExt(const std::array<size_t,N>& arr);
|
||||||
|
|
||||||
inline size_t val() const;
|
inline const size_t& val() const;
|
||||||
inline const X& next() const;
|
inline const X& next() const;
|
||||||
|
|
||||||
inline MExt operator+(const MExt& in) const;
|
inline MExt operator+(const MExt& in) const;
|
||||||
|
@ -76,7 +76,7 @@ namespace MultiArrayHelper
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
inline MExt(const std::array<size_t,N>& arr);
|
inline MExt(const std::array<size_t,N>& arr);
|
||||||
|
|
||||||
inline size_t val() const;
|
inline const size_t& val() const;
|
||||||
inline size_t next() const { return 0; }
|
inline size_t next() const { return 0; }
|
||||||
|
|
||||||
inline MExt operator+(const MExt& in) const;
|
inline MExt operator+(const MExt& in) const;
|
||||||
|
@ -151,7 +151,7 @@ namespace MultiArrayHelper
|
||||||
mExt(y.val()), mNext(y.next(), z) {}
|
mExt(y.val()), mNext(y.next(), z) {}
|
||||||
|
|
||||||
template <class X>
|
template <class X>
|
||||||
inline size_t MExt<X>::val() const
|
inline const size_t& MExt<X>::val() const
|
||||||
{
|
{
|
||||||
return mExt;
|
return mExt;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ namespace MultiArrayHelper
|
||||||
mExt(std::get<NUM>(arr)) {}
|
mExt(std::get<NUM>(arr)) {}
|
||||||
|
|
||||||
//template <>
|
//template <>
|
||||||
inline size_t MExt<void>::val() const
|
inline const size_t& MExt<void>::val() const
|
||||||
{
|
{
|
||||||
return mExt;
|
return mExt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "xfor/for_utils.h"
|
#include "xfor/for_utils.h"
|
||||||
#include "xfor/exttype.h"
|
#include "xfor/exttype.h"
|
||||||
|
|
||||||
|
#include "allocator.h"
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
|
||||||
#define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \
|
#define VCHECK(a) std::cout << __FILE__ << ": @" << __LINE__ \
|
||||||
|
@ -16,7 +17,7 @@
|
||||||
|
|
||||||
namespace MultiArrayHelper
|
namespace MultiArrayHelper
|
||||||
{
|
{
|
||||||
|
using namespace MultiArrayTools;
|
||||||
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
// 'HIDDEN FOR' CLASS for nested for loops in contractions a.s.o.
|
||||||
// (NO COUNTING OF MASTER POSITION !!!!!)
|
// (NO COUNTING OF MASTER POSITION !!!!!)
|
||||||
|
|
||||||
|
@ -34,8 +35,8 @@ namespace MultiArrayHelper
|
||||||
ExpressionBase& operator=(const ExpressionBase& in) = default;
|
ExpressionBase& operator=(const ExpressionBase& in) = default;
|
||||||
ExpressionBase& operator=(ExpressionBase&& in) = default;
|
ExpressionBase& operator=(ExpressionBase&& in) = default;
|
||||||
|
|
||||||
virtual void operator()(size_t mlast, DExt last) const = 0;
|
virtual void operator()(size_t mlast, DExt last) = 0;
|
||||||
virtual void operator()(size_t mlast = 0) const = 0;
|
virtual void operator()(size_t mlast = 0) = 0;
|
||||||
|
|
||||||
virtual DExt dRootSteps(std::intptr_t iPtrNum = 0) const = 0;
|
virtual DExt dRootSteps(std::intptr_t iPtrNum = 0) const = 0;
|
||||||
virtual DExt dExtension() const = 0;
|
virtual DExt dExtension() const = 0;
|
||||||
|
@ -126,9 +127,9 @@ namespace MultiArrayHelper
|
||||||
Expr expr);
|
Expr expr);
|
||||||
|
|
||||||
|
|
||||||
inline void operator()(size_t mlast, DExt last) const override final;
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
inline void operator()(size_t mlast, ExtType last) const;
|
inline void operator()(size_t mlast, ExtType last);
|
||||||
inline void operator()(size_t mlast = 0) const override final;
|
inline void operator()(size_t mlast = 0) override final;
|
||||||
|
|
||||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
DExt dExtension() const override final;
|
DExt dExtension() const override final;
|
||||||
|
@ -152,7 +153,7 @@ namespace MultiArrayHelper
|
||||||
typedef decltype(mkExt(0).extend(mExpr.rootSteps())) ExtType;
|
typedef decltype(mkExt(0).extend(mExpr.rootSteps())) ExtType;
|
||||||
ExtType mExt;
|
ExtType mExt;
|
||||||
|
|
||||||
const std::vector<size_t>* mSubSet;
|
const vector<size_t>* mSubSet;
|
||||||
|
|
||||||
mutable ExtType mRootSteps;
|
mutable ExtType mRootSteps;
|
||||||
|
|
||||||
|
@ -169,15 +170,15 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
SubExpr(const std::shared_ptr<IndexClass>& indPtr,
|
SubExpr(const std::shared_ptr<IndexClass>& indPtr,
|
||||||
std::intptr_t siptr,
|
std::intptr_t siptr,
|
||||||
const std::vector<size_t>* subset, Expr expr);
|
const vector<size_t>* subset, Expr expr);
|
||||||
|
|
||||||
SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
||||||
const std::vector<size_t>* subset, Expr expr);
|
const vector<size_t>* subset, Expr expr);
|
||||||
|
|
||||||
|
|
||||||
inline void operator()(size_t mlast, DExt last) const override final;
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
inline void operator()(size_t mlast, ExtType last) const;
|
inline void operator()(size_t mlast, ExtType last) ;
|
||||||
inline void operator()(size_t mlast = 0) const override final;
|
inline void operator()(size_t mlast = 0) override final;
|
||||||
|
|
||||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
DExt dExtension() const override final;
|
DExt dExtension() const override final;
|
||||||
|
@ -223,9 +224,9 @@ namespace MultiArrayHelper
|
||||||
For(const IndexClass* indPtr,
|
For(const IndexClass* indPtr,
|
||||||
size_t step, Expr expr);
|
size_t step, Expr expr);
|
||||||
|
|
||||||
inline void operator()(size_t mlast, DExt last) const override final;
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
inline void operator()(size_t mlast, ExtType last) const;
|
inline void operator()(size_t mlast, ExtType last) ;
|
||||||
inline void operator()(size_t mlast = 0) const override final;
|
inline void operator()(size_t mlast = 0) override final;
|
||||||
|
|
||||||
PFor<IndexClass,Expr> parallel() const;
|
PFor<IndexClass,Expr> parallel() const;
|
||||||
|
|
||||||
|
@ -271,9 +272,9 @@ namespace MultiArrayHelper
|
||||||
PFor(const IndexClass* indPtr,
|
PFor(const IndexClass* indPtr,
|
||||||
size_t step, Expr expr);
|
size_t step, Expr expr);
|
||||||
|
|
||||||
inline void operator()(size_t mlast, DExt last) const override final;
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
inline void operator()(size_t mlast, ExtType last) const;
|
inline void operator()(size_t mlast, ExtType last) ;
|
||||||
inline void operator()(size_t mlast = 0) const override final;
|
inline void operator()(size_t mlast = 0) override final;
|
||||||
|
|
||||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
DExt dExtension() const override final;
|
DExt dExtension() const override final;
|
||||||
|
@ -310,8 +311,8 @@ namespace MultiArrayHelper
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
|
DynamicExpression(Expr ex) : mNext( std::make_shared<Expr>(ex) ) {}
|
||||||
|
|
||||||
inline void operator()(size_t mlast, DExt last) const override final;
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
inline void operator()(size_t mlast = 0) const override final;
|
inline void operator()(size_t mlast = 0) override final;
|
||||||
|
|
||||||
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
inline DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
inline DExt dExtension() const override final;
|
inline DExt dExtension() const override final;
|
||||||
|
@ -344,9 +345,9 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
ExpressionHolder(DynamicExpression expr);
|
ExpressionHolder(DynamicExpression expr);
|
||||||
|
|
||||||
inline void operator()(size_t mlast, DExt last) const override final;
|
inline void operator()(size_t mlast, DExt last) override final;
|
||||||
inline void operator()(size_t mlast, ExtType last) const;
|
inline void operator()(size_t mlast, ExtType last) ;
|
||||||
inline void operator()(size_t mlast = 0) const override final;
|
inline void operator()(size_t mlast = 0) override final;
|
||||||
|
|
||||||
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
DExt dRootSteps(std::intptr_t iPtrNum = 0) const override final;
|
||||||
DExt dExtension() const override final;
|
DExt dExtension() const override final;
|
||||||
|
@ -390,14 +391,14 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast, DExt last) const
|
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast,
|
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast,
|
||||||
ExtType last) const
|
ExtType last)
|
||||||
{
|
{
|
||||||
typedef typename IndexClass::RangeType RangeType;
|
typedef typename IndexClass::RangeType RangeType;
|
||||||
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE>(mMax); ++pos){
|
for(size_t pos = 0u; pos != ForBound<RangeType::ISSTATIC>::template bound<RangeType::SIZE>(mMax); ++pos){
|
||||||
|
@ -410,7 +411,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr, ForType FT>
|
template <class IndexClass, class Expr, ForType FT>
|
||||||
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast) const
|
inline void For<IndexClass,Expr,FT>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
typedef typename IndexClass::RangeType RangeType;
|
typedef typename IndexClass::RangeType RangeType;
|
||||||
const ExtType last;
|
const ExtType last;
|
||||||
|
@ -483,14 +484,14 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast, DExt last) const
|
inline void PFor<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast,
|
inline void PFor<IndexClass,Expr>::operator()(size_t mlast,
|
||||||
ExtType last) const
|
ExtType last)
|
||||||
{
|
{
|
||||||
CHECK;
|
CHECK;
|
||||||
typedef typename IndexClass::RangeType RangeType;
|
typedef typename IndexClass::RangeType RangeType;
|
||||||
|
@ -510,7 +511,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void PFor<IndexClass,Expr>::operator()(size_t mlast) const
|
inline void PFor<IndexClass,Expr>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
CHECK;
|
CHECK;
|
||||||
typedef typename IndexClass::RangeType RangeType;
|
typedef typename IndexClass::RangeType RangeType;
|
||||||
|
@ -587,14 +588,14 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast, DExt last) const
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast,
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast,
|
||||||
ExtType last) const
|
ExtType last)
|
||||||
{
|
{
|
||||||
//typedef typename IndexClass::RangeType RangeType;
|
//typedef typename IndexClass::RangeType RangeType;
|
||||||
const size_t pos = mIndPtr->pos();
|
const size_t pos = mIndPtr->pos();
|
||||||
|
@ -604,7 +605,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast) const
|
inline void SingleExpression<IndexClass,Expr>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
//typedef typename IndexClass::RangeType RangeType;
|
//typedef typename IndexClass::RangeType RangeType;
|
||||||
const ExtType last;
|
const ExtType last;
|
||||||
|
@ -650,7 +651,7 @@ namespace MultiArrayHelper
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
SubExpr<IndexClass,Expr>::SubExpr(const std::shared_ptr<IndexClass>& indPtr,
|
SubExpr<IndexClass,Expr>::SubExpr(const std::shared_ptr<IndexClass>& indPtr,
|
||||||
std::intptr_t siptr,
|
std::intptr_t siptr,
|
||||||
const std::vector<size_t>* subset, Expr expr) :
|
const vector<size_t>* subset, Expr expr) :
|
||||||
mIndPtr(indPtr.get()), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
mIndPtr(indPtr.get()), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
||||||
mExpr(expr),
|
mExpr(expr),
|
||||||
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
||||||
|
@ -661,7 +662,7 @@ namespace MultiArrayHelper
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
SubExpr<IndexClass,Expr>::SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
SubExpr<IndexClass,Expr>::SubExpr(const IndexClass* indPtr, std::intptr_t siptr,
|
||||||
const std::vector<size_t>* subset, Expr expr) :
|
const vector<size_t>* subset, Expr expr) :
|
||||||
mIndPtr(indPtr), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
mIndPtr(indPtr), mSIPtr(siptr), mSPos(mIndPtr->pos()), mMax(mIndPtr->max()),
|
||||||
mExpr(expr),
|
mExpr(expr),
|
||||||
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
mExt( mkExt(0).extend( mExpr.rootSteps( reinterpret_cast<std::intptr_t>( mIndPtr )) ) ),
|
||||||
|
@ -671,14 +672,14 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last) const
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
operator()(mlast, *reinterpret_cast<ExtType const*>(last.first));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast,
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast,
|
||||||
ExtType last) const
|
ExtType last)
|
||||||
{
|
{
|
||||||
const size_t pos = (*mSubSet)[last.val()];
|
const size_t pos = (*mSubSet)[last.val()];
|
||||||
const size_t mnpos = mlast;
|
const size_t mnpos = mlast;
|
||||||
|
@ -687,7 +688,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IndexClass, class Expr>
|
template <class IndexClass, class Expr>
|
||||||
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast) const
|
inline void SubExpr<IndexClass,Expr>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
const ExtType last;
|
const ExtType last;
|
||||||
const size_t pos = (*mSubSet)[last.val()];
|
const size_t pos = (*mSubSet)[last.val()];
|
||||||
|
@ -730,12 +731,12 @@ namespace MultiArrayHelper
|
||||||
* DynamicExpression *
|
* DynamicExpression *
|
||||||
***************************/
|
***************************/
|
||||||
|
|
||||||
inline void DynamicExpression::operator()(size_t mlast, DExt last) const
|
inline void DynamicExpression::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
(*mNext)(mlast,last);
|
(*mNext)(mlast,last);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DynamicExpression::operator()(size_t mlast) const
|
inline void DynamicExpression::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
(*mNext)(mlast);
|
(*mNext)(mlast);
|
||||||
}
|
}
|
||||||
|
@ -758,13 +759,13 @@ namespace MultiArrayHelper
|
||||||
ExpressionHolder<Expr>::ExpressionHolder(DynamicExpression expr) : mExpr(expr) {}
|
ExpressionHolder<Expr>::ExpressionHolder(DynamicExpression expr) : mExpr(expr) {}
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast, DExt last) const
|
inline void ExpressionHolder<Expr>::operator()(size_t mlast, DExt last)
|
||||||
{
|
{
|
||||||
mExpr(mlast,last);
|
mExpr(mlast,last);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last) const
|
inline void ExpressionHolder<Expr>::operator()(size_t mlast, ExtType last)
|
||||||
{
|
{
|
||||||
mExpr(mlast,
|
mExpr(mlast,
|
||||||
std::make_pair<size_t const*,size_t>
|
std::make_pair<size_t const*,size_t>
|
||||||
|
@ -773,7 +774,7 @@ namespace MultiArrayHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Expr>
|
template <class Expr>
|
||||||
inline void ExpressionHolder<Expr>::operator()(size_t mlast) const
|
inline void ExpressionHolder<Expr>::operator()(size_t mlast)
|
||||||
{
|
{
|
||||||
mExpr(mlast);
|
mExpr(mlast);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > MapRangeFactoryProductMap::mAleadyCreated;
|
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > MapRangeFactoryProductMap::mAleadyCreated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,14 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > AnonymousRangeFactory::mAleadyCreated;
|
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > AnonymousRangeFactory::mAleadyCreated;
|
||||||
|
|
||||||
AnonymousRangeFactory::AnonymousRangeFactory(const std::vector<std::shared_ptr<RangeBase>>& origs)
|
AnonymousRangeFactory::AnonymousRangeFactory(const vector<std::shared_ptr<RangeBase>>& origs)
|
||||||
{
|
{
|
||||||
mProd = std::shared_ptr<oType>( new AnonymousRange( origs ) );
|
mProd = std::shared_ptr<oType>( new AnonymousRange( origs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RangeBase> AnonymousRangeFactory::checkIfCreated(const std::vector<std::shared_ptr<RangeBase> >& pvec)
|
std::shared_ptr<RangeBase> AnonymousRangeFactory::checkIfCreated(const vector<std::shared_ptr<RangeBase> >& pvec)
|
||||||
{
|
{
|
||||||
std::shared_ptr<RangeBase> out;
|
std::shared_ptr<RangeBase> out;
|
||||||
bool check = false;
|
bool check = false;
|
||||||
|
@ -40,7 +40,7 @@ namespace MultiArrayTools
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(not check){
|
if(not check){
|
||||||
std::vector<std::intptr_t> app(pvec.size());
|
vector<std::intptr_t> app(pvec.size());
|
||||||
for(size_t i = 0; i != app.size(); ++i){
|
for(size_t i = 0; i != app.size(); ++i){
|
||||||
app[i] = reinterpret_cast<std::intptr_t>( pvec[i].get() );
|
app[i] = reinterpret_cast<std::intptr_t>( pvec[i].get() );
|
||||||
}
|
}
|
||||||
|
@ -108,10 +108,10 @@ namespace MultiArrayTools
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> AnonymousRange::data() const
|
vector<char> AnonymousRange::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
for(auto& x: mOrig){
|
for(auto& x: mOrig){
|
||||||
|
@ -168,7 +168,7 @@ namespace MultiArrayTools
|
||||||
return std::dynamic_pointer_cast<AnonymousRange>(arf.create());
|
return std::dynamic_pointer_cast<AnonymousRange>(arf.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<AnonymousRange> AnonymousRange::sreplace(const std::vector<std::shared_ptr<RangeBase>>& in, size_t num) const
|
std::shared_ptr<AnonymousRange> AnonymousRange::sreplace(const vector<std::shared_ptr<RangeBase>>& in, size_t num) const
|
||||||
{
|
{
|
||||||
size_t nsize = 1;
|
size_t nsize = 1;
|
||||||
for(auto& x: in){
|
for(auto& x: in){
|
||||||
|
@ -191,12 +191,12 @@ namespace MultiArrayTools
|
||||||
return std::dynamic_pointer_cast<AnonymousRange>(arf.create());
|
return std::dynamic_pointer_cast<AnonymousRange>(arf.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::shared_ptr<RangeBase> >& AnonymousRange::orig() const
|
const vector<std::shared_ptr<RangeBase> >& AnonymousRange::orig() const
|
||||||
{
|
{
|
||||||
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 vector<std::shared_ptr<RangeBase>>& origs) :
|
||||||
RangeInterface<AnonymousIndex>(),
|
RangeInterface<AnonymousIndex>(),
|
||||||
mOrig(origs)
|
mOrig(origs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
|
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
std::map<std::shared_ptr<RangeBase>,std::vector<std::intptr_t> > MultiRangeFactoryProductMap::mAleadyCreated;
|
std::map<std::shared_ptr<RangeBase>,vector<std::intptr_t> > MultiRangeFactoryProductMap::mAleadyCreated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MultiArrayTools
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
using STP = std::tuple<std::shared_ptr<Ranges>...>;
|
using STP = std::tuple<std::shared_ptr<Ranges>...>;
|
||||||
|
|
||||||
typedef std::vector<std::shared_ptr<RangeBase> > RVEC;
|
typedef vector<std::shared_ptr<RangeBase> > RVEC;
|
||||||
|
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
inline bool compareSpaceTypes(const RVEC& rvec)
|
inline bool compareSpaceTypes(const RVEC& rvec)
|
||||||
|
@ -127,7 +127,7 @@ namespace MultiArrayTools
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
#define register_type(x) else if(x == h.metaType) { \
|
#define register_type(x) else if(x == h.metaType) { \
|
||||||
std::vector<TypeMap<x>::type> vd;\
|
vector<TypeMap<x>::type> vd;\
|
||||||
metaCat(vd, *dp, h.metaSize); \
|
metaCat(vd, *dp, h.metaSize); \
|
||||||
out = std::make_shared<SingleRangeFactory<TypeMap<x>::type, \
|
out = std::make_shared<SingleRangeFactory<TypeMap<x>::type, \
|
||||||
SpaceType::ANY> >(vd); }
|
SpaceType::ANY> >(vd); }
|
||||||
|
|
|
@ -5,63 +5,63 @@
|
||||||
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
|
vector<char> GenSingleRange<size_t,SpaceType::NONE,-1>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
|
@ -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,56 +42,56 @@ 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
|
vector<char> GenSingleRange<size_t,SpaceType::NUL,0>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
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,63 +11,63 @@ 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
|
vector<char> GenSingleRange<int,SpaceType::PSPACE,-1>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
|
@ -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,68 +10,68 @@ 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
|
vector<char> GenSingleRange<size_t,SpaceType::SPIN,4>::data() const
|
||||||
{
|
{
|
||||||
DataHeader h = dataHeader();
|
DataHeader h = dataHeader();
|
||||||
std::vector<char> out;
|
vector<char> out;
|
||||||
out.reserve(h.metaSize + sizeof(DataHeader));
|
out.reserve(h.metaSize + sizeof(DataHeader));
|
||||||
char* hcp = reinterpret_cast<char*>(&h);
|
char* hcp = reinterpret_cast<char*>(&h);
|
||||||
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
out.insert(out.end(), hcp, hcp + sizeof(DataHeader));
|
||||||
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 ) ) ) );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace {
|
||||||
template <class Factory, typename T>
|
template <class Factory, typename T>
|
||||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
||||||
{
|
{
|
||||||
std::vector<T> tmp = ilist;
|
vector<T> tmp = ilist;
|
||||||
auto nptr = std::make_shared<Factory>( tmp );
|
auto nptr = std::make_shared<Factory>( tmp );
|
||||||
fptr = nptr;
|
fptr = nptr;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace {
|
||||||
|
|
||||||
std::shared_ptr<RangeFactoryBase> rfbptr;
|
std::shared_ptr<RangeFactoryBase> rfbptr;
|
||||||
std::shared_ptr<SRange> srptr;
|
std::shared_ptr<SRange> srptr;
|
||||||
std::vector<double> vv = { 3.141, 2.718, 1.618, 0.693, 0.577 };
|
vector<double> vv = { 3.141, 2.718, 1.618, 0.693, 0.577 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace {
|
||||||
std::shared_ptr<SRange> sr3ptr;
|
std::shared_ptr<SRange> sr3ptr;
|
||||||
std::shared_ptr<SRange> sr4ptr;
|
std::shared_ptr<SRange> sr4ptr;
|
||||||
std::shared_ptr<MRange> mrptr;
|
std::shared_ptr<MRange> mrptr;
|
||||||
std::vector<double> vv = { 2.917, 9.436, 0.373, 7.192, 7.315, 1.536, 4.892, 0.280,
|
vector<double> vv = { 2.917, 9.436, 0.373, 7.192, 7.315, 1.536, 4.892, 0.280,
|
||||||
8.870, 4.790, 8.215, 5.063, 1.530, 3.084, 1.609, 4.847,
|
8.870, 4.790, 8.215, 5.063, 1.530, 3.084, 1.609, 4.847,
|
||||||
8.175, 0.112, 6.712, 6.408, 1.959, 0.331, 4.209, 2.951 };
|
8.175, 0.112, 6.712, 6.408, 1.959, 0.331, 4.209, 2.951 };
|
||||||
};
|
};
|
||||||
|
@ -114,7 +114,7 @@ namespace {
|
||||||
|
|
||||||
TEST_F(MATest_1Dim, ForLoop)
|
TEST_F(MATest_1Dim, ForLoop)
|
||||||
{
|
{
|
||||||
std::vector<double> v2 = { 0.693 , 2.718, 3.141, 1.618, 9.98 };
|
vector<double> v2 = { 0.693 , 2.718, 3.141, 1.618, 9.98 };
|
||||||
MultiArray<double,MATest_1Dim::SRange> ma(srptr, std::move( v2 ) );
|
MultiArray<double,MATest_1Dim::SRange> ma(srptr, std::move( v2 ) );
|
||||||
size_t cnt = 0;
|
size_t cnt = 0;
|
||||||
for(auto el: ma){
|
for(auto el: ma){
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "multi_array_header.h"
|
#include "multi_array_header.h"
|
||||||
|
#include "conversions.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#define ONLY_SPIN
|
#define ONLY_SPIN
|
||||||
|
|
||||||
|
@ -32,15 +34,15 @@ namespace {
|
||||||
template <class Factory, typename T>
|
template <class Factory, typename T>
|
||||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
||||||
{
|
{
|
||||||
std::vector<T> tmp = ilist;
|
vector<T> tmp = ilist;
|
||||||
auto nptr = std::make_shared<Factory>( tmp );
|
auto nptr = std::make_shared<Factory>( tmp );
|
||||||
fptr = nptr;
|
fptr = nptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Factory, typename T>
|
template <class Factory, typename T>
|
||||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::vector<T>& ilist)
|
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, vector<T>& ilist)
|
||||||
{
|
{
|
||||||
std::vector<T> tmp = ilist;
|
vector<T> tmp = ilist;
|
||||||
auto nptr = std::make_shared<Factory>( tmp );
|
auto nptr = std::make_shared<Factory>( tmp );
|
||||||
fptr = nptr;
|
fptr = nptr;
|
||||||
}
|
}
|
||||||
|
@ -78,14 +80,14 @@ namespace {
|
||||||
OpTest_Performance()
|
OpTest_Performance()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<size_t> initvec1(vs1);
|
vector<size_t> initvec1(vs1);
|
||||||
cv1.resize(vs1);
|
cv1.resize(vs1);
|
||||||
for(size_t i = 0; i != vs1; ++i){
|
for(size_t i = 0; i != vs1; ++i){
|
||||||
initvec1[i] = i;
|
initvec1[i] = i;
|
||||||
cv1[i] = sqrt( static_cast<double>(i)*0.53 );
|
cv1[i] = sqrt( static_cast<double>(i)*0.53 );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<size_t> initvec2(vs2);
|
vector<size_t> initvec2(vs2);
|
||||||
cv2.resize(vs2*vs1);
|
cv2.resize(vs2*vs1);
|
||||||
for(size_t i = 0; i != vs2; ++i){
|
for(size_t i = 0; i != vs2; ++i){
|
||||||
initvec2[i] = i;
|
initvec2[i] = i;
|
||||||
|
@ -118,8 +120,8 @@ namespace {
|
||||||
std::shared_ptr<SRange> sr2ptr;
|
std::shared_ptr<SRange> sr2ptr;
|
||||||
std::shared_ptr<MRange> mrptr;
|
std::shared_ptr<MRange> mrptr;
|
||||||
|
|
||||||
std::vector<double> cv1;
|
vector<double> cv1;
|
||||||
std::vector<double> cv2;
|
vector<double> cv2;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
class OpTest_Spin
|
class OpTest_Spin
|
||||||
|
@ -132,15 +134,16 @@ namespace {
|
||||||
typedef SpinRF SRF;
|
typedef SpinRF SRF;
|
||||||
typedef SpinRange SR;
|
typedef SpinRange SR;
|
||||||
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 = 3000;
|
||||||
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]);
|
||||||
|
@ -151,18 +154,18 @@ namespace {
|
||||||
cr = std::dynamic_pointer_cast<CR>(cf.create());
|
cr = std::dynamic_pointer_cast<CR>(cf.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
void contract();
|
void contract();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<double> data;
|
vector<double> data;
|
||||||
std::shared_ptr<SR> sr;
|
std::shared_ptr<SR> sr;
|
||||||
std::shared_ptr<CR> cr;
|
std::shared_ptr<CR> cr;
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
|
@ -171,36 +174,35 @@ namespace {
|
||||||
auto beta = MAT::getIndex<SR>();
|
auto beta = MAT::getIndex<SR>();
|
||||||
auto gamma = MAT::getIndex<SR>();
|
auto gamma = MAT::getIndex<SR>();
|
||||||
auto delta = MAT::getIndex<SR>();
|
auto delta = MAT::getIndex<SR>();
|
||||||
auto deltap = MAT::getIndex<SR>();
|
//auto deltap = MAT::getIndex<SR>();
|
||||||
|
auto deltap = MAT::getIndex<GenSingleRange<size_t,SpaceType::NONE,1>>();
|
||||||
|
|
||||||
auto mix = MAT::mkMIndex( alpha, beta, gamma, jj );
|
auto mix = MAT::mkMIndex( jj, alpha, beta, gamma );
|
||||||
|
|
||||||
std::clock_t begin = std::clock();
|
|
||||||
//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);
|
|
||||||
//}
|
|
||||||
std::clock_t end = std::clock();
|
|
||||||
std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
std::vector<double> vres(4*4*os);
|
vector<double> vres(4*4*os);
|
||||||
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 = d*4 + p;
|
const size_t tidx = d*4 + p;
|
||||||
vres[tidx] = 0.;
|
vres[tidx] = 0.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::clock_t begin2 = std::clock();
|
auto begin2 = std::chrono::system_clock::now();
|
||||||
for(size_t j = 0; j != os; ++j) {
|
double* vrptr = vres.data();
|
||||||
for(size_t i = 0; i != os; ++i){
|
double* dptr = data.data();
|
||||||
for(size_t a = 0; a != 4; ++a){
|
for(size_t i = 0; i != os; ++i){
|
||||||
for(size_t b = 0; b != 4; ++b){
|
for(size_t d = 0; d != 4; ++d){
|
||||||
for(size_t c = 0; c != 4; ++c){
|
for(size_t j = 0; j != os; ++j) {
|
||||||
for(size_t d = 0; d != 4; ++d){
|
for(size_t a = 0; a != 4; ++a){
|
||||||
for(size_t p = 0; p != 4; ++p){
|
for(size_t b = 0; b != 4; ++b){
|
||||||
const size_t tidx = i*4*4 + d*4 + p;
|
for(size_t c = 0; c != 4; ++c){
|
||||||
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 tidx = i*4*4 + d*4;
|
||||||
vres[tidx] += data[sidx];
|
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;
|
||||||
|
double* xvrptr = vrptr + tidx;
|
||||||
|
double* xdptr = dptr + sidx;
|
||||||
|
#pragma omp simd aligned(xvrptr, xdptr: 32)
|
||||||
|
for(int p = 0; p < 4; p++){
|
||||||
|
xvrptr[p] += xdptr[p];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +210,19 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::clock_t end2 = std::clock();
|
auto end2 = std::chrono::system_clock::now();
|
||||||
|
std::cout << "vector - for loop time: " << std::chrono::duration<double>(end2-begin2).count()
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
auto begin = std::chrono::system_clock::now();
|
||||||
|
//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);
|
||||||
|
tcast<v256>(res1)(ii ,delta, deltap).par() += tcast<v256>(ma)(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(mix);
|
||||||
|
//}
|
||||||
|
auto end = std::chrono::system_clock::now();
|
||||||
|
std::cout << "MultiArray time: " << std::chrono::duration<double>(end-begin).count()
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
assert( xround(res1.at(mkts(0,0,0))) == xround(vres[0]) );
|
assert( xround(res1.at(mkts(0,0,0))) == xround(vres[0]) );
|
||||||
assert( xround(res1.at(mkts(0,0,1))) == xround(vres[1]) );
|
assert( xround(res1.at(mkts(0,0,1))) == xround(vres[1]) );
|
||||||
|
@ -230,9 +244,9 @@ namespace {
|
||||||
assert( xround(res1.at(mkts(0,3,2))) == xround(vres[14]) );
|
assert( xround(res1.at(mkts(0,3,2))) == xround(vres[14]) );
|
||||||
assert( xround(res1.at(mkts(0,3,3))) == xround(vres[15]) );
|
assert( xround(res1.at(mkts(0,3,3))) == xround(vres[15]) );
|
||||||
|
|
||||||
std::cout << "std::vector - for loop time: " << static_cast<double>( end2 - begin2 ) / CLOCKS_PER_SEC
|
std::cout << "ratio: "
|
||||||
<< std::endl;
|
<< std::chrono::duration<double>(end-begin).count() / std::chrono::duration<double>(end2-begin2).count()
|
||||||
std::cout << "ratio: " << static_cast<double>( end - begin ) / static_cast<double>( end2 - begin2 ) << std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
#ifndef ONLY_SPIN
|
#ifndef ONLY_SPIN
|
||||||
void OpTest_Performance::PCheck()
|
void OpTest_Performance::PCheck()
|
||||||
|
@ -254,7 +268,7 @@ namespace {
|
||||||
std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC
|
std::cout << "MultiArray time: " << static_cast<double>( end - begin ) / CLOCKS_PER_SEC
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
std::vector<double> res2(vs1*vs2);
|
vector<double> res2(vs1*vs2);
|
||||||
std::clock_t begin2 = std::clock();
|
std::clock_t begin2 = std::clock();
|
||||||
|
|
||||||
for(size_t i = 0; i != vs2; ++i){
|
for(size_t i = 0; i != vs2; ++i){
|
||||||
|
@ -264,7 +278,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::clock_t end2 = std::clock();
|
std::clock_t end2 = std::clock();
|
||||||
std::cout << "std::vector - for loop time: " << static_cast<double>( end2 - begin2 ) / CLOCKS_PER_SEC
|
std::cout << "vector - for loop time: " << static_cast<double>( end2 - begin2 ) / CLOCKS_PER_SEC
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
std::cout << "ratio: " << static_cast<double>( end - begin ) / static_cast<double>( end2 - begin2 ) << std::endl;
|
std::cout << "ratio: " << static_cast<double>( end - begin ) / static_cast<double>( end2 - begin2 ) << std::endl;
|
||||||
|
|
|
@ -31,15 +31,15 @@ namespace {
|
||||||
template <class Factory, typename T>
|
template <class Factory, typename T>
|
||||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
||||||
{
|
{
|
||||||
std::vector<T> tmp = ilist;
|
vector<T> tmp = ilist;
|
||||||
auto nptr = std::make_shared<Factory>( tmp );
|
auto nptr = std::make_shared<Factory>( tmp );
|
||||||
fptr = nptr;
|
fptr = nptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Factory, typename T>
|
template <class Factory, typename T>
|
||||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::vector<T>& ilist)
|
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, vector<T>& ilist)
|
||||||
{
|
{
|
||||||
std::vector<T> tmp = ilist;
|
vector<T> tmp = ilist;
|
||||||
auto nptr = std::make_shared<Factory>( tmp );
|
auto nptr = std::make_shared<Factory>( tmp );
|
||||||
fptr = nptr;
|
fptr = nptr;
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,8 @@ namespace {
|
||||||
|
|
||||||
std::shared_ptr<RangeFactoryBase> rfbptr;
|
std::shared_ptr<RangeFactoryBase> rfbptr;
|
||||||
std::shared_ptr<SRange> srptr;
|
std::shared_ptr<SRange> srptr;
|
||||||
std::vector<double> v1 = { 2.917, 9.436, 0.373, 7.192 };
|
vector<double> v1 = { 2.917, 9.436, 0.373, 7.192 };
|
||||||
std::vector<double> v2 = { 8.870, 4.790, 8.215, 5.063 };
|
vector<double> v2 = { 8.870, 4.790, 8.215, 5.063 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpTest_MDim : public ::testing::Test
|
class OpTest_MDim : public ::testing::Test
|
||||||
|
@ -151,11 +151,11 @@ namespace {
|
||||||
std::shared_ptr<SRange> sr4ptr;
|
std::shared_ptr<SRange> sr4ptr;
|
||||||
std::shared_ptr<MRange> mr1ptr;
|
std::shared_ptr<MRange> mr1ptr;
|
||||||
std::shared_ptr<MRange> mr2ptr;
|
std::shared_ptr<MRange> mr2ptr;
|
||||||
std::vector<double> v1 = { 2.917, 9.436, 0.373 };
|
vector<double> v1 = { 2.917, 9.436, 0.373 };
|
||||||
std::vector<double> v2 = { 8.870, 4.790 };
|
vector<double> v2 = { 8.870, 4.790 };
|
||||||
std::vector<double> v3 = { 0.353, 4.005, 1.070, 2.310, 9.243, 2.911 };
|
vector<double> v3 = { 0.353, 4.005, 1.070, 2.310, 9.243, 2.911 };
|
||||||
std::vector<double> v4 = { 1.470, 2.210 };
|
vector<double> v4 = { 1.470, 2.210 };
|
||||||
std::vector<double> v5 = { 30.932, -33.693, -26.205, -15.504, 21.227, 17.829,
|
vector<double> v5 = { 30.932, -33.693, -26.205, -15.504, 21.227, 17.829,
|
||||||
-14.364, -1.868, -25.703, 13.836, 23.563, 41.339 };
|
-14.364, -1.868, -25.703, 13.836, 23.563, 41.339 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,10 +184,10 @@ namespace {
|
||||||
std::shared_ptr<SRange> sr2ptr;
|
std::shared_ptr<SRange> sr2ptr;
|
||||||
std::shared_ptr<SRange> sr3ptr;
|
std::shared_ptr<SRange> sr3ptr;
|
||||||
|
|
||||||
std::vector<double> v1 = { 2.917, 9.436, 0.373, 0.353, 4.005, 1.070,
|
vector<double> v1 = { 2.917, 9.436, 0.373, 0.353, 4.005, 1.070,
|
||||||
-14.364, -1.868, -25.703, 13.836, 23.563, 41.339 };
|
-14.364, -1.868, -25.703, 13.836, 23.563, 41.339 };
|
||||||
|
|
||||||
std::vector<double> v2 = { 0.353, 4.005, 1.070, 2.310, 9.243, 2.911 };
|
vector<double> v2 = { 0.353, 4.005, 1.070, 2.310, 9.243, 2.911 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ namespace {
|
||||||
std::shared_ptr<SRange> sr1ptr;
|
std::shared_ptr<SRange> sr1ptr;
|
||||||
std::shared_ptr<SRange> sr2ptr;
|
std::shared_ptr<SRange> sr2ptr;
|
||||||
std::shared_ptr<MpRange> mpr1ptr;
|
std::shared_ptr<MpRange> mpr1ptr;
|
||||||
std::vector<double> v1 = { -31.71, -77.16, -18.81,
|
vector<double> v1 = { -31.71, -77.16, -18.81,
|
||||||
-67.06, 72.31, -54.48,
|
-67.06, 72.31, -54.48,
|
||||||
-50.91, -11.62, -59.57,
|
-50.91, -11.62, -59.57,
|
||||||
-42.53, 80.41, 6.35 };
|
-42.53, 80.41, 6.35 };
|
||||||
|
@ -241,14 +241,14 @@ namespace {
|
||||||
OpTest_Performance()
|
OpTest_Performance()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<size_t> initvec1(vs1);
|
vector<size_t> initvec1(vs1);
|
||||||
cv1.resize(vs1);
|
cv1.resize(vs1);
|
||||||
for(size_t i = 0; i != vs1; ++i){
|
for(size_t i = 0; i != vs1; ++i){
|
||||||
initvec1[i] = i;
|
initvec1[i] = i;
|
||||||
cv1[i] = sqrt( static_cast<double>(i)*0.53 );
|
cv1[i] = sqrt( static_cast<double>(i)*0.53 );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<size_t> initvec2(vs2);
|
vector<size_t> initvec2(vs2);
|
||||||
cv2.resize(vs2*vs1);
|
cv2.resize(vs2*vs1);
|
||||||
for(size_t i = 0; i != vs2; ++i){
|
for(size_t i = 0; i != vs2; ++i){
|
||||||
initvec2[i] = i;
|
initvec2[i] = i;
|
||||||
|
@ -277,8 +277,8 @@ namespace {
|
||||||
std::shared_ptr<SRange> sr2ptr;
|
std::shared_ptr<SRange> sr2ptr;
|
||||||
std::shared_ptr<MRange> mrptr;
|
std::shared_ptr<MRange> mrptr;
|
||||||
|
|
||||||
std::vector<double> cv1;
|
vector<double> cv1;
|
||||||
std::vector<double> cv2;
|
vector<double> cv2;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpTest_Spin : public ::testing::Test
|
class OpTest_Spin : public ::testing::Test
|
||||||
|
@ -303,7 +303,7 @@ namespace {
|
||||||
sr = std::dynamic_pointer_cast<SR>(f.create());
|
sr = std::dynamic_pointer_cast<SR>(f.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> data;
|
vector<double> data;
|
||||||
std::shared_ptr<SR> sr;
|
std::shared_ptr<SR> sr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -337,8 +337,8 @@ namespace {
|
||||||
std::shared_ptr<SR> sr1ptr;
|
std::shared_ptr<SR> sr1ptr;
|
||||||
std::shared_ptr<SR> sr2ptr;
|
std::shared_ptr<SR> sr2ptr;
|
||||||
|
|
||||||
std::vector<double> mv1;
|
vector<double> mv1;
|
||||||
std::vector<double> mv2;
|
vector<double> mv2;
|
||||||
|
|
||||||
double vcontract(size_t i)
|
double vcontract(size_t i)
|
||||||
{
|
{
|
||||||
|
@ -458,7 +458,7 @@ namespace {
|
||||||
|
|
||||||
res2(delta, deltap).par() += ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(alpha).c(beta).c(gamma);
|
res2(delta, deltap).par() += ma(delta, alpha, alpha, beta, beta, gamma, gamma, deltap).c(alpha).c(beta).c(gamma);
|
||||||
|
|
||||||
std::vector<double> vres(4*4);
|
vector<double> vres(4*4);
|
||||||
|
|
||||||
std::clock_t begin2 = std::clock();
|
std::clock_t begin2 = std::clock();
|
||||||
for(size_t d = 0; d != 4; ++d){
|
for(size_t d = 0; d != 4; ++d){
|
||||||
|
@ -517,7 +517,7 @@ namespace {
|
||||||
EXPECT_EQ( xround(res2.at(mkts(3,2))), xround(vres[14]) );
|
EXPECT_EQ( xround(res2.at(mkts(3,2))), xround(vres[14]) );
|
||||||
EXPECT_EQ( xround(res2.at(mkts(3,3))), xround(vres[15]) );
|
EXPECT_EQ( xround(res2.at(mkts(3,3))), xround(vres[15]) );
|
||||||
|
|
||||||
std::cout << "std::vector - for loop time: " << static_cast<double>( end2 - begin2 ) / CLOCKS_PER_SEC
|
std::cout << "vector - for loop time: " << static_cast<double>( end2 - begin2 ) / CLOCKS_PER_SEC
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "ratio: " << static_cast<double>( end - begin ) / static_cast<double>( end2 - begin2 ) << std::endl;
|
std::cout << "ratio: " << static_cast<double>( end - begin ) / static_cast<double>( end2 - begin2 ) << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -543,7 +543,7 @@ namespace {
|
||||||
MultiArray<double,SRange,SRange,SRange> ma1(sr1ptr, sr2ptr, sr3ptr, v1);
|
MultiArray<double,SRange,SRange,SRange> ma1(sr1ptr, sr2ptr, sr3ptr, v1);
|
||||||
MultiArray<double,SRange,SRange> ma2(sr3ptr, sr2ptr, v2);
|
MultiArray<double,SRange,SRange> ma2(sr3ptr, sr2ptr, v2);
|
||||||
|
|
||||||
SubRangeFactory<SRange> subf(sr2ptr, std::vector<size_t>({0,2}));
|
SubRangeFactory<SRange> subf(sr2ptr, vector<size_t>({0,2}));
|
||||||
auto subptr = MAT::createExplicit(subf);
|
auto subptr = MAT::createExplicit(subf);
|
||||||
|
|
||||||
MultiArray<double,SRange,SRange> res(sr3ptr,sr1ptr,0.);
|
MultiArray<double,SRange,SRange> res(sr3ptr,sr1ptr,0.);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace {
|
||||||
template <class Factory, typename T>
|
template <class Factory, typename T>
|
||||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
||||||
{
|
{
|
||||||
std::vector<T> tmp = ilist;
|
vector<T> tmp = ilist;
|
||||||
auto nptr = std::make_shared<Factory>( tmp );
|
auto nptr = std::make_shared<Factory>( tmp );
|
||||||
fptr = nptr;
|
fptr = nptr;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ namespace {
|
||||||
|
|
||||||
TEST_F(AnonymousTest, ToString1)
|
TEST_F(AnonymousTest, ToString1)
|
||||||
{
|
{
|
||||||
std::vector<char> vv = sr1ptr->data();
|
vector<char> vv = sr1ptr->data();
|
||||||
const char* dp = vv.data();
|
const char* dp = vv.data();
|
||||||
auto ff = createRangeFactory(&dp);
|
auto ff = createRangeFactory(&dp);
|
||||||
auto ss = std::dynamic_pointer_cast<SRange>( ff->create() );
|
auto ss = std::dynamic_pointer_cast<SRange>( ff->create() );
|
||||||
|
@ -183,9 +183,9 @@ namespace {
|
||||||
auto sr = std::dynamic_pointer_cast<SpinRange>( srf.create() );
|
auto sr = std::dynamic_pointer_cast<SpinRange>( srf.create() );
|
||||||
auto nr = std::dynamic_pointer_cast<NameRange>( nrf.create() );
|
auto nr = std::dynamic_pointer_cast<NameRange>( nrf.create() );
|
||||||
|
|
||||||
std::vector<char> cv = cr->data();
|
vector<char> cv = cr->data();
|
||||||
std::vector<char> sv = sr->data();
|
vector<char> sv = sr->data();
|
||||||
std::vector<char> nv = nr->data();
|
vector<char> nv = nr->data();
|
||||||
const char* cp = cv.data();
|
const char* cp = cv.data();
|
||||||
const char* sp = sv.data();
|
const char* sp = sv.data();
|
||||||
const char* np = nv.data();
|
const char* np = nv.data();
|
||||||
|
@ -212,7 +212,7 @@ namespace {
|
||||||
|
|
||||||
TEST_F(AnonymousTest, ToStringMulti)
|
TEST_F(AnonymousTest, ToStringMulti)
|
||||||
{
|
{
|
||||||
std::vector<char> vv = m3rptr->data();
|
vector<char> vv = m3rptr->data();
|
||||||
const char* dp = vv.data();
|
const char* dp = vv.data();
|
||||||
|
|
||||||
auto ff2 = std::dynamic_pointer_cast<M3RF>( createRangeFactory(&dp) );
|
auto ff2 = std::dynamic_pointer_cast<M3RF>( createRangeFactory(&dp) );
|
||||||
|
@ -235,7 +235,7 @@ namespace {
|
||||||
{
|
{
|
||||||
AnonymousRangeFactory arf2(sr1ptr,m3rptr,sr2ptr);
|
AnonymousRangeFactory arf2(sr1ptr,m3rptr,sr2ptr);
|
||||||
auto ar = std::dynamic_pointer_cast<AnonymousRange>( arf2.create() );
|
auto ar = std::dynamic_pointer_cast<AnonymousRange>( arf2.create() );
|
||||||
std::vector<char> vv = ar->data();
|
vector<char> vv = ar->data();
|
||||||
const char* dp = vv.data();
|
const char* dp = vv.data();
|
||||||
|
|
||||||
auto ff2 = std::dynamic_pointer_cast<AnonymousRangeFactory>( createRangeFactory(&dp) );
|
auto ff2 = std::dynamic_pointer_cast<AnonymousRangeFactory>( createRangeFactory(&dp) );
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace {
|
||||||
template <class Factory, typename T>
|
template <class Factory, typename T>
|
||||||
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
void swapFactory(std::shared_ptr<RangeFactoryBase>& fptr, std::initializer_list<T> ilist)
|
||||||
{
|
{
|
||||||
std::vector<T> tmp = ilist;
|
vector<T> tmp = ilist;
|
||||||
auto nptr = std::make_shared<Factory>( tmp );
|
auto nptr = std::make_shared<Factory>( tmp );
|
||||||
fptr = nptr;
|
fptr = nptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue