25 #ifndef ALEXANDRIA_NDARRAY_H
26 #define ALEXANDRIA_NDARRAY_H
50 template <
template <
class...>
class Container =
std::vector>
63 :
public std::iterator<std::random_access_iterator_tag, typename std::conditional<Const, const T, T>::type> {
209 template <
template <
class...>
class Container =
std::vector>
226 template <
template <
class...>
class Container =
std::vector>
247 template <
template <
class...>
class Container =
std::vector>
262 template <
typename Iterator>
275 template <
typename... Args>
361 template <
typename... D>
414 template <
typename... D>
415 T&
at(
size_t i, D... rest);
427 template <
typename... D>
428 const T&
at(
size_t i, D... rest)
const;
517 T
get(
size_t offset)
const {
518 return *
reinterpret_cast<T*
>(
m_data_ptr + offset);
522 T&
get(
size_t offset) {
523 return *
reinterpret_cast<T*
>(
m_data_ptr + offset);
527 virtual size_t size()
const = 0;
531 return size() *
sizeof(T);
541 template <
template <
class...>
class Container>
542 struct ContainerWrapper :
public ContainerInterface {
553 template <typename... Args>
562 template <
typename T2>
568 template <
typename T2>
583 resizeImpl<T>(
shape);
588 return Euclid::make_unique<ContainerWrapper>(
m_container);
627 template <
typename... D>
628 T&
at_helper(
size_t offset_acc,
size_t axis,
size_t i, D... rest);
633 T&
at_helper(
size_t offset_acc,
size_t axis);
643 template <
typename... D>
644 const T&
at_helper(
size_t offset_acc,
size_t axis,
size_t i, D... rest)
const;
649 const T&
at_helper(
size_t offset_acc,
size_t axis)
const;
656 template <
typename... D>
665 template <
typename T>
666 std::ostream& operator<<(std::ostream& out, const NdArray<T>& ndarray);
675 #endif // ALEXANDRIA_NDARRAY_H
const std::vector< std::size_t > & strides() const
auto resizeImpl(const std::vector< size_t > &shape) -> decltype((void) std::declval< Container< T2 >>().resize(size_t
bool operator>(const Iterator &other)
ContainerWrapper(const ContainerWrapper &)=delete
NdArray(std::vector< size_t > shape_)
Container< T > m_container
Iterator & operator-=(size_t n)
std::vector< size_t > m_shape
~ContainerWrapper()=default
self_type & reshape_helper(std::vector< size_t > &acc, size_t i, D...rest)
bool operator==(const self_type &b) const
value_t & operator[](size_t i)
virtual void resize(const std::vector< size_t > &shape)=0
Resize container.
bool operator!=(const self_type &b) const
self_type slice(size_t i)
const std::vector< size_t > & shape() const
const std::vector< std::string > & attributes() const
T & at_helper(size_t offset_acc, size_t axis, size_t i, D...rest)
auto resizeImpl(const std::vector< size_t > &shape) -> decltype((void) std::declval< Container< T2 >>().resize(std::vector< size_t >
size_t get_attr_offset(const std::string &attr) const
size_t shape(std::size_t i) const
Iterator< false > iterator
Iterator operator+(size_t n) const
size_t nbytes() const
Get the size in bytes.
std::unique_ptr< ContainerInterface > copy() const final
Expected to generate a deep copy of the underlying data.
self_type & concatenate(const self_type &other)
std::vector< size_t > m_stride_size
NdArray(const std::initializer_list< size_t > &shape_)
virtual ~NdArray()=default
Iterator operator-(size_t n) const
virtual ~ContainerInterface()=default
Iterator & operator+=(size_t n)
bool operator<(const Iterator &other)
bool operator!=(const Iterator &other) const
virtual size_t size() const =0
std::shared_ptr< ContainerInterface > m_container
self_type rslice(size_t i)
self_type & reshape(const std::vector< size_t > &new_shape)
T & at(const std::vector< size_t > &coords)
Iterator< true > const_iterator
std::size_t strides(std::size_t i) const
void resize(const std::vector< size_t > &shape) final
typename std::conditional< Const, const T, T >::type value_t
Iterator(ContainerInterface *container_ptr, size_t offset, const std::vector< size_t > &shape, const std::vector< size_t > &strides, size_t start)
size_t get_offset(const std::vector< size_t > &coords) const
std::vector< std::string > m_attr_names
bool operator==(const Iterator &other) const
ContainerInterface * m_container_ptr
size_t size() const final
virtual std::unique_ptr< ContainerInterface > copy() const =0
Expected to generate a deep copy of the underlying data.