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>
class OpRoot;
// definition: operation/op_types.h
template <class Index>
class PosOp;
// definition: operation/op_types.h
template <class F, class... Ops>
class Operation;

View file

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

View file

@ -119,17 +119,9 @@ namespace CNORXZ
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):
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);
return posop(_this);
}
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
{
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) );
}
else {
@ -335,11 +338,16 @@ namespace CNORXZ
const String blim = "[";
const String elim = "]";
const String dlim = ",";
return blim +
std::accumulate(std::next(mIs.all().begin()), mIs.all().end(), mIs[0]->stringMeta(),
[&](const auto& s, const auto& e)
{ return s + dlim + e->stringMeta(); } ) +
elim;
if(mIs.size() == 0){
return blim + elim;
}
else {
return blim +
std::accumulate(std::next(mIs.all().begin()), mIs.all().end(), mIs[0]->stringMeta(),
[&](const auto& s, const auto& e)
{ return s + dlim + e->stringMeta(); } ) +
elim;
}
}
Vector<DType> YIndex::meta() const

View file

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

View file

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