functional multi array... need general functional ma transform
This commit is contained in:
parent
cf724f60ed
commit
ea139067dd
2 changed files with 44 additions and 11 deletions
|
@ -25,6 +25,11 @@ namespace MultiArrayTools
|
||||||
virtual bool isConst() const override;
|
virtual bool isConst() const override;
|
||||||
virtual bool isSlice() const override;
|
virtual bool isSlice() const override;
|
||||||
|
|
||||||
|
// EVALUTAION CLASS ??!!!!
|
||||||
|
|
||||||
|
//virtual ConstOperationRoot<T,SRanges...>
|
||||||
|
//operator()(std::shared_ptr<typename SRanges::IndexType>&... inds) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable T mVal;
|
mutable T mVal;
|
||||||
Function mFunc;
|
Function mFunc;
|
||||||
|
@ -57,7 +62,7 @@ namespace MultiArrayTools
|
||||||
template <typename T, class Function, class... SRanges>
|
template <typename T, class Function, class... SRanges>
|
||||||
const T& FunctionalMultiArray<T,Function,SRanges...>::operator[](const typename CRange::IndexType& i) const
|
const T& FunctionalMultiArray<T,Function,SRanges...>::operator[](const typename CRange::IndexType& i) const
|
||||||
{
|
{
|
||||||
mVal = mFunc(i);
|
mVal = mFunc(i.meta());
|
||||||
return mVal;
|
return mVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +78,6 @@ namespace MultiArrayTools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace MultiArrayTools
|
} // namespace MultiArrayTools
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -98,6 +98,9 @@ namespace MultiArrayTools
|
||||||
OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second,
|
OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second,
|
||||||
IndexType& index);
|
IndexType& index);
|
||||||
|
|
||||||
|
OperationMaster(T* data, const OpClass& second,
|
||||||
|
IndexType& index);
|
||||||
|
|
||||||
inline void set(size_t pos, T val) { mDataPtr[pos] = val; }
|
inline void set(size_t pos, T val) { mDataPtr[pos] = val; }
|
||||||
inline void add(size_t pos, T val) { mDataPtr[pos] += val; }
|
inline void add(size_t pos, T val) { mDataPtr[pos] += val; }
|
||||||
inline T get(size_t pos) const;
|
inline T get(size_t pos) const;
|
||||||
|
@ -106,7 +109,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
void performAssignment(std::intptr_t blockIndexNum);
|
void performAssignment(std::intptr_t blockIndexNum);
|
||||||
OpClass const& mSecond;
|
OpClass const& mSecond;
|
||||||
MutableMultiArrayBase<T,Ranges...>& mArrayRef;
|
//MutableMultiArrayBase<T,Ranges...>& mArrayRef;
|
||||||
T* mDataPtr;
|
T* mDataPtr;
|
||||||
IndexType mIndex;
|
IndexType mIndex;
|
||||||
};
|
};
|
||||||
|
@ -128,7 +131,9 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
||||||
|
|
||||||
|
ConstOperationRoot(const T* data, const IndexType& ind);
|
||||||
|
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T get(ET pos) const;
|
inline T get(ET pos) const;
|
||||||
|
|
||||||
|
@ -139,7 +144,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MultiArrayBase<T,Ranges...> const& mArrayRef;
|
//MultiArrayBase<T,Ranges...> const& mArrayRef;
|
||||||
const T* mDataPtr;
|
const T* mDataPtr;
|
||||||
IndexType mIndex;
|
IndexType mIndex;
|
||||||
};
|
};
|
||||||
|
@ -160,6 +165,8 @@ namespace MultiArrayTools
|
||||||
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
const std::shared_ptr<typename Ranges::IndexType>&... indices);
|
||||||
|
|
||||||
|
OperationRoot(T* data, const IndexType& ind);
|
||||||
|
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationMaster<T,OpClass,Ranges...> operator=(const OpClass& in);
|
OperationMaster<T,OpClass,Ranges...> operator=(const OpClass& in);
|
||||||
|
|
||||||
|
@ -175,7 +182,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MutableMultiArrayBase<T,Ranges...>& mArrayRef;
|
//MutableMultiArrayBase<T,Ranges...>& mArrayRef;
|
||||||
T* mDataPtr;
|
T* mDataPtr;
|
||||||
IndexType mIndex;
|
IndexType mIndex;
|
||||||
};
|
};
|
||||||
|
@ -372,12 +379,22 @@ namespace MultiArrayTools
|
||||||
OperationMaster<T,OpClass,Ranges...>::
|
OperationMaster<T,OpClass,Ranges...>::
|
||||||
OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second,
|
OperationMaster(MutableMultiArrayBase<T,Ranges...>& ma, const OpClass& second,
|
||||||
IndexType& index) :
|
IndexType& index) :
|
||||||
mSecond(second), mArrayRef(ma), mDataPtr(mArrayRef.data()),
|
mSecond(second), mDataPtr(ma.data()),
|
||||||
mIndex(index)
|
mIndex(index)
|
||||||
{
|
{
|
||||||
performAssignment(0);
|
performAssignment(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class OpClass, class... Ranges>
|
||||||
|
OperationMaster<T,OpClass,Ranges...>::
|
||||||
|
OperationMaster(T* data, const OpClass& second,
|
||||||
|
IndexType& index) :
|
||||||
|
mSecond(second), mDataPtr(data),
|
||||||
|
mIndex(index)
|
||||||
|
{
|
||||||
|
performAssignment(0);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, class OpClass, class... Ranges>
|
template <typename T, class OpClass, class... Ranges>
|
||||||
void OperationMaster<T,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum)
|
void OperationMaster<T,OpClass,Ranges...>::performAssignment(std::intptr_t blockIndexNum)
|
||||||
{
|
{
|
||||||
|
@ -402,12 +419,18 @@ namespace MultiArrayTools
|
||||||
ConstOperationRoot<T,Ranges...>::
|
ConstOperationRoot<T,Ranges...>::
|
||||||
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
ConstOperationRoot(const MultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||||
mArrayRef(ma), mDataPtr(mArrayRef.data()),
|
mDataPtr(ma.data()),
|
||||||
mIndex( ma.begin() )
|
mIndex( ma.begin() )
|
||||||
{
|
{
|
||||||
mIndex(indices...);
|
mIndex(indices...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
ConstOperationRoot<T,Ranges...>::
|
||||||
|
ConstOperationRoot(const T* data, const IndexType& ind) :
|
||||||
|
mDataPtr(data),
|
||||||
|
mIndex( ind ) { }
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class ET>
|
template <class ET>
|
||||||
inline T ConstOperationRoot<T,Ranges...>::get(ET pos) const
|
inline T ConstOperationRoot<T,Ranges...>::get(ET pos) const
|
||||||
|
@ -438,17 +461,23 @@ namespace MultiArrayTools
|
||||||
OperationRoot<T,Ranges...>::
|
OperationRoot<T,Ranges...>::
|
||||||
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
OperationRoot(MutableMultiArrayBase<T,Ranges...>& ma,
|
||||||
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
const std::shared_ptr<typename Ranges::IndexType>&... indices) :
|
||||||
mArrayRef(ma), mDataPtr(mArrayRef.data()),
|
mDataPtr(ma.data()),
|
||||||
mIndex( ma.begin() )
|
mIndex( ma.begin() )
|
||||||
{
|
{
|
||||||
mIndex(indices...);
|
mIndex(indices...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... Ranges>
|
||||||
|
OperationRoot<T,Ranges...>::
|
||||||
|
OperationRoot(T* data, const IndexType& ind) :
|
||||||
|
mDataPtr(data),
|
||||||
|
mIndex( ind ) { }
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
template <class OpClass>
|
template <class OpClass>
|
||||||
OperationMaster<T,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
OperationMaster<T,OpClass,Ranges...> OperationRoot<T,Ranges...>::operator=(const OpClass& in)
|
||||||
{
|
{
|
||||||
return OperationMaster<T,OpClass,Ranges...>(mArrayRef, in, mIndex);
|
return OperationMaster<T,OpClass,Ranges...>(mDataPtr, in, mIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, class... Ranges>
|
template <typename T, class... Ranges>
|
||||||
|
|
Loading…
Reference in a new issue