From 9fec5d63543758fd6bb3bc5c29f8d11fce4ee53c Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 27 Feb 2019 20:41:46 +0100 Subject: [PATCH] remove emacs bak file + fixes --- src/include/allocator.h~ | 62 -------------------------- src/include/multi_array_operation.cc.h | 8 +++- 2 files changed, 7 insertions(+), 63 deletions(-) delete mode 100644 src/include/allocator.h~ 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(); }