This commit is contained in:
Christian Zimmermann 2024-04-22 01:03:26 +02:00
parent e5782ac327
commit 1d77098670
3 changed files with 14 additions and 9 deletions

View file

@ -49,7 +49,7 @@ namespace CNORXZ
template <typename T> template <typename T>
template <class IndexI, class IndexK> template <class IndexI, class IndexK>
RCArray<T>::RCArray(const RRange<IndexI,IndexK>& range) : RCArray<T>::RCArray(const Sptr<RRange<IndexI,IndexK>>& range) :
mA(std::make_unique<T>(range->local())), mA(std::make_unique<T>(range->local())),
mGeom(range->geom()), mGeom(range->geom()),
mGlobal(range) mGlobal(range)
@ -258,9 +258,9 @@ namespace CNORXZ
return imap; return imap;
} }
/*===============+ /*==============+
| RCArray | | RArray |
+===============*/ +==============*/
template <typename T> template <typename T>
RArray<T>::RArray(const RArray& a) : RArray<T>::RArray(const RArray& a) :
@ -278,7 +278,7 @@ namespace CNORXZ
template <typename T> template <typename T>
template <class IndexI, class IndexK> template <class IndexI, class IndexK>
RArray<T>::RArray(const RRange<IndexI,IndexK>& range) : RArray<T>::RArray(const Sptr<RRange<IndexI,IndexK>>& range) :
RCArray<T>(range), RCArray<T>(range),
mB(dynamic_cast<ArrayBase<T>*>(RCA::mA.get())) mB(dynamic_cast<ArrayBase<T>*>(RCA::mA.get()))
{} {}

View file

@ -38,7 +38,7 @@ namespace CNORXZ
@param range The range. @param range The range.
*/ */
template <class IndexI, class IndexK> template <class IndexI, class IndexK>
RCArray(const RRange<IndexI,IndexK>& range); RCArray(const Sptr<RRange<IndexI,IndexK>>& range);
/** Construct from local array object. /** Construct from local array object.
@param a Local array. @param a Local array.
@ -142,10 +142,12 @@ namespace CNORXZ
template <class Index, class F> template <class Index, class F>
Sptr<Vector<SizeT>> load(const Sptr<Index>& lpi, const F& f) const; Sptr<Vector<SizeT>> load(const Sptr<Index>& lpi, const F& f) const;
private: protected:
ObjHandle<CArrayBase<T>> mA; ObjHandle<CArrayBase<T>> mA;
RangePtr mGeom; RangePtr mGeom;
RangePtr mGlobal; RangePtr mGlobal;
private:
mutable Vector<T> mBuf; // data from other ranks mutable Vector<T> mBuf; // data from other ranks
mutable Vector<const T*> mMap; // point to positions in mA or mBuf mutable Vector<const T*> mMap; // point to positions in mA or mBuf
}; };
@ -181,7 +183,7 @@ namespace CNORXZ
@param range The range. @param range The range.
*/ */
template <class IndexI, class IndexK> template <class IndexI, class IndexK>
RArray(const RRange<IndexI,IndexK>& range); RArray(const Sptr<RRange<IndexI,IndexK>>& range);
/** Construct from local array object. /** Construct from local array object.
@param a Local array. @param a Local array.

View file

@ -45,6 +45,7 @@ namespace
RangePtr g1 = CRangeFactory(1).create(); RangePtr g1 = CRangeFactory(1).create();
RangePtr g2 = CRangeFactory(2).create(); RangePtr g2 = CRangeFactory(2).create();
mGeom = g2*g1*g1*g2*g1; mGeom = g2*g1*g1*g2*g1;
mGeom2 = g2*g1*g1*g2;
mRXRange = rrange(mXRange, g2*g1*g1*g2); mRXRange = rrange(mXRange, g2*g1*g1*g2);
RangePtr scr = mSpRange*mSpRange; RangePtr scr = mSpRange*mSpRange;
@ -88,6 +89,7 @@ namespace
RangePtr mSpRange; RangePtr mSpRange;
RangePtr mMRange; RangePtr mMRange;
RangePtr mGeom; RangePtr mGeom;
RangePtr mGeom2;
RCArray<Double> mM1; RCArray<Double> mM1;
RCArray<Double> mM2; RCArray<Double> mM2;
@ -103,7 +105,8 @@ namespace
TEST_F(ROp_Test, Contract) TEST_F(ROp_Test, Contract)
{ {
Vector<Double> comp(mRXRange->size()); Vector<Double> comp(mRXRange->size());
//RArray<Double> res( MArray<Double>(mMRange), mGeom ); RArray<Double> res( MArray<Double>(mRXRange->sub(1)), mGeom2 );
EXPECT_EQ(res.size(), comp.size());
typedef UIndex<SizeT> UI; typedef UIndex<SizeT> UI;
RIndex<MIndex<UI,UI,UI,UI>,MIndex<UI,UI,UI,UI>> x(mRXRange); RIndex<MIndex<UI,UI,UI,UI>,MIndex<UI,UI,UI,UI>> x(mRXRange);
RIndex<MIndex<UI,UI,UI,UI>,MIndex<UI,UI,UI,UI>> y(mRXRange); RIndex<MIndex<UI,UI,UI,UI>,MIndex<UI,UI,UI,UI>> y(mRXRange);