#ifndef __ma_allocator__ #define __ma_allocator__ #include #include #include #include #include #include namespace MultiArrayHelper { template struct Allocator { typedef T value_type; static constexpr size_t type_size = sizeof(value_type); static constexpr size_t N = 32; struct VX { alignas(N) char x[N]; }; Allocator() = default; template Allocator(const Allocator& x) {} T* allocate(size_t n) { const size_t nn = n*type_size; const size_t off = nn%N; const size_t nnx = (off == 0) ? nn : nn + N - off; const size_t nnd = nnx/4; VX* vx = new VX[nnd]; return reinterpret_cast(vx); } void deallocate(T* p, size_t n) { VX* vx = reinterpret_cast(p); delete [] vx; } }; template bool operator==(const Allocator& a, const Allocator& b) { return true; } template bool operator!=(const Allocator& a, const Allocator& b) { return false; } } // namespace MultiArrayHelper namespace MultiArrayTools { template using vector = std::vector>; template inline std::vector toStdVec(const vector& v) { return std::vector(v.begin(), v.end()); } template inline vector toMatVec(const std::vector& v) { return vector(v.begin(), v.end()); } } // namespace MultiArrayTools #endif