diff --git a/src/include/allocator.h~ b/src/include/allocator.h~ deleted file mode 100644 index 9636d7a..0000000 --- a/src/include/allocator.h~ +++ /dev/null @@ -1,62 +0,0 @@ - -#ifndef __ma_allocator__ -#define __ma_allocator__ - -#include -#include -#include - -namespace MultiArrayHelper -{ - - template - struct Allocator - { - typedef T value_type; - static constexpr type_size = sizeof(value_type); - - Allocator() = default; - - template - Allocator(const Allocator& x) {} - - T* allocate(size_t n) - { - //constexpr size_t NN = N*type_size; - const size_t nn = n*type_size; - if(n > static_cast(-1-NN)) throw std::bad_alloc(); - auto p = static_cast(std::malloc(nn + N)); - if(not p) throw std::bad_alloc(); - auto ip = static_cast(p); - mDiff = N - (ip % N); - p += mDiff; - return static_cast(p); - } - - void deacllocate(T* p, size_t n) - { - std::free(p-mDiff); - } - - private: - std::intptr_t mDiff; - }; - - template - bool operator==(const Allocator& a, const Allocator& b) - { - return true; - } - - template - bool operator!=(const Allocator& a, const Allocator& b) - { - return false; - } - - template - using vector = vector; - -} // namespace MultiArrayHelper - -#endif diff --git a/src/include/multi_array_operation.cc.h b/src/include/multi_array_operation.cc.h index fb42803..9c99bc7 100644 --- a/src/include/multi_array_operation.cc.h +++ b/src/include/multi_array_operation.cc.h @@ -234,6 +234,7 @@ namespace MultiArrayTools { //VCHECK(ma.data()); mIndex(indices...); + mDataPtr = mOrigDataPtr + mIndex.pos(); //mOff = mIndex.pos(); } @@ -247,6 +248,7 @@ namespace MultiArrayTools mMaPtr(maptr) { mIndex(indices...); + mDataPtr = mOrigDataPtr + mIndex.pos(); //mOff = mIndex.pos(); } @@ -257,6 +259,7 @@ namespace MultiArrayTools mOrigDataPtr(data), mIndex( ind ) { + mDataPtr = mOrigDataPtr + mIndex.pos(); //mOff = mIndex.pos(); } @@ -279,7 +282,8 @@ namespace MultiArrayTools template const T* ConstOperationRoot::data() const { - return mDataPtr + mIndex().pos(); + auto i = mIndex; + return mDataPtr + i().pos(); } template @@ -392,6 +396,7 @@ namespace MultiArrayTools mIndex( ma.begin() ) { mIndex(indices...); + mDataPtr = mOrigDataPtr + mIndex.pos(); //mOff = mIndex.pos(); } @@ -402,6 +407,7 @@ namespace MultiArrayTools mOrigDataPtr(data), mIndex( ind ) { + mDataPtr = mOrigDataPtr + mIndex.pos(); //mOff = mIndex.pos(); }