some fixes, introduce const operation classes for conistency reasons
This commit is contained in:
parent
0066cfef54
commit
ed53e4b3c7
10 changed files with 371 additions and 18 deletions
|
@ -28,6 +28,18 @@
|
|||
|
||||
namespace MultiArrayTools
|
||||
{
|
||||
template <class MultiArray>
|
||||
void checkPtr(const MultiArray& in, bool check = false)
|
||||
{
|
||||
static MultiArray const* ptr = nullptr;
|
||||
if(not check){
|
||||
ptr = ∈
|
||||
}
|
||||
else {
|
||||
assert(ptr == &in);
|
||||
}
|
||||
}
|
||||
|
||||
/***********************
|
||||
* Provided Types *
|
||||
***********************/
|
||||
|
@ -81,9 +93,17 @@ namespace MultiArrayTools
|
|||
template <typename T>
|
||||
class MultiArrayOperationBase;
|
||||
|
||||
// multi_array_operation.h
|
||||
template <typename T>
|
||||
class MutableMultiArrayOperationBase;
|
||||
|
||||
// multi_array_operation.h
|
||||
template <typename T, class Range>
|
||||
class MultiArrayOperationRoot;
|
||||
|
||||
// multi_array_operation.h
|
||||
template <typename T, class Range>
|
||||
class ConstMultiArrayOperationRoot;
|
||||
|
||||
// multi_array_operation.h
|
||||
template <typename T, class Operation, class... MAOps>
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace MultiArrayTools
|
|||
|
||||
void IndefinitIndexBase::setPos(size_t pos)
|
||||
{
|
||||
//CHECK;
|
||||
//assert(not virt());
|
||||
mPos = pos;
|
||||
if(linked()){
|
||||
|
|
|
@ -20,7 +20,10 @@ namespace MultiArrayTools
|
|||
template <typename T, class Range>
|
||||
auto MultiArrayBase<T,Range>::begin() const -> decltype(Range().begin())
|
||||
{
|
||||
return mRange->begin();
|
||||
//VCHECK(not mRange);
|
||||
auto i = mRange->begin();
|
||||
//CHECK;
|
||||
return i;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
|
@ -46,6 +49,7 @@ namespace MultiArrayTools
|
|||
template <class NameType>
|
||||
MultiArrayOperationRoot<T,Range> MultiArrayBase<T,Range>::operator()(const NameType& name, bool master)
|
||||
{
|
||||
//CHECK;
|
||||
if(master){
|
||||
return MultiArrayOperationRoot<T,Range>(*this, name);
|
||||
}
|
||||
|
@ -54,6 +58,26 @@ namespace MultiArrayTools
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class... NameTypes>
|
||||
ConstMultiArrayOperationRoot<T,Range> MultiArrayBase<T,Range>::operator()(const NameTypes&... str) const
|
||||
{
|
||||
return MultiArrayOperationRoot<T,Range>(*this, Name("master", str...));
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class NameType>
|
||||
ConstMultiArrayOperationRoot<T,Range> MultiArrayBase<T,Range>::operator()(const NameType& name, bool master) const
|
||||
{
|
||||
//CHECK;
|
||||
if(master){
|
||||
return ConstMultiArrayOperationRoot<T,Range>(*this, name);
|
||||
}
|
||||
else {
|
||||
return operator()(name);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
bool MultiArrayBase<T,Range>::isInit() const
|
||||
{
|
||||
|
|
|
@ -44,6 +44,12 @@ namespace MultiArrayTools
|
|||
template <class NameType>
|
||||
MultiArrayOperationRoot<T,Range> operator()(const NameType& name, bool master);
|
||||
|
||||
template <class... NameTypes>
|
||||
ConstMultiArrayOperationRoot<T,Range> operator()(const NameTypes&... str) const;
|
||||
|
||||
template <class NameType>
|
||||
ConstMultiArrayOperationRoot<T,Range> operator()(const NameType& name, bool master) const;
|
||||
|
||||
virtual bool isInit() const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -20,6 +20,12 @@ namespace MultiArrayTools
|
|||
{
|
||||
return *mIibPtr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void MultiArrayOperationBase<T>::freeIndex()
|
||||
{
|
||||
mIibPtr->freeLinked();
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* MultiArrayOperationBase *
|
||||
|
@ -28,12 +34,18 @@ namespace MultiArrayTools
|
|||
template <typename T, class Range>
|
||||
void MultiArrayOperationRoot<T,Range>::performAssignment(const MultiArrayOperationBase<T>& in)
|
||||
{
|
||||
//CHECK;
|
||||
in.linkIndicesTo(MAOB::mIibPtr);
|
||||
//CHECK;
|
||||
IndexType& iref = dynamic_cast<IndexType&>(*MAOB::mIibPtr);
|
||||
//CHECK;
|
||||
const size_t endPos = mArrayRef.end().pos();
|
||||
std::cout << "assignment: " << endPos << "elements" << std::endl;
|
||||
for(iref = mArrayRef.begin().pos(); iref != mArrayRef.end(); ++iref){
|
||||
// build in vectorization later
|
||||
std::cout << iref.pos() << '\r' << std::flush;
|
||||
get() = in.get();
|
||||
}
|
||||
//CHECK;
|
||||
MAOB::mIibPtr->freeLinked();
|
||||
}
|
||||
|
||||
|
@ -64,7 +76,7 @@ namespace MultiArrayTools
|
|||
MultiArrayOperationRoot<T,Range>::
|
||||
MultiArrayOperationRoot(MultiArrayBase<T,Range>& ma,
|
||||
const Name& nm) :
|
||||
MultiArrayOperationBase<T>(),
|
||||
MutableMultiArrayOperationBase<T>(),
|
||||
mArrayRef(ma),
|
||||
mIndex(mArrayRef.begin()),
|
||||
mNm(nm)
|
||||
|
@ -86,6 +98,7 @@ namespace MultiArrayTools
|
|||
MultiArrayOperationRoot<T,Range>&
|
||||
MultiArrayOperationRoot<T,Range>::operator=(MultiArrayOperationRoot<T,Range>& in)
|
||||
{
|
||||
//CHECK;
|
||||
maketurnSlice(in);
|
||||
if(mArrayRef.isSlice() and not mArrayRef.isInit()){
|
||||
return makeSlice(in);
|
||||
|
@ -99,6 +112,7 @@ namespace MultiArrayTools
|
|||
MultiArrayOperationRoot<T,Range>&
|
||||
MultiArrayOperationRoot<T,Range>::operator=(MultiArrayOperationRoot<T,Range2>& in)
|
||||
{
|
||||
//CHECK;
|
||||
if(mArrayRef.isSlice() and not mArrayRef.isInit()){
|
||||
return makeSlice(in);
|
||||
}
|
||||
|
@ -111,7 +125,9 @@ namespace MultiArrayTools
|
|||
const MultiArrayOperationRoot<T,Range>&
|
||||
MultiArrayOperationRoot<T,Range>::operator=(const MultiArrayOperationRoot<T,Range2>& in)
|
||||
{
|
||||
//CHECK;
|
||||
if(mArrayRef.isSlice() and not mArrayRef.isInit()){
|
||||
//CHECK;
|
||||
return makeConstSlice(in);
|
||||
}
|
||||
performAssignment(in);
|
||||
|
@ -123,6 +139,7 @@ namespace MultiArrayTools
|
|||
MultiArrayOperationRoot<T,Range>&
|
||||
MultiArrayOperationRoot<T,Range>::operator=(const MultiArrayOperation<T,Operation,MAOps...>& in)
|
||||
{
|
||||
//CHECK;
|
||||
if(mArrayRef.isSlice() and not mArrayRef.isInit()){
|
||||
// NO SLICE CREATION !!! (total array not initialized!!)
|
||||
// throw !
|
||||
|
@ -132,19 +149,12 @@ namespace MultiArrayTools
|
|||
return *this;
|
||||
}
|
||||
|
||||
/* template <typename T, class Range>
|
||||
template <class Operation, class... MAOps>
|
||||
MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>
|
||||
MultiArrayOperationRoot<T,Range>::operator()(Operation& op, const MAOps&... secs) const
|
||||
{
|
||||
return MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>(op, *this, secs...);
|
||||
}*/
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class Operation, class... MAOps>
|
||||
MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>
|
||||
MultiArrayOperationRoot<T,Range>::operator()(const Operation& op, const MAOps&... secs) const
|
||||
{
|
||||
//CHECK;
|
||||
return MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>(op, *this, secs...);
|
||||
}
|
||||
|
||||
|
@ -177,12 +187,14 @@ namespace MultiArrayTools
|
|||
auto MultiArrayOperationRoot<T,Range>::operator/(const MAOp& sec)
|
||||
-> decltype(operator()(std::divides<T>(), sec))
|
||||
{
|
||||
//CHECK;
|
||||
return operator()(std::divides<T>(), sec);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
MultiArrayOperationRoot<T,Range> MultiArrayOperationRoot<T,Range>::copyThis()
|
||||
{
|
||||
//CHECK;
|
||||
return MultiArrayOperationRoot<T,Range>(mArrayRef, mNm);
|
||||
}
|
||||
|
||||
|
@ -215,6 +227,7 @@ namespace MultiArrayTools
|
|||
MultiArrayOperationRoot<T,Range>&
|
||||
MultiArrayOperationRoot<T,Range>::operator/=(const MAOp& sec)
|
||||
{
|
||||
//CHECK;
|
||||
return (*this) = copyThis() / sec;
|
||||
}
|
||||
|
||||
|
@ -275,6 +288,188 @@ namespace MultiArrayTools
|
|||
mIndex.copyPos(ind);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
void MultiArrayOperationRoot<T,Range>::freeIndex()
|
||||
{
|
||||
MAOB::mIibPtr->freeLinked();
|
||||
mIndex = mArrayRef.begin();
|
||||
MAOB::mIibPtr = &mIndex;
|
||||
MAOB::mIibPtr->name(mNm);
|
||||
}
|
||||
|
||||
/**************************************
|
||||
* ConstMultiArrayOperationBase *
|
||||
**************************************/
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class RangeX>
|
||||
const ConstMultiArrayOperationRoot<T,Range>&
|
||||
ConstMultiArrayOperationRoot<T,Range>::makeConstSlice(const ConstMultiArrayOperationRoot<T,RangeX>& in) const
|
||||
{
|
||||
ConstSlice<T,Range,RangeX>& sl = dynamic_cast<ConstSlice<T,Range,RangeX>&>( mArrayRef );
|
||||
sl.set(in.mArrayRef, name(), dynamic_cast<const typename RangeX::IndexType&>( in.index() ), in.name());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// CONST SLICE !!!!!
|
||||
|
||||
template <typename T, class Range>
|
||||
ConstMultiArrayOperationRoot<T,Range>::
|
||||
ConstMultiArrayOperationRoot(const MultiArrayBase<T,Range>& ma,
|
||||
const Name& nm) :
|
||||
MultiArrayOperationBase<T>(),
|
||||
mArrayRef(ma),
|
||||
mIndex(mArrayRef.begin()),
|
||||
mNm(nm)
|
||||
{
|
||||
MAOB::mIibPtr = &mIndex;
|
||||
MAOB::mIibPtr->name(nm);
|
||||
//mIndex.name(nm);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
ConstMultiArrayOperationRoot<T,Range>::
|
||||
ConstMultiArrayOperationRoot(const MultiArrayOperationRoot<T,Range>& in) :
|
||||
MultiArrayOperationBase<T>(),
|
||||
mArrayRef(in.getCont()),
|
||||
mIndex(mArrayRef.begin()),
|
||||
mNm(in.name())
|
||||
{
|
||||
MAOB::mIibPtr = &mIndex;
|
||||
MAOB::mIibPtr->name(mNm);
|
||||
//mIndex.name(nm);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
const ConstMultiArrayOperationRoot<T,Range>&
|
||||
ConstMultiArrayOperationRoot<T,Range>::operator=(const ConstMultiArrayOperationRoot<T,Range>& in)
|
||||
{
|
||||
//CHECK;
|
||||
if(mArrayRef.isSlice() and not mArrayRef.isInit()){
|
||||
return makeConstSlice(in);
|
||||
}
|
||||
assert(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class Range2>
|
||||
const ConstMultiArrayOperationRoot<T,Range>&
|
||||
ConstMultiArrayOperationRoot<T,Range>::operator=(const ConstMultiArrayOperationRoot<T,Range2>& in)
|
||||
{
|
||||
//CHECK;
|
||||
if(mArrayRef.isSlice() and not mArrayRef.isInit()){
|
||||
//CHECK;
|
||||
return makeConstSlice(in);
|
||||
}
|
||||
assert(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class Operation, class... MAOps>
|
||||
MultiArrayOperation<T,Operation,ConstMultiArrayOperationRoot<T,Range>, MAOps...>
|
||||
ConstMultiArrayOperationRoot<T,Range>::operator()(const Operation& op, const MAOps&... secs) const
|
||||
{
|
||||
//CHECK;
|
||||
return MultiArrayOperation<T,Operation,ConstMultiArrayOperationRoot<T,Range>, MAOps...>(op, *this, secs...);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class MAOp>
|
||||
auto ConstMultiArrayOperationRoot<T,Range>::operator+(const MAOp& sec) const
|
||||
-> decltype(operator()(std::plus<T>(), sec))
|
||||
{
|
||||
return operator()(std::plus<T>(), sec);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class MAOp>
|
||||
auto ConstMultiArrayOperationRoot<T,Range>::operator-(const MAOp& sec) const
|
||||
-> decltype(operator()(std::minus<T>(), sec))
|
||||
{
|
||||
return operator()(std::minus<T>(), sec);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class MAOp>
|
||||
auto ConstMultiArrayOperationRoot<T,Range>::operator*(const MAOp& sec) const
|
||||
-> decltype(operator()(std::multiplies<T>(), sec))
|
||||
{
|
||||
return operator()(std::multiplies<T>(), sec);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
template <class MAOp>
|
||||
auto ConstMultiArrayOperationRoot<T,Range>::operator/(const MAOp& sec) const
|
||||
-> decltype(operator()(std::divides<T>(), sec))
|
||||
{
|
||||
//CHECK;
|
||||
return operator()(std::divides<T>(), sec);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
ConstMultiArrayOperationRoot<T,Range> ConstMultiArrayOperationRoot<T,Range>::copyThis() const
|
||||
{
|
||||
//CHECK;
|
||||
return ConstMultiArrayOperationRoot<T,Range>(mArrayRef, mNm);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
const MultiArrayBase<T,Range>& ConstMultiArrayOperationRoot<T,Range>::operator*() const
|
||||
{
|
||||
return mArrayRef;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
MultiArrayBase<T,Range> const* ConstMultiArrayOperationRoot<T,Range>::operator->() const
|
||||
{
|
||||
return &mArrayRef;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
size_t ConstMultiArrayOperationRoot<T,Range>::argNum() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
void ConstMultiArrayOperationRoot<T,Range>::linkIndicesTo(IndefinitIndexBase* target) const
|
||||
{
|
||||
MAOB::mIibPtr->linkTo(target);
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
const T& ConstMultiArrayOperationRoot<T,Range>::get() const
|
||||
{
|
||||
//return mArrayRef[mIndex];
|
||||
return mArrayRef[*dynamic_cast<IndexType*>(MAOB::mIibPtr)];
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
const Name& ConstMultiArrayOperationRoot<T,Range>::name() const
|
||||
{
|
||||
return mNm;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
const ConstMultiArrayOperationRoot<T,Range>& ConstMultiArrayOperationRoot<T,Range>::operator[](const IndexType& ind) const
|
||||
{
|
||||
mIndex.copyPos(ind);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, class Range>
|
||||
void ConstMultiArrayOperationRoot<T,Range>::freeIndex()
|
||||
{
|
||||
MAOB::mIibPtr->freeLinked();
|
||||
mIndex = mArrayRef.begin();
|
||||
MAOB::mIibPtr = &mIndex;
|
||||
MAOB::mIibPtr->name(mNm);
|
||||
}
|
||||
|
||||
|
||||
/*****************************
|
||||
* MultiArrayOperation *
|
||||
|
@ -410,14 +605,15 @@ namespace MultiArrayTools
|
|||
{
|
||||
TupleIndicesLinker<sizeof...(MAOps)-1>::linkTupleIndicesTo(mArgs, target);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
template <typename T, class Operation, class... MAOps>
|
||||
T& MultiArrayOperation<T,Operation,MAOps...>::get()
|
||||
{
|
||||
mVal = OperationCall<sizeof...(MAOps)-1>::
|
||||
template callOperation(mOp, mArgs);
|
||||
return mVal;
|
||||
}
|
||||
}*/
|
||||
|
||||
template <typename T, class Operation, class... MAOps>
|
||||
const T& MultiArrayOperation<T,Operation,MAOps...>::get() const
|
||||
|
|
|
@ -17,22 +17,33 @@ namespace MultiArrayTools
|
|||
{
|
||||
public:
|
||||
|
||||
MultiArrayOperationBase() = default;
|
||||
MultiArrayOperationBase() /*{ CHECK; }*/ = default;
|
||||
virtual ~MultiArrayOperationBase();
|
||||
|
||||
virtual size_t argNum() const = 0;
|
||||
const IndefinitIndexBase& index() const;
|
||||
virtual void linkIndicesTo(IndefinitIndexBase* target) const = 0;
|
||||
|
||||
virtual T& get() = 0;
|
||||
virtual const T& get() const = 0;
|
||||
|
||||
virtual void freeIndex();
|
||||
|
||||
protected:
|
||||
IndefinitIndexBase* mIibPtr = nullptr;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
class MutableMultiArrayOperationBase : public MultiArrayOperationBase<T>
|
||||
{
|
||||
public:
|
||||
|
||||
MutableMultiArrayOperationBase() /*{ CHECK; }*/ = default;
|
||||
virtual T& get() = 0;
|
||||
};
|
||||
|
||||
template <typename T, class Range>
|
||||
class MultiArrayOperationRoot : public MultiArrayOperationBase<T>
|
||||
class MultiArrayOperationRoot : public MutableMultiArrayOperationBase<T>
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -89,6 +100,7 @@ namespace MultiArrayTools
|
|||
MultiArrayOperationRoot& operator/=(const MAOp& sec);
|
||||
|
||||
const MultiArrayBase<T,Range>& operator*() const;
|
||||
//MultiArrayBase<T,Range>& operator*();
|
||||
MultiArrayBase<T,Range> const* operator->() const;
|
||||
|
||||
virtual size_t argNum() const override;
|
||||
|
@ -104,6 +116,10 @@ namespace MultiArrayTools
|
|||
|
||||
const Name& name() const;
|
||||
|
||||
virtual void freeIndex() override;
|
||||
|
||||
const MultiArrayBase<T,Range>& getCont() const { return mArrayRef; }
|
||||
|
||||
template <typename U, class RangeX>
|
||||
friend class MultiArrayOperationRoot;
|
||||
|
||||
|
@ -121,6 +137,77 @@ namespace MultiArrayTools
|
|||
mutable IndexType mIndex;
|
||||
Name mNm;
|
||||
};
|
||||
|
||||
template <typename T, class Range>
|
||||
class ConstMultiArrayOperationRoot : public MultiArrayOperationBase<T>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef MultiArrayOperationBase<T> MAOB;
|
||||
typedef typename Range::IndexType IndexType;
|
||||
//typedef decltype(MultiArray<T,Range>().begin()) IndexType;
|
||||
|
||||
ConstMultiArrayOperationRoot(const MultiArrayBase<T,Range>& ma, const Name& nm);
|
||||
ConstMultiArrayOperationRoot(const MultiArrayOperationRoot<T,Range>& in);
|
||||
|
||||
const ConstMultiArrayOperationRoot& operator=(const ConstMultiArrayOperationRoot& in);
|
||||
|
||||
template <class Range2>
|
||||
const ConstMultiArrayOperationRoot& operator=(const ConstMultiArrayOperationRoot<T,Range2>& in);
|
||||
|
||||
//template <class Operation, class... MAOps>
|
||||
//MultiArrayOperation<T,Operation,MultiArrayOperationRoot<T,Range>, MAOps...>
|
||||
//operator()(Operation& op, const MAOps&... secs) const;
|
||||
|
||||
template <class Operation, class... MAOps>
|
||||
MultiArrayOperation<T,Operation,ConstMultiArrayOperationRoot<T,Range>, MAOps...>
|
||||
operator()(const Operation& op, const MAOps&... secs) const;
|
||||
|
||||
template <class MAOp>
|
||||
auto operator+(const MAOp& sec) const -> decltype(operator()(std::plus<T>(), sec));
|
||||
|
||||
template <class MAOp>
|
||||
auto operator-(const MAOp& sec) const -> decltype(operator()(std::minus<T>(), sec));
|
||||
|
||||
template <class MAOp>
|
||||
auto operator*(const MAOp& sec) const -> decltype(operator()(std::multiplies<T>(), sec));
|
||||
|
||||
template <class MAOp>
|
||||
auto operator/(const MAOp& sec) const -> decltype(operator()(std::divides<T>(), sec));
|
||||
|
||||
ConstMultiArrayOperationRoot copyThis() const;
|
||||
|
||||
const MultiArrayBase<T,Range>& operator*() const;
|
||||
//MultiArrayBase<T,Range>& operator*();
|
||||
MultiArrayBase<T,Range> const* operator->() const;
|
||||
|
||||
virtual size_t argNum() const override;
|
||||
|
||||
// set index -> implement !!!!!
|
||||
const ConstMultiArrayOperationRoot<T,Range>& operator[](const IndexType& ind) const;
|
||||
|
||||
virtual void linkIndicesTo(IndefinitIndexBase* target) const override;
|
||||
|
||||
virtual const T& get() const override;
|
||||
|
||||
const Name& name() const;
|
||||
|
||||
virtual void freeIndex() override;
|
||||
|
||||
const MultiArrayBase<T,Range>& getCont() const { return mArrayRef; }
|
||||
|
||||
template <typename U, class RangeX>
|
||||
friend class MultiArrayOperationRoot;
|
||||
|
||||
protected:
|
||||
|
||||
template <class RangeX>
|
||||
const ConstMultiArrayOperationRoot& makeConstSlice(const ConstMultiArrayOperationRoot<T,RangeX>& in) const;
|
||||
|
||||
MultiArrayBase<T,Range> const& mArrayRef;
|
||||
mutable IndexType mIndex;
|
||||
Name mNm;
|
||||
};
|
||||
|
||||
template <typename T, class Operation, class... MAOps>
|
||||
class MultiArrayOperation : public MultiArrayOperationBase<T>
|
||||
|
@ -157,7 +244,7 @@ namespace MultiArrayTools
|
|||
|
||||
virtual void linkIndicesTo(IndefinitIndexBase* target) const override;
|
||||
|
||||
virtual T& get() override;
|
||||
//virtual T& get() override;
|
||||
virtual const T& get() const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -585,12 +585,15 @@ namespace MultiArrayTools
|
|||
if(name == IIB::mName){
|
||||
return this;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i != sizeof...(Indices); ++i){
|
||||
IndefinitIndexBase* iibPtr = get(i).getLinked(name);
|
||||
if(iibPtr != nullptr){
|
||||
//CHECK;
|
||||
return iibPtr;
|
||||
}
|
||||
}
|
||||
//CHECK;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace MultiArrayTools
|
|||
#ifdef LORENTZ_DIMENSION
|
||||
return LORENTZ_DIMENSION;
|
||||
#else
|
||||
return 4;
|
||||
return 1; // 4
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -327,6 +327,8 @@ namespace MultiArrayTools
|
|||
template <typename U, RangeType TYPE>
|
||||
IndefinitIndexBase* SingleIndex<U,TYPE>::getLinked(const std::string& name)
|
||||
{
|
||||
//VCHECK(name);
|
||||
//VCHECK(IIB::mName);
|
||||
if(name == IIB::mName){
|
||||
return this;
|
||||
}
|
||||
|
|
10
src/slice.cc
10
src/slice.cc
|
@ -104,4 +104,14 @@ namespace MultiArrayTools
|
|||
//mOwnIdx = i.pos();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace MultiArrayTools
|
|||
|
||||
ConstSlice(const Range& range);
|
||||
|
||||
virtual T& operator[](const typename Range::IndexType& i) override;
|
||||
virtual const T& operator[](const typename Range::IndexType& i) const override;
|
||||
|
||||
//Slice& setSlicePos(const Index& slicePos);
|
||||
|
@ -71,6 +72,9 @@ namespace MultiArrayTools
|
|||
const Name& MANm);
|
||||
|
||||
private:
|
||||
|
||||
// !!!
|
||||
T x = static_cast<T>(0);
|
||||
|
||||
MultiArrayBase<T,MARange> const* mMultiArrayPtr = nullptr;
|
||||
mutable typename Range::IndexType mOwnIdx;
|
||||
|
|
Loading…
Reference in a new issue