WIP: fix compile errors regarding first extension operation test

This commit is contained in:
Christian Zimmermann 2023-06-12 00:00:20 +02:00
parent 1919d373df
commit 717e4a6548
6 changed files with 76 additions and 16 deletions

View file

@ -7,6 +7,12 @@
namespace CNORXZ
{
template <SizeT I>
UPos CIndex::stepSize(const IndexId<I>& id) const
{
return UPos(id == this->id() ? 1 : 0);
}
template <class Index>
decltype(auto) CIndex::reformat(const Sptr<Index>& ind) const
{

View file

@ -38,7 +38,9 @@ namespace CNORXZ
SizeT dim() const; // = 1
Sptr<RangeType> range() const;
UPos stepSize(const IndexId<0>& id) const;
template <SizeT I>
UPos stepSize(const IndexId<I>& id) const;
String stringMeta() const;
SizeT meta() const;

View file

@ -629,13 +629,26 @@ namespace CNORXZ
* Traits and Helper-Classes *
*********************************/
template <SizeT N, class BPosT, class OPosT>
decltype(auto) mkEPos(const BPosT& a, const OPosT& b)
template <class BPosT, class OPosT, SizeT N>
decltype(auto) MkEPos<BPosT,OPosT,N>::mk(const BPosT& a, const OPosT& b)
{
return mkiEPos(a, b, std::make_index_sequence<N>{});
}
template <SizeT N, class BPosT, class OPosT, SizeT... Is>
template <class BPosT, class NPosT, class OPosT, SizeT N>
decltype(auto) MkEPos<MPos<BPosT,NPosT>,OPosT,N>::mk(const MPos<BPosT,NPosT>& a, const OPosT& b)
{
const BPosT& ax = static_cast<const BPosT&>(a);
return MPos<decltype(mkEPos<N>(ax,b)),NPosT>(mkEPos<N>(ax,b), a.next());
}
template <SizeT N, class BPosT, class OPosT>
decltype(auto) mkEPos(const BPosT& a, const OPosT& b)
{
return MkEPos<BPosT,OPosT,N>::mk(a,b);
}
template <class BPosT, class OPosT, SizeT... Is>
decltype(auto) mkiEPos(const BPosT& a, const OPosT& b, std::index_sequence<Is...> is)
{
return EPos<BPosT,decltype(b*SPos<Is>())...>(a, b*SPos<Is>()...);

View file

@ -308,7 +308,7 @@ namespace CNORXZ
template <class PosT>
struct epos_size
{
static constexpr SizeT value = 0;
static constexpr SizeT value = 1;
};
template <class OPosT1, class OPosT2, class... OPosTs>
@ -339,10 +339,22 @@ namespace CNORXZ
template <class PosT> struct pos_type_is_consecutive { CXZ_CVAL_TRUE; };
template <class BPosT, class OPosT, SizeT N>
struct MkEPos
{
static decltype(auto) mk(const BPosT& a, const OPosT& b);
};
template <class BPosT, class NPosT, class OPosT, SizeT N>
struct MkEPos<MPos<BPosT,NPosT>,OPosT,N>
{
static decltype(auto) mk(const MPos<BPosT,NPosT>& a, const OPosT& b);
};
template <SizeT N, class BPosT, class OPosT>
decltype(auto) mkEPos(const BPosT& a, const OPosT& b);
template <SizeT N, class BPosT, class OPosT, SizeT... Is>
template <class BPosT, class OPosT, SizeT... Is>
decltype(auto) mkiEPos(const BPosT& a, const OPosT& b, std::index_sequence<Is...> is);
/**************************************************
@ -376,7 +388,9 @@ namespace CNORXZ
template <class BPosT, class... OPosTs> struct is_static_pos_type<EPos<BPosT,OPosTs...>>
{ static constexpr bool value = is_static_pos_type<BPosT>::value and (is_static_pos_type<OPosTs>::value and ...); };
template <class BPosT, class... OPosTs> struct is_epos_type<EPos<BPosT,OPosTs...>> { CXZ_CVAL_TRUE; };
template <class BPosT, class NPosT> struct is_epos_type<MPos<BPosT,NPosT>> { static constexpr bool value = is_epos_type<BPosT>::value or is_epos_type<NPosT>::value; };
template <class BPosT, class NPosT>
struct static_pos_size<MPos<BPosT,NPosT>>
{
@ -388,7 +402,13 @@ namespace CNORXZ
{
static constexpr SizeT value = sizeof...(OPosTs);
};
template <class BPosT, class NPosT>
struct epos_size<MPos<BPosT,NPosT>>
{
static constexpr SizeT value = epos_size<BPosT>::value * epos_size<NPosT>::value;
};
template <class BPosT, class... OPosTs>
struct pos_type_is_consecutive<EPos<BPosT,OPosTs...>>
{

View file

@ -87,11 +87,6 @@ namespace CNORXZ
return mRangePtr;
}
UPos CIndex::stepSize(const IndexId<0>& id) const
{
return UPos(id == this->id() ? 1 : 0);
}
String CIndex::stringMeta() const
{
return toString(IB::mPos);

View file

@ -70,7 +70,7 @@ namespace
//mCC1j2i = mindexPtr(mCI1j*mCI2i);
mOC1i1j.init(mCC1i1j);
mOR1j1i.init(mData11.data(), mCC1j1i);
mOR1i1j.init(mData11.data(), mCC1i1j);
mOR1i1j.init(mData12.data(), mCC1i1j);
}
SizeT mSize1;
@ -120,7 +120,7 @@ namespace
mCC1j1i = mindexPtr(eplex<4,1,2>(mCI1j)*mCI1i);
mOC1i1j.init(mCC1i1j);
mOR1j1i.init(mData11.data(), mCC1j1i);
mOR1i1j.init(mData11.data(), mCC1i1j);
mOR1i1j.init(mData12.data(), mCC1i1j);
}
SizeT mSize1;
@ -230,4 +230,28 @@ namespace
}
}
}
TEST_F(OpCont_CR_CR_Test2, Assignment)
{
mOC1i1j = mOR1j1i;
for(SizeT i = 0; i != mCI1i->pmax().val(); ++i){
for(SizeT j = 0; j != mCI1j->pmax().val(); ++j){
const SizeT jS = mCI1j->pmax().val();
const SizeT iS = mCI1i->pmax().val();
EXPECT_EQ(mOC1i1j.data()[i*jS+j], mOR1j1i.data()[j*iS+i]);
}
}
}
TEST_F(OpCont_CR_CR_Test2, Multiply)
{
mOC1i1j = mOR1j1i * mOR1i1j;
for(SizeT i = 0; i != mCI1i->pmax().val(); ++i){
for(SizeT j = 0; j != mCI1j->pmax().val(); ++j){
const SizeT jS = mCI1j->pmax().val();
const SizeT iS = mCI1i->pmax().val();
EXPECT_EQ(mOC1i1j.data()[i*jS+j], mOR1j1i.data()[j*iS+i] * mOR1i1j.data()[i*jS+j]);
}
}
}
}