WIP: EIndex tests

This commit is contained in:
Christian Zimmermann 2023-06-11 03:06:30 +02:00
parent 59a9236c04
commit 811e955491
3 changed files with 86 additions and 4 deletions

View file

@ -35,17 +35,45 @@ namespace CNORXZ
} }
template <SizeT L, typename MetaType, SizeT S> template <SizeT L, typename MetaType, SizeT S>
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>,L>& i) decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i)
{ {
return eindexPtr( lindexPtr<L>( i ) ); return eindexPtr( lindexPtr<L>( i ) );
} }
template <typename MetaType, SizeT S, SizeT L> template <typename MetaType, SizeT S, SizeT L>
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>,L>& i, CSizeT<L> l) decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i, CSizeT<L> l)
{ {
return eindexPtr<l>( i ); return eindexPtr<l>( i );
} }
template <SizeT S, SizeT L1, SizeT L2, class Index>
decltype(auto) eplex(const Sptr<Index>& i)
{
const SizeT isize = i->lmax().val()
CXZ_ASSERT(isize % S == 0, "index max (= " << isize
<< " ) not dividable by extension size = " << S);
auto ci = std::make_shared<CIndex>( CRangeFactory(isize/L).create() );
auto ei = eindexPtr<L1>( std::make_shared<SIndex<S>>( SRangeFactory<S>().create() ) );
if constexpr(L2 == 0){
return spackp(ci,ei);
}
else {
return spackp(lindex<L2>(ci),ei);
}
}
template <class Index, SizeT S, SizeT L>
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L> l)
{
return eplex<s,l,0>(i);
}
template <class Index, SizeT S, SizeT L1, SizeT L2>
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L1> l1, CSizeT<L2> l2)
{
return eplex<s,l1,l2>(i);
}
} }
#endif #endif

View file

@ -35,10 +35,19 @@ namespace CNORXZ
decltype(auto) eindexPtr(const Sptr<LIndex<SIndex<MetaT,S>,L>>& i); decltype(auto) eindexPtr(const Sptr<LIndex<SIndex<MetaT,S>,L>>& i);
template <SizeT L, typename MetaType, SizeT S> template <SizeT L, typename MetaType, SizeT S>
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>,L>& i); decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i);
template <typename MetaType, SizeT S, SizeT L> template <typename MetaType, SizeT S, SizeT L>
decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>,L>& i, CSizeT<L> l); decltype(auto) eindexPtr(const Sptr<SIndex<MetaT,S>>& i, CSizeT<L> l);
template <SizeT S, SizeT L1, SizeT L2, class Index>
decltype(auto) eplex(const Sptr<Index>& i);
template <class Index, SizeT S, SizeT L>
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L> l);
template <class Index, SizeT S, SizeT L1, SizeT L2>
decltype(auto) eplex(const Sptr<Index>& i, CSizeT<S> s, CSizeT<L1> l1, CSizeT<L2> l2);
} }

View file

@ -94,6 +94,51 @@ namespace
//COpRoot<double,MCCI> mOR1i2i; //COpRoot<double,MCCI> mOR1i2i;
}; };
class OpCont_CR_CR_Test2 : public ::testing::Test
{
protected:
typedef MIndex<CIndex,LIndex<CIndex,2>,EIndex<SizeT,4,1>> MCCI;
OpCont_CR_CR_Test()
{
mSize1 = 12;
mSize2 = 11;
SizeT off = 20;
mData1 = Numbers::get(off, mSize1);
mData2 = Numbers::get(off += mSize1 , mSize2);
mData11 = Numbers::get(off += mSize2, mSize1*mSize1);
mData12 = Numbers::get(off += mSize1*mSize1, mSize1*mSize2);
auto cr1 = CRangeFactory(mSize1).create();
auto cr2 = CRangeFactory(mSize2).create();
mCI1i = std::make_shared<CIndex>(cr1);
mCI1j = std::make_shared<CIndex>(cr1);
mCI2i = std::make_shared<CIndex>(cr2);
mCI2j = std::make_shared<CIndex>(cr2);
mCC1i1j = mindexPtr(mCI1i*eplex(mCI1j,4,1,2));
mCC1j1i = mindexPtr(eplex(mCI1j,4,1,2)*mCI1i);
mOC1i1j.init(mCC1i1j);
mOR1j1i.init(mData11.data(), mCC1j1i);
mOR1i1j.init(mData11.data(), mCC1i1j);
}
SizeT mSize1;
SizeT mSize2;
Vector<Double> mData1;
Vector<Double> mData2;
Vector<Double> mData11;
Vector<Double> mData12;
Sptr<CIndex> mCI1i;
Sptr<CIndex> mCI1j;
Sptr<CIndex> mCI2i;
Sptr<CIndex> mCI2j;
Sptr<MCCI> mCC1i1j;
Sptr<MCCI> mCC1j1i;
OpCont<double,MCCI> mOC1i1j;
COpRoot<double,MCCI> mOR1j1i;
COpRoot<double,MCCI> mOR1i1j;
};
TEST_F(OpCont_CR_Test, Basics) TEST_F(OpCont_CR_Test, Basics)
{ {
EXPECT_EQ(mOp2.data(), mData1.data()); EXPECT_EQ(mOp2.data(), mData1.data());