diff --git a/src/include/ranges/crange.cc.h b/src/include/ranges/crange.cc.h index 8674476..3410ac7 100644 --- a/src/include/ranges/crange.cc.h +++ b/src/include/ranges/crange.cc.h @@ -7,6 +7,12 @@ namespace CNORXZ { + template + UPos CIndex::stepSize(const IndexId& id) const + { + return UPos(id == this->id() ? 1 : 0); + } + template decltype(auto) CIndex::reformat(const Sptr& ind) const { diff --git a/src/include/ranges/crange.h b/src/include/ranges/crange.h index 71302af..f9adbad 100644 --- a/src/include/ranges/crange.h +++ b/src/include/ranges/crange.h @@ -38,7 +38,9 @@ namespace CNORXZ SizeT dim() const; // = 1 Sptr range() const; - UPos stepSize(const IndexId<0>& id) const; + + template + UPos stepSize(const IndexId& id) const; String stringMeta() const; SizeT meta() const; diff --git a/src/include/xpr/pos_type.cc.h b/src/include/xpr/pos_type.cc.h index 8adf78a..4370e70 100644 --- a/src/include/xpr/pos_type.cc.h +++ b/src/include/xpr/pos_type.cc.h @@ -629,13 +629,26 @@ namespace CNORXZ * Traits and Helper-Classes * *********************************/ - template - decltype(auto) mkEPos(const BPosT& a, const OPosT& b) + template + decltype(auto) MkEPos::mk(const BPosT& a, const OPosT& b) { return mkiEPos(a, b, std::make_index_sequence{}); } - template + template + decltype(auto) MkEPos,OPosT,N>::mk(const MPos& a, const OPosT& b) + { + const BPosT& ax = static_cast(a); + return MPos(ax,b)),NPosT>(mkEPos(ax,b), a.next()); + } + + template + decltype(auto) mkEPos(const BPosT& a, const OPosT& b) + { + return MkEPos::mk(a,b); + } + + template decltype(auto) mkiEPos(const BPosT& a, const OPosT& b, std::index_sequence is) { return EPos())...>(a, b*SPos()...); diff --git a/src/include/xpr/pos_type.h b/src/include/xpr/pos_type.h index b7eaa68..c345a53 100644 --- a/src/include/xpr/pos_type.h +++ b/src/include/xpr/pos_type.h @@ -308,7 +308,7 @@ namespace CNORXZ template struct epos_size { - static constexpr SizeT value = 0; + static constexpr SizeT value = 1; }; template @@ -339,10 +339,22 @@ namespace CNORXZ template struct pos_type_is_consecutive { CXZ_CVAL_TRUE; }; + template + struct MkEPos + { + static decltype(auto) mk(const BPosT& a, const OPosT& b); + }; + + template + struct MkEPos,OPosT,N> + { + static decltype(auto) mk(const MPos& a, const OPosT& b); + }; + template decltype(auto) mkEPos(const BPosT& a, const OPosT& b); - - template + + template decltype(auto) mkiEPos(const BPosT& a, const OPosT& b, std::index_sequence is); /************************************************** @@ -376,7 +388,9 @@ namespace CNORXZ template struct is_static_pos_type> { static constexpr bool value = is_static_pos_type::value and (is_static_pos_type::value and ...); }; template struct is_epos_type> { CXZ_CVAL_TRUE; }; - + + template struct is_epos_type> { static constexpr bool value = is_epos_type::value or is_epos_type::value; }; + template struct static_pos_size> { @@ -388,7 +402,13 @@ namespace CNORXZ { static constexpr SizeT value = sizeof...(OPosTs); }; - + + template + struct epos_size> + { + static constexpr SizeT value = epos_size::value * epos_size::value; + }; + template struct pos_type_is_consecutive> { diff --git a/src/lib/ranges/crange.cc b/src/lib/ranges/crange.cc index 42b7c66..0802b8b 100644 --- a/src/lib/ranges/crange.cc +++ b/src/lib/ranges/crange.cc @@ -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); diff --git a/src/tests/operation_unit_test.cc b/src/tests/operation_unit_test.cc index a8a4144..cc480db 100644 --- a/src/tests/operation_unit_test.cc +++ b/src/tests/operation_unit_test.cc @@ -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]); + } + } + } }