WIP: fix test errors...
This commit is contained in:
parent
717e4a6548
commit
bd6f15156b
5 changed files with 81 additions and 31 deletions
|
@ -33,6 +33,7 @@ namespace CNORXZ
|
||||||
{
|
{
|
||||||
constexpr SizeT N = epos_size<EPosT>::value;
|
constexpr SizeT N = epos_size<EPosT>::value;
|
||||||
static_assert(is_epos_type<EPosT>::value, "got non-epos-type");
|
static_assert(is_epos_type<EPosT>::value, "got non-epos-type");
|
||||||
|
static_assert(pos_type_is_consecutive<EPosT>::value, "no write access for non-consecutive");
|
||||||
if constexpr(pos_type_is_consecutive<EPosT>::value){
|
if constexpr(pos_type_is_consecutive<EPosT>::value){
|
||||||
return *reinterpret_cast<Consecutive<T,N>*>(d);
|
return *reinterpret_cast<Consecutive<T,N>*>(d);
|
||||||
}
|
}
|
||||||
|
@ -117,32 +118,32 @@ namespace CNORXZ
|
||||||
constexpr decltype(auto)
|
constexpr decltype(auto)
|
||||||
PlusCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
PlusCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x + y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x + y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U, SizeT N>
|
template <typename T, typename U, SizeT N>
|
||||||
constexpr decltype(auto)
|
constexpr decltype(auto)
|
||||||
PlusCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
PlusCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](auto& x, const auto& y) { return x += y; }, o, a );
|
return consecFuncA<N>( [](auto& x, const auto& y) { return x += y; }, o, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) PlusCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
constexpr decltype(auto) PlusCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x + y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x + y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) PlusCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
constexpr decltype(auto) PlusCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x + y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x + y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) PlusCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
constexpr decltype(auto) PlusCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](auto& x, const auto& y) { return x += y; }, o, a );
|
return consecFuncA<N>( [](auto& x, const auto& y) { return x += y; }, o, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
|
@ -152,31 +153,31 @@ namespace CNORXZ
|
||||||
template <typename T, typename U, SizeT N>
|
template <typename T, typename U, SizeT N>
|
||||||
constexpr decltype(auto) MinusCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
constexpr decltype(auto) MinusCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x - y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x - y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) MinusCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
constexpr decltype(auto) MinusCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x - y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x - y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) MinusCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
constexpr decltype(auto) MinusCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x - y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x - y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U, SizeT N>
|
template <typename T, typename U, SizeT N>
|
||||||
constexpr decltype(auto) MinusCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
constexpr decltype(auto) MinusCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](auto& x, const auto& y) { return x -= y; }, o, a );
|
return consecFuncA<N>( [](auto& x, const auto& y) { return x -= y; }, o, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) MinusCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
constexpr decltype(auto) MinusCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](auto& x, const auto& y) { return x -= y; }, o, a );
|
return consecFuncA<N>( [](auto& x, const auto& y) { return x -= y; }, o, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
|
@ -186,31 +187,31 @@ namespace CNORXZ
|
||||||
template <typename T, typename U, SizeT N>
|
template <typename T, typename U, SizeT N>
|
||||||
constexpr decltype(auto) MultipliesCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
constexpr decltype(auto) MultipliesCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x * y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x * y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) MultipliesCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
constexpr decltype(auto) MultipliesCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x * y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x * y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) MultipliesCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
constexpr decltype(auto) MultipliesCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x * y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x * y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U, SizeT N>
|
template <typename T, typename U, SizeT N>
|
||||||
constexpr decltype(auto) MultipliesCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
constexpr decltype(auto) MultipliesCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](const auto& x, const auto& y) { return x *= y; }, o, a );
|
return consecFuncA<N>( [](const auto& x, const auto& y) { return x *= y; }, o, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) MultipliesCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
constexpr decltype(auto) MultipliesCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](const auto& x, const auto& y) { return x *= y; }, o, a );
|
return consecFuncA<N>( [](const auto& x, const auto& y) { return x *= y; }, o, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
|
@ -220,31 +221,31 @@ namespace CNORXZ
|
||||||
template <typename T, typename U, SizeT N>
|
template <typename T, typename U, SizeT N>
|
||||||
constexpr decltype(auto) DividesCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
constexpr decltype(auto) DividesCC<T,U,N>::eval(const Consecutive<T,N>& a, const Consecutive<U,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x / y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x / y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) DividesCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
constexpr decltype(auto) DividesCX<T,X,N>::eval(const Consecutive<T,N>& a, const X& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x / y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x / y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) DividesCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
constexpr decltype(auto) DividesCX<T,X,N>::eval(const X& a, const Consecutive<T,N>& b)
|
||||||
{
|
{
|
||||||
return consecFunc( [](const auto& x, const auto& y) { return x / y; }, a, b );
|
return consecFunc<N>( [](const auto& x, const auto& y) { return x / y; }, a, b );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U, SizeT N>
|
template <typename T, typename U, SizeT N>
|
||||||
constexpr decltype(auto) DividesCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
constexpr decltype(auto) DividesCC<T,U,N>::aeval(Consecutive<T,N>& o, const Consecutive<U,N>& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](const auto& x, const auto& y) { return x /= y; }, o, a );
|
return consecFuncA<N>( [](const auto& x, const auto& y) { return x /= y; }, o, a );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename X, SizeT N>
|
template <typename T, typename X, SizeT N>
|
||||||
constexpr decltype(auto) DividesCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
constexpr decltype(auto) DividesCX<T,X,N>::aeval(Consecutive<T,N>& o, const X& a)
|
||||||
{
|
{
|
||||||
return consecFuncA( [](const auto& x, const auto& y) { return x /= y; }, o, a );
|
return consecFuncA<N>( [](const auto& x, const auto& y) { return x /= y; }, o, a );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,13 @@ namespace CNORXZ
|
||||||
struct Consecutive
|
struct Consecutive
|
||||||
{
|
{
|
||||||
T mD[N];
|
T mD[N];
|
||||||
|
Consecutive& operator=(const Consecutive& a)
|
||||||
|
{
|
||||||
|
iter<0,N>([&](auto i) { mD[i] = a.mD[i]; VCHECK(mD[i]); }, NoF{} );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Consecutive& operator=(Consecutive&& a) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -586,6 +586,37 @@ namespace CNORXZ
|
||||||
mP(os...)
|
mP(os...)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
template <class BPosT, class... OPosTs>
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) EPos<BPosT,OPosTs...>::operator+(const PosT& a) const
|
||||||
|
{
|
||||||
|
return iter<0,sizeof...(OPosTs)>
|
||||||
|
( [&](auto i) { return std::get<i>(mP); },
|
||||||
|
[&](const auto&... e) { return EPos<decltype(BPosT::operator+(a)),OPosTs...>
|
||||||
|
(BPosT::operator+(a),e...); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class BPosT, class... OPosTs>
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) EPos<BPosT,OPosTs...>::operator*(const PosT& a) const
|
||||||
|
{
|
||||||
|
return iter<0,sizeof...(OPosTs)>
|
||||||
|
( [&](auto i) { return std::get<i>(mP); },
|
||||||
|
[&](const auto&... e) { return EPos<decltype(BPosT::operator*(a)),OPosTs...>
|
||||||
|
(BPosT::operator*(a),e...); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class BPosT, class... OPosTs>
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) EPos<BPosT,OPosTs...>::operator()(const PosT& a) const
|
||||||
|
{
|
||||||
|
return iter<0,sizeof...(OPosTs)>
|
||||||
|
( [&](auto i) { return std::get<i>(mP); },
|
||||||
|
[&](const auto&... e) { return EPos<decltype(BPosT::operator()(a)),OPosTs...>
|
||||||
|
(BPosT::operator()(a),e...); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class BPosT, class... OPosTs>
|
template <class BPosT, class... OPosTs>
|
||||||
constexpr decltype(auto) EPos<BPosT,OPosTs...>::val() const
|
constexpr decltype(auto) EPos<BPosT,OPosTs...>::val() const
|
||||||
{
|
{
|
||||||
|
@ -635,11 +666,13 @@ namespace CNORXZ
|
||||||
return mkiEPos(a, b, std::make_index_sequence<N>{});
|
return mkiEPos(a, b, std::make_index_sequence<N>{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class BPosT, class NPosT, class OPosT, SizeT N>
|
template <class BPosT, class NPosT, class OPosT, class ONPosT, SizeT N>
|
||||||
decltype(auto) MkEPos<MPos<BPosT,NPosT>,OPosT,N>::mk(const MPos<BPosT,NPosT>& a, const OPosT& b)
|
decltype(auto) MkEPos<MPos<BPosT,NPosT>,MPos<OPosT,ONPosT>,N>::mk(const MPos<BPosT,NPosT>& a, const MPos<OPosT,ONPosT>& b)
|
||||||
{
|
{
|
||||||
const BPosT& ax = static_cast<const BPosT&>(a);
|
const BPosT& ax = static_cast<const BPosT&>(a);
|
||||||
return MPos<decltype(mkEPos<N>(ax,b)),NPosT>(mkEPos<N>(ax,b), a.next());
|
const OPosT& bx = static_cast<const OPosT&>(b);
|
||||||
|
return MPos<decltype(mkEPos<N>(ax,bx)),decltype(mkEPos<N>(a.next(),b.next()))>
|
||||||
|
(mkEPos<N>(ax,bx), mkEPos<N>(a.next(),b.next()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <SizeT N, class BPosT, class OPosT>
|
template <SizeT N, class BPosT, class OPosT>
|
||||||
|
|
|
@ -276,6 +276,15 @@ namespace CNORXZ
|
||||||
constexpr EPos(const BPosT& b, const OPosTs&... os);
|
constexpr EPos(const BPosT& b, const OPosTs&... os);
|
||||||
constexpr EPos(BPosT&& b, OPosTs&&... os);
|
constexpr EPos(BPosT&& b, OPosTs&&... os);
|
||||||
|
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) operator+(const PosT& a) const;
|
||||||
|
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) operator*(const PosT& a) const;
|
||||||
|
|
||||||
|
template <class PosT>
|
||||||
|
constexpr decltype(auto) operator()(const PosT& a) const;
|
||||||
|
|
||||||
constexpr decltype(auto) val() const;
|
constexpr decltype(auto) val() const;
|
||||||
constexpr decltype(auto) next() const;
|
constexpr decltype(auto) next() const;
|
||||||
|
|
||||||
|
@ -345,10 +354,10 @@ namespace CNORXZ
|
||||||
static decltype(auto) mk(const BPosT& a, const OPosT& b);
|
static decltype(auto) mk(const BPosT& a, const OPosT& b);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class BPosT, class NPosT, class OPosT, SizeT N>
|
template <class BPosT, class NPosT, class OPosT, class ONPosT, SizeT N>
|
||||||
struct MkEPos<MPos<BPosT,NPosT>,OPosT,N>
|
struct MkEPos<MPos<BPosT,NPosT>,MPos<OPosT,ONPosT>,N>
|
||||||
{
|
{
|
||||||
static decltype(auto) mk(const MPos<BPosT,NPosT>& a, const OPosT& b);
|
static decltype(auto) mk(const MPos<BPosT,NPosT>& a, const MPos<OPosT,ONPosT>& b);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <SizeT N, class BPosT, class OPosT>
|
template <SizeT N, class BPosT, class OPosT>
|
||||||
|
@ -406,7 +415,7 @@ namespace CNORXZ
|
||||||
template <class BPosT, class NPosT>
|
template <class BPosT, class NPosT>
|
||||||
struct epos_size<MPos<BPosT,NPosT>>
|
struct epos_size<MPos<BPosT,NPosT>>
|
||||||
{
|
{
|
||||||
static constexpr SizeT value = epos_size<BPosT>::value * epos_size<NPosT>::value;
|
static constexpr SizeT value = epos_size<BPosT>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class BPosT, class... OPosTs>
|
template <class BPosT, class... OPosTs>
|
||||||
|
|
|
@ -56,8 +56,8 @@ namespace
|
||||||
SizeT off = 20;
|
SizeT off = 20;
|
||||||
mData1 = Numbers::get(off, mSize1);
|
mData1 = Numbers::get(off, mSize1);
|
||||||
mData2 = Numbers::get(off += mSize1 , mSize2);
|
mData2 = Numbers::get(off += mSize1 , mSize2);
|
||||||
mData11 = Numbers::get(off += mSize2, mSize1*mSize1);
|
mData11 = Numbers::get(off += mSize2, mSize1*mSize2);
|
||||||
mData12 = Numbers::get(off += mSize1*mSize1, mSize1*mSize2);
|
mData12 = Numbers::get(off += mSize1*mSize2, mSize1*mSize2);
|
||||||
auto cr1 = CRangeFactory(mSize1).create();
|
auto cr1 = CRangeFactory(mSize1).create();
|
||||||
auto cr2 = CRangeFactory(mSize2).create();
|
auto cr2 = CRangeFactory(mSize2).create();
|
||||||
mCI1i = std::make_shared<CIndex>(cr1);
|
mCI1i = std::make_shared<CIndex>(cr1);
|
||||||
|
@ -108,8 +108,8 @@ namespace
|
||||||
SizeT off = 20;
|
SizeT off = 20;
|
||||||
mData1 = Numbers::get(off, mSize1);
|
mData1 = Numbers::get(off, mSize1);
|
||||||
mData2 = Numbers::get(off += mSize1 , mSize2);
|
mData2 = Numbers::get(off += mSize1 , mSize2);
|
||||||
mData11 = Numbers::get(off += mSize2, mSize1*mSize1);
|
mData11 = Numbers::get(off += mSize2, mSize1*mSize2);
|
||||||
mData12 = Numbers::get(off += mSize1*mSize1, mSize1*mSize2);
|
mData12 = Numbers::get(off += mSize1*mSize2, mSize1*mSize2);
|
||||||
auto cr1 = CRangeFactory(mSize1).create();
|
auto cr1 = CRangeFactory(mSize1).create();
|
||||||
auto cr2 = CRangeFactory(mSize2).create();
|
auto cr2 = CRangeFactory(mSize2).create();
|
||||||
mCI1i = std::make_shared<CIndex>(cr1);
|
mCI1i = std::make_shared<CIndex>(cr1);
|
||||||
|
|
Loading…
Reference in a new issue