change slice creation procedure -> works so far
This commit is contained in:
parent
7a02d0f6b8
commit
cd7c5c6c7b
3 changed files with 53 additions and 19 deletions
49
src/slice.cc
49
src/slice.cc
|
@ -8,8 +8,8 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Range, class MARange>
|
template <typename T, class Range, class MARange>
|
||||||
Slice<T,Range,MARange>::
|
Slice<T,Range,MARange>::
|
||||||
Slice(const Range& range,
|
Slice(const Range& range,
|
||||||
MutableMultiArrayBase<T,MARange>& multiArrayRef,
|
|
||||||
const Name& ownNm, // for correct linkage
|
const Name& ownNm, // for correct linkage
|
||||||
|
MutableMultiArrayBase<T,MARange>& multiArrayRef,
|
||||||
const typename MARange::IndexType& MAIdx, // for desired slice position
|
const typename MARange::IndexType& MAIdx, // for desired slice position
|
||||||
const Name& MANm) :
|
const Name& MANm) :
|
||||||
MutableMultiArrayBase<T,Range>(range),
|
MutableMultiArrayBase<T,Range>(range),
|
||||||
|
@ -23,6 +23,23 @@ namespace MultiArrayTools
|
||||||
mMAIdx.linkTo(&mOwnIdx);
|
mMAIdx.linkTo(&mOwnIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Range, class MARange>
|
||||||
|
Slice<T,Range,MARange>::
|
||||||
|
Slice(const Range& range,
|
||||||
|
const Name& ownNm,
|
||||||
|
MultiArrayOperationRoot<T,MARange>& mor,
|
||||||
|
const typename MARange::IndexType& MAIdx) :
|
||||||
|
MutableMultiArrayBase<T,Range>(range),
|
||||||
|
mOwnName(ownNm), mMAName(mor.name()), mMultiArrayPtr(&(*mor)),
|
||||||
|
mMAIdx(MAIdx)
|
||||||
|
{
|
||||||
|
MAB::mInit = true;
|
||||||
|
mOwnIdx = MAB::mRange->begin();
|
||||||
|
mMAIdx.name(mMAName);
|
||||||
|
mOwnIdx.name(ownNm);
|
||||||
|
mMAIdx.linkTo(&mOwnIdx);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class Range, class MARange>
|
template <typename T, class Range, class MARange>
|
||||||
bool Slice<T,Range,MARange>::isSlice() const
|
bool Slice<T,Range,MARange>::isSlice() const
|
||||||
{
|
{
|
||||||
|
@ -110,11 +127,11 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Range, class MARange>
|
template <typename T, class Range, class MARange>
|
||||||
ConstSlice<T,Range,MARange>::
|
ConstSlice<T,Range,MARange>::
|
||||||
ConstSlice(const Range& range,
|
ConstSlice(const Range& range,
|
||||||
const MultiArrayBase<T,MARange>& multiArrayRef,
|
|
||||||
const Name& ownNm, // for correct linkage
|
const Name& ownNm, // for correct linkage
|
||||||
|
const MultiArrayBase<T,MARange>& multiArrayRef,
|
||||||
const typename MARange::IndexType& MAIdx, // for desired slice position
|
const typename MARange::IndexType& MAIdx, // for desired slice position
|
||||||
const Name& MANm) :
|
const Name& MANm) :
|
||||||
MutableMultiArrayBase<T,Range>(range),
|
MultiArrayBase<T,Range>(range),
|
||||||
mMultiArrayPtr(&multiArrayRef),
|
mMultiArrayPtr(&multiArrayRef),
|
||||||
mMAIdx(MAIdx)
|
mMAIdx(MAIdx)
|
||||||
{
|
{
|
||||||
|
@ -125,6 +142,22 @@ namespace MultiArrayTools
|
||||||
mMAIdx.linkTo(&mOwnIdx);
|
mMAIdx.linkTo(&mOwnIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Range, class MARange>
|
||||||
|
ConstSlice<T,Range,MARange>::
|
||||||
|
ConstSlice(const Range& range,
|
||||||
|
const Name& ownNm,
|
||||||
|
const ConstMultiArrayOperationRoot<T,MARange>& mor,
|
||||||
|
const typename MARange::IndexType& MAIdx) :
|
||||||
|
MultiArrayBase<T,Range>(range),
|
||||||
|
mMultiArrayPtr(&(*mor)),
|
||||||
|
mMAIdx(MAIdx)
|
||||||
|
{
|
||||||
|
MAB::mInit = true;
|
||||||
|
mOwnIdx = MAB::mRange->begin();
|
||||||
|
mMAIdx.name(mor.name());
|
||||||
|
mOwnIdx.name(ownNm);
|
||||||
|
mMAIdx.linkTo(&mOwnIdx);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class Range, class MARange>
|
template <typename T, class Range, class MARange>
|
||||||
ConstSlice<T,Range,MARange>::
|
ConstSlice<T,Range,MARange>::
|
||||||
|
@ -192,14 +225,4 @@ namespace MultiArrayTools
|
||||||
//mOwnIdx = i.pos();
|
//mOwnIdx = i.pos();
|
||||||
return (*mMultiArrayPtr)[ mMAIdx ];
|
return (*mMultiArrayPtr)[ mMAIdx ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T, class Range, class MARange>
|
|
||||||
T& ConstSlice<T,Range,MARange>::operator[](const typename Range::IndexType& i)
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
mOwnIdx.copyPos(i);
|
|
||||||
//mOwnIdx = i.pos();
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
17
src/slice.h
17
src/slice.h
|
@ -22,11 +22,17 @@ namespace MultiArrayTools
|
||||||
typedef MultiArrayBase<T,Range> MAB;
|
typedef MultiArrayBase<T,Range> MAB;
|
||||||
|
|
||||||
Slice(const Range& range,
|
Slice(const Range& range,
|
||||||
MutableMultiArrayBase<T,MARange>& multiArrayRef,
|
|
||||||
const Name& ownNm,
|
const Name& ownNm,
|
||||||
|
MutableMultiArrayBase<T,MARange>& multiArrayRef,
|
||||||
const typename MARange::IndexType& MAIdx,
|
const typename MARange::IndexType& MAIdx,
|
||||||
const Name& MANm);
|
const Name& MANm);
|
||||||
|
|
||||||
|
Slice(const Range& range,
|
||||||
|
const Name& ownNm,
|
||||||
|
MultiArrayOperationRoot<T,MARange>& mor,
|
||||||
|
const typename MARange::IndexType& MAIdx);
|
||||||
|
|
||||||
|
|
||||||
virtual T& operator[](const typename Range::IndexType& i) override;
|
virtual T& operator[](const typename Range::IndexType& i) override;
|
||||||
virtual const T& operator[](const typename Range::IndexType& i) const override;
|
virtual const T& operator[](const typename Range::IndexType& i) const override;
|
||||||
|
|
||||||
|
@ -71,13 +77,18 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
//ConstSlice(const Range& range);
|
//ConstSlice(const Range& range);
|
||||||
ConstSlice(const Range& range,
|
ConstSlice(const Range& range,
|
||||||
const MultiArrayBase<T,MARange>& multiArrayRef,
|
|
||||||
const Name& ownNm,
|
const Name& ownNm,
|
||||||
|
const MultiArrayBase<T,MARange>& multiArrayRef,
|
||||||
const typename MARange::IndexType& MAIdx,
|
const typename MARange::IndexType& MAIdx,
|
||||||
const Name& MANm);
|
const Name& MANm);
|
||||||
|
|
||||||
|
ConstSlice(const Range& range,
|
||||||
|
const Name& ownNm,
|
||||||
|
const ConstMultiArrayOperationRoot<T,MARange>& mor,
|
||||||
|
const typename MARange::IndexType& MAIdx);
|
||||||
|
|
||||||
ConstSlice(const Slice<T,Range,MARange>& slice);
|
ConstSlice(const Slice<T,Range,MARange>& slice);
|
||||||
|
|
||||||
virtual T& operator[](const typename Range::IndexType& i) override;
|
|
||||||
virtual const T& operator[](const typename Range::IndexType& i) const override;
|
virtual const T& operator[](const typename Range::IndexType& i) const override;
|
||||||
|
|
||||||
//Slice& setSlicePos(const Index& slicePos);
|
//Slice& setSlicePos(const Index& slicePos);
|
||||||
|
|
|
@ -413,7 +413,7 @@ namespace {
|
||||||
auto i2 = i.template getIndex<1>();
|
auto i2 = i.template getIndex<1>();
|
||||||
auto i3 = i.template getIndex<2>();
|
auto i3 = i.template getIndex<2>();
|
||||||
|
|
||||||
Slice2d3dAny sl(ra, ma, MAT::Name("master", "alpha", "gamma"),
|
Slice2d3dAny sl(ra, MAT::Name("master", "alpha", "gamma"), ma,
|
||||||
i(i1 = 0, i2 = 2, i3 = 0),
|
i(i1 = 0, i2 = 2, i3 = 0),
|
||||||
MAT::Name("master", "alpha","beta","gamma"));
|
MAT::Name("master", "alpha","beta","gamma"));
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ namespace {
|
||||||
//sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
|
//sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
|
||||||
EXPECT_EQ(sl.size(), 6);
|
EXPECT_EQ(sl.size(), 6);
|
||||||
|
|
||||||
Slice2d3dAny sl2(rb, ma, MAT::Name("master", "alpha", "beta"),
|
Slice2d3dAny sl2(rb, MAT::Name("master", "alpha", "beta"), ma,
|
||||||
i(i1 = 0, i2 = 0, i3 = 1),
|
i(i1 = 0, i2 = 0, i3 = 1),
|
||||||
MAT::Name("master", "alpha","beta","gamma"));
|
MAT::Name("master", "alpha","beta","gamma"));
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ namespace {
|
||||||
auto i1 = i.template getIndex<0>();
|
auto i1 = i.template getIndex<0>();
|
||||||
auto i2 = i.template getIndex<1>();
|
auto i2 = i.template getIndex<1>();
|
||||||
auto i3 = i.template getIndex<2>();
|
auto i3 = i.template getIndex<2>();
|
||||||
Slice2d3dAny sl(ra, ma, MAT::Name("master", "alpha", "gamma"),
|
Slice2d3dAny sl(ra, MAT::Name("master", "alpha", "gamma"), ma,
|
||||||
i(i1 = 0, i2 = 2, i3 = 0),
|
i(i1 = 0, i2 = 2, i3 = 0),
|
||||||
MAT::Name("master", "alpha","beta","gamma"));
|
MAT::Name("master", "alpha","beta","gamma"));
|
||||||
//sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
|
//sl("alpha","gamma") = ma("alpha","beta","gamma")[i(i1 = 0, i2 = 2, i3 = 0)];
|
||||||
|
|
Loading…
Reference in a new issue