| 45 | |
| 46 | template<class T, int AlignBytes=kDefaultAlignBytes> |
| 47 | static inline T* aligned_alloc(size_t n) { |
| 48 | static_assert(AlignBytes == 0 || AlignBytes == kDefaultAlignBytes, |
| 49 | "Only AlignBytes values of 0 and kDefaultAlignBytes are supported!"); |
| 50 | static_assert(EIGEN_DEFAULT_ALIGN_BYTES == AlignBytes, |
| 51 | "AlignBytes does not match Eigen default align bytes!"); |
| 52 | if (AlignBytes == kDefaultAlignBytes) { |
| 53 | return Eigen::aligned_allocator<T>{}.allocate(n); |
| 54 | } else { |
| 55 | return new T[n]; |
| 56 | } |
| 57 | } |
| 58 | template<class T, int AlignBytes=kDefaultAlignBytes> |
| 59 | static inline void aligned_free(T* p) { |
| 60 | static_assert(AlignBytes == 0 || AlignBytes == kDefaultAlignBytes, |