diff --git a/src/include/functional_multi_array.h b/src/include/functional_multi_array.h index 3d5cde1..bd014c2 100644 --- a/src/include/functional_multi_array.h +++ b/src/include/functional_multi_array.h @@ -25,6 +25,11 @@ namespace MultiArrayTools virtual bool isConst() const override; virtual bool isSlice() const override; + // EVALUTAION CLASS ??!!!! + + //virtual ConstOperationRoot + //operator()(std::shared_ptr&... inds) const override; + private: mutable T mVal; Function mFunc; @@ -57,7 +62,7 @@ namespace MultiArrayTools template const T& FunctionalMultiArray::operator[](const typename CRange::IndexType& i) const { - mVal = mFunc(i); + mVal = mFunc(i.meta()); return mVal; } @@ -73,7 +78,6 @@ namespace MultiArrayTools return false; } - } // namespace MultiArrayTools #endif diff --git a/src/include/multi_array_operation.h b/src/include/multi_array_operation.h index 83dda7f..ccf12e1 100644 --- a/src/include/multi_array_operation.h +++ b/src/include/multi_array_operation.h @@ -98,6 +98,9 @@ namespace MultiArrayTools OperationMaster(MutableMultiArrayBase& ma, const OpClass& second, IndexType& index); + OperationMaster(T* data, const OpClass& second, + IndexType& index); + inline void set(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; @@ -106,7 +109,7 @@ namespace MultiArrayTools void performAssignment(std::intptr_t blockIndexNum); OpClass const& mSecond; - MutableMultiArrayBase& mArrayRef; + //MutableMultiArrayBase& mArrayRef; T* mDataPtr; IndexType mIndex; }; @@ -128,7 +131,9 @@ namespace MultiArrayTools ConstOperationRoot(const MultiArrayBase& ma, const std::shared_ptr&... indices); - + + ConstOperationRoot(const T* data, const IndexType& ind); + template inline T get(ET pos) const; @@ -139,7 +144,7 @@ namespace MultiArrayTools private: - MultiArrayBase const& mArrayRef; + //MultiArrayBase const& mArrayRef; const T* mDataPtr; IndexType mIndex; }; @@ -160,6 +165,8 @@ namespace MultiArrayTools OperationRoot(MutableMultiArrayBase& ma, const std::shared_ptr&... indices); + OperationRoot(T* data, const IndexType& ind); + template OperationMaster operator=(const OpClass& in); @@ -175,7 +182,7 @@ namespace MultiArrayTools private: - MutableMultiArrayBase& mArrayRef; + //MutableMultiArrayBase& mArrayRef; T* mDataPtr; IndexType mIndex; }; @@ -372,12 +379,22 @@ namespace MultiArrayTools OperationMaster:: OperationMaster(MutableMultiArrayBase& ma, const OpClass& second, IndexType& index) : - mSecond(second), mArrayRef(ma), mDataPtr(mArrayRef.data()), + mSecond(second), mDataPtr(ma.data()), mIndex(index) { performAssignment(0); } - + + template + OperationMaster:: + OperationMaster(T* data, const OpClass& second, + IndexType& index) : + mSecond(second), mDataPtr(data), + mIndex(index) + { + performAssignment(0); + } + template void OperationMaster::performAssignment(std::intptr_t blockIndexNum) { @@ -402,12 +419,18 @@ namespace MultiArrayTools ConstOperationRoot:: ConstOperationRoot(const MultiArrayBase& ma, const std::shared_ptr&... indices) : - mArrayRef(ma), mDataPtr(mArrayRef.data()), + mDataPtr(ma.data()), mIndex( ma.begin() ) { mIndex(indices...); } + template + ConstOperationRoot:: + ConstOperationRoot(const T* data, const IndexType& ind) : + mDataPtr(data), + mIndex( ind ) { } + template template inline T ConstOperationRoot::get(ET pos) const @@ -438,17 +461,23 @@ namespace MultiArrayTools OperationRoot:: OperationRoot(MutableMultiArrayBase& ma, const std::shared_ptr&... indices) : - mArrayRef(ma), mDataPtr(mArrayRef.data()), + mDataPtr(ma.data()), mIndex( ma.begin() ) { mIndex(indices...); } + template + OperationRoot:: + OperationRoot(T* data, const IndexType& ind) : + mDataPtr(data), + mIndex( ind ) { } + template template OperationMaster OperationRoot::operator=(const OpClass& in) { - return OperationMaster(mArrayRef, in, mIndex); + return OperationMaster(mDataPtr, in, mIndex); } template