various fixes + rindex: clear()

This commit is contained in:
Christian Zimmermann 2024-12-01 22:39:03 -08:00
parent 1743fd196a
commit cb8d854f88
6 changed files with 32 additions and 17 deletions

View file

@ -302,6 +302,10 @@ namespace CNORXZ
template <typename T, class IndexT> template <typename T, class IndexT>
class OpRoot; class OpRoot;
// definition: operation/op_types.h
template <class Index>
class PosOp;
// definition: operation/op_types.h // definition: operation/op_types.h
template <class F, class... Ops> template <class F, class... Ops>
class Operation; class Operation;

View file

@ -117,7 +117,7 @@ namespace CNORXZ
bool formatIsTrivial() const; bool formatIsTrivial() const;
/** @copydoc IndexInterface::xpr() */ /** @copydoc IndexInterface::xpr() */
COpRoot<SizeT,CIndex> xpr(const Sptr<CIndex>& _this) const; PosOp<CIndex> xpr(const Sptr<CIndex>& _this) const;
private: private:
Sptr<RangeType> mRangePtr; Sptr<RangeType> mRangePtr;

View file

@ -119,17 +119,9 @@ namespace CNORXZ
return *this; return *this;
} }
COpRoot<SizeT,CIndex> CIndex::xpr(const Sptr<CIndex>& _this) const PosOp<CIndex> CIndex::xpr(const Sptr<CIndex>& _this) const
{ {
// preliminary solution (TODO: implement xpr that simply returns PosT value): return posop(_this);
static Vector<SizeT> m;
if(m.size() < _this->lmax().val()){
m.resize(_this->lmax().val());
for(SizeT i = 0; i != m.size(); ++i) {
m[i] = i;
}
}
return coproot(m.data(), _this);
} }
RangePtr CIndex::prange(const CIndex& last) const RangePtr CIndex::prange(const CIndex& last) const

View file

@ -110,7 +110,10 @@ namespace CNORXZ
inline decltype(auto) YIndex::mkIFor(SizeT i, const DXpr<None>& xpr, NoF&& f) const inline decltype(auto) YIndex::mkIFor(SizeT i, const DXpr<None>& xpr, NoF&& f) const
{ {
if(i == mIs.size()-1){ if(i == mIs.size()){
return DXpr<None>(xpr);
}
else if(i == mIs.size()-1){
return mIs[i]->ifor( xpr, std::forward<NoF>(f) ); return mIs[i]->ifor( xpr, std::forward<NoF>(f) );
} }
else { else {
@ -335,12 +338,17 @@ namespace CNORXZ
const String blim = "["; const String blim = "[";
const String elim = "]"; const String elim = "]";
const String dlim = ","; const String dlim = ",";
if(mIs.size() == 0){
return blim + elim;
}
else {
return blim + return blim +
std::accumulate(std::next(mIs.all().begin()), mIs.all().end(), mIs[0]->stringMeta(), std::accumulate(std::next(mIs.all().begin()), mIs.all().end(), mIs[0]->stringMeta(),
[&](const auto& s, const auto& e) [&](const auto& s, const auto& e)
{ return s + dlim + e->stringMeta(); } ) + { return s + dlim + e->stringMeta(); } ) +
elim; elim;
} }
}
Vector<DType> YIndex::meta() const Vector<DType> YIndex::meta() const
{ {

View file

@ -249,6 +249,13 @@ namespace CNORXZ
setupBuffer(ai, required, *mA, mBuf, mMap, blocks); setupBuffer(ai, required, *mA, mBuf, mMap, blocks);
} }
template <typename T>
void RCArray<T>::clear() const
{
mBuf.resize(0);
mMap.resize(0);
}
/*==============+ /*==============+
| RArray | | RArray |
+==============*/ +==============*/

View file

@ -134,6 +134,9 @@ namespace CNORXZ
const Sptr<I>& i, const Vector<bool>& required) const; const Sptr<I>& i, const Vector<bool>& required) const;
/** Clear data loaded from other ranks. */
void clear() const;
protected: protected:
ObjHandle<CArrayBase<T>> mA; ObjHandle<CArrayBase<T>> mA;
RangePtr mGeom; RangePtr mGeom;
@ -165,6 +168,7 @@ namespace CNORXZ
using RCA::cbegin; using RCA::cbegin;
using RCA::cend; using RCA::cend;
using RCA::sl; using RCA::sl;
using RCA::local;
DEFAULT_C(RArray); DEFAULT_C(RArray);
DEFAULT_MOVE(RArray); DEFAULT_MOVE(RArray);