some minor changes
This commit is contained in:
parent
d1363c3c3d
commit
685023b09c
6 changed files with 37 additions and 73 deletions
|
@ -35,6 +35,13 @@ namespace MultiArrayTools
|
||||||
return *mRange;
|
return *mRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class Range>
|
||||||
|
template <class... NameTypes>
|
||||||
|
MultiArrayOperationRoot<T,Range> MultiArrayBase<T,Range>::operator()(const NameTypes&... str)
|
||||||
|
{
|
||||||
|
return MultiArrayOperationRoot<T,Range>(*this, Name("master", str...));
|
||||||
|
}
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
* MultiArray *
|
* MultiArray *
|
||||||
*******************/
|
*******************/
|
||||||
|
@ -76,13 +83,6 @@ namespace MultiArrayTools
|
||||||
return mCont[ i.pos() ];
|
return mCont[ i.pos() ];
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class Range>
|
|
||||||
template <class... NameTypes>
|
|
||||||
MultiArrayOperationRoot<T,Range> MultiArray<T,Range>::operator()(const NameTypes&... str)
|
|
||||||
{
|
|
||||||
return MultiArrayOperationRoot<T,Range>(*this, Name("master", str...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, class Range>
|
template <typename T, class Range>
|
||||||
bool MultiArray<T,Range>::isSlice() const
|
bool MultiArray<T,Range>::isSlice() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
virtual const Range& range() const;
|
virtual const Range& range() const;
|
||||||
|
|
||||||
|
template <class... NameTypes>
|
||||||
|
MultiArrayOperationRoot<T,Range> operator()(const NameTypes&... str);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<Range> mRange;
|
std::shared_ptr<Range> mRange;
|
||||||
|
|
||||||
|
@ -50,9 +53,6 @@ namespace MultiArrayTools
|
||||||
MultiArray(const Range& range, const std::vector<T>& vec);
|
MultiArray(const Range& range, const std::vector<T>& vec);
|
||||||
MultiArray(const Range& range, std::vector<T>&& vec);
|
MultiArray(const Range& range, std::vector<T>&& vec);
|
||||||
|
|
||||||
template <class... NameTypes>
|
|
||||||
MultiArrayOperationRoot<T,Range> operator()(const NameTypes&... str);
|
|
||||||
|
|
||||||
T& operator[](const typename Range::IndexType& i) override;
|
T& operator[](const typename Range::IndexType& i) override;
|
||||||
const T& operator[](const typename Range::IndexType& i) const override;
|
const T& operator[](const typename Range::IndexType& i) const override;
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,16 @@ namespace MultiArrayTools
|
||||||
MultiArrayOperationRoot<T,Range>&
|
MultiArrayOperationRoot<T,Range>&
|
||||||
MultiArrayOperationRoot<T,Range>::operator=(const MultiArrayOperationRoot<T,Range>& in)
|
MultiArrayOperationRoot<T,Range>::operator=(const MultiArrayOperationRoot<T,Range>& in)
|
||||||
{
|
{
|
||||||
|
if(mArrayRef.isSlice()){
|
||||||
|
Slice<T,Range>& sl = dynamic_cast<Slice<T,Range>&>( mArrayRef );
|
||||||
|
|
||||||
|
sl.set()
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
in.linkIndicesTo(MAOB::mIibPtr);
|
in.linkIndicesTo(MAOB::mIibPtr);
|
||||||
IndexType& iref = dynamic_cast<IndexType&>(*MAOB::mIibPtr);
|
IndexType& iref = dynamic_cast<IndexType&>(*MAOB::mIibPtr);
|
||||||
//if(mArrayRef.isSlice()){
|
|
||||||
// linkSlice(&in.index(), MAOB::mIibPtr);
|
|
||||||
// return *this;
|
|
||||||
//}
|
|
||||||
for(iref = mArrayRef.begin().pos(); iref != mArrayRef.end(); ++iref){
|
for(iref = mArrayRef.begin().pos(); iref != mArrayRef.end(); ++iref){
|
||||||
// build in vectorization later
|
// build in vectorization later
|
||||||
get() = in.get();
|
get() = in.get();
|
||||||
|
@ -62,12 +66,11 @@ namespace MultiArrayTools
|
||||||
MultiArrayOperationRoot<T,Range>&
|
MultiArrayOperationRoot<T,Range>&
|
||||||
MultiArrayOperationRoot<T,Range>::operator=(const MultiArrayOperation<T,Operation,MAOps...>& in)
|
MultiArrayOperationRoot<T,Range>::operator=(const MultiArrayOperation<T,Operation,MAOps...>& in)
|
||||||
{
|
{
|
||||||
|
// NO SLICE CREATION !!! (total array not initialized!!)
|
||||||
|
|
||||||
in.linkIndicesTo(MAOB::mIibPtr);
|
in.linkIndicesTo(MAOB::mIibPtr);
|
||||||
IndexType& iref = dynamic_cast<IndexType&>(*MAOB::mIibPtr);
|
IndexType& iref = dynamic_cast<IndexType&>(*MAOB::mIibPtr);
|
||||||
//if(mArrayRef.isSlice()){
|
|
||||||
// linkSlice(&in.index(), MAOB::mIibPtr);
|
|
||||||
// return *this;
|
|
||||||
//}
|
|
||||||
for(iref = mArrayRef.begin().pos(); iref != mArrayRef.end(); ++iref){
|
for(iref = mArrayRef.begin().pos(); iref != mArrayRef.end(); ++iref){
|
||||||
// build in vectorization later
|
// build in vectorization later
|
||||||
get() = in.get();
|
get() = in.get();
|
||||||
|
@ -76,26 +79,6 @@ namespace MultiArrayTools
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
template <typename T, class Range>
|
|
||||||
template <class Range2>
|
|
||||||
MultiArrayOperationRoot<T,Range>&
|
|
||||||
MultiArrayOperationRoot<T,Range>::operator=(const MultiArrayOperationBase<T, Range2>& in)
|
|
||||||
{
|
|
||||||
in.linkIndicesTo(MAOB::mIibPtr);
|
|
||||||
IndexType& iref = dynamic_cast<IndexType&>(*MAOB::mIibPtr);
|
|
||||||
if(mArrayRef.isSlice()){
|
|
||||||
linkSlice(&in.index(), MAOB::mIibPtr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
for(iref = mArrayRef.begin().pos(); iref != mArrayRef.end(); ++iref){
|
|
||||||
// build in vectorization later
|
|
||||||
get() = in.get();
|
|
||||||
}
|
|
||||||
MAOB::mIibPtr->freeLinked();
|
|
||||||
return *this;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
template <typename T, class Range>
|
template <typename T, class Range>
|
||||||
template <class Operation, class... MAOps>
|
template <class Operation, class... MAOps>
|
||||||
MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>
|
MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>
|
||||||
|
|
|
@ -45,14 +45,6 @@ namespace MultiArrayTools
|
||||||
template <class Operation, class... MAOps>
|
template <class Operation, class... MAOps>
|
||||||
MultiArrayOperationRoot& operator=(const MultiArrayOperation<T,Operation,MAOps...>& in);
|
MultiArrayOperationRoot& operator=(const MultiArrayOperation<T,Operation,MAOps...>& in);
|
||||||
|
|
||||||
//MultiArrayOperationRoot& operator=(const MultiArrayOperationRoot& in) = delete;
|
|
||||||
//MultiArrayOperationRoot(const MultiArrayOperationRoot& in) = default;
|
|
||||||
|
|
||||||
// execute AnyOperation
|
|
||||||
// exception if range types are inconsitent with names
|
|
||||||
//MultiArrayOperationRoot& operator=(const MultiArrayOperationBase<T>& in);
|
|
||||||
|
|
||||||
|
|
||||||
template <class Operation, class... MAOps>
|
template <class Operation, class... MAOps>
|
||||||
MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>
|
MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>
|
||||||
operator()(Operation& op, const MAOps&... secs);
|
operator()(Operation& op, const MAOps&... secs);
|
||||||
|
|
25
src/slice.cc
25
src/slice.cc
|
@ -5,32 +5,23 @@
|
||||||
namespace MultiArrayTools
|
namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename T, class Range, class MARange, class Index>
|
template <typename T, class Range, class MARange>
|
||||||
Slice<T,Range,MARange,Index>::
|
Slice<T,Range,MARange,Index>::
|
||||||
Slice(MultiArrayBase<T,MARange>& ma, const Index& slicePos) :
|
Slice() :
|
||||||
MultiArrayBase<T,Range>(ma.range()),
|
MultiArrayBase<T,Range>(ma.range()),
|
||||||
multiArrayRef(ma),
|
mMultiArrayRef(*this) {}
|
||||||
mSlicePos(slicePos) {}
|
|
||||||
|
|
||||||
template <typename T, class Range, class MARange, class Index>
|
template <typename T, class Range, class MARange>
|
||||||
Slice<T,Range,MARange,Index>& Slice<T,Range,MARange,Index>::setSlicePos(const Index& slicePos)
|
|
||||||
{
|
|
||||||
mSlicePos = slicePos;
|
|
||||||
mMAPtr->linkTo(&mSlicePos);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, class Range, class MARange, class Index>
|
|
||||||
bool Slice<T,Range,MARange,Index>::isSlice() const
|
bool Slice<T,Range,MARange,Index>::isSlice() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class Range, class MARange, class Index>
|
template <typename T, class Range, class MARange>
|
||||||
void Slice<T,Range,MARange,Index>::setPtr(IndefinitIndexBase* MAPtr,
|
void Slice<T,Range,MARange,Index>::set(MultiArrayBase<T,MARange>& multiArrayRef, IndefinitIndexBase* MAPtr)
|
||||||
IndefinitIndexBase* ownPtr)
|
|
||||||
{
|
{
|
||||||
|
mMultiArrayRef = multiArrayRef;
|
||||||
|
|
||||||
mMAPtr.reset(new typename MARange::IndexType(MAPtr));
|
mMAPtr.reset(new typename MARange::IndexType(MAPtr));
|
||||||
mOwnPtr.reset(new typename Range::IndexType(ownPtr));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
src/slice.h
18
src/slice.h
|
@ -14,20 +14,19 @@ namespace MultiArrayTools
|
||||||
// Range = range of slice
|
// Range = range of slice
|
||||||
// MARange = original range of multi array of which this is the slice
|
// MARange = original range of multi array of which this is the slice
|
||||||
// Index = index which determines the slice position (remnant of MARange w.o. Range)
|
// Index = index which determines the slice position (remnant of MARange w.o. Range)
|
||||||
template <typename T, class Range, class MARange, class Index>
|
template <typename T, class Range, class MARange/*, class Index*/>
|
||||||
class Slice : public MultiArrayBase<T,Range> // yes, 'Range' is correct !!!
|
class Slice : public MultiArrayBase<T,Range> // yes, 'Range' is correct !!!
|
||||||
{
|
{
|
||||||
//MA::mCont has to be empty; only make use of the provided functions
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef MultiArrayBase<T,MARange> MAB;
|
typedef MultiArrayBase<T,Range> MAB;
|
||||||
|
|
||||||
Slice(MultiArray<T,MARange>& ma, const Index& slicePos);
|
Slice();
|
||||||
|
|
||||||
T& operator[](const typename Range::IndexType& i) override;
|
T& operator[](const typename Range::IndexType& i) override;
|
||||||
const T& operator[](const typename Range::IndexType& i) const override;
|
const T& operator[](const typename Range::IndexType& i) const override;
|
||||||
|
|
||||||
Slice& setSlicePos(const Index& slicePos);
|
//Slice& setSlicePos(const Index& slicePos);
|
||||||
|
|
||||||
// link given Index to mMAPtr which is index of total array
|
// link given Index to mMAPtr which is index of total array
|
||||||
auto begin() override -> decltype(Range().begin());
|
auto begin() override -> decltype(Range().begin());
|
||||||
|
@ -35,15 +34,14 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
virtual bool isSlice() const override;
|
virtual bool isSlice() const override;
|
||||||
|
|
||||||
void setPtr(IndefinitIndexBase* MAPtr,
|
void set(MultiArrayBase<T,MARange>& multiArrayRef, IndefinitIndexBase* MAPtr);
|
||||||
IndefinitIndexBase* ownPtr);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MultiArrayBase<T,MARange>& multiArrayRef;
|
MultiArrayBase<T,MARange>& mMultiArrayRef;
|
||||||
IndefinitIndexBase* mMAPtr; // idx ptr for original MA Range
|
std::shared_ptr<IndefinitIndexBase> mMAPtr; // idx ptr for original MA Range
|
||||||
IndefinitIndexBase* mOwnPtr; // idx ptr for own Range
|
IndefinitIndexBase* mOwnPtr; // idx ptr for own Range
|
||||||
Index mSlicePos;
|
//Index mSlicePos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue