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>
241 template <
typename Iterator>
254 template <
typename... Args>
324 template <
typename... D>
377 template <
typename... D>
378 T&
at(
size_t i, D... rest);
390 template <
typename... D>
391 const T&
at(
size_t i, D... rest)
const;
478 T
at(
size_t offset)
const {
483 T&
at(
size_t offset) {
488 virtual size_t size()
const = 0;
497 template <
template <
class...>
class Container>
508 template <
typename... Args>
517 template <
typename T2>
523 template <
typename T2>
538 resizeImpl<T>(
shape);
543 return Euclid::make_unique<ContainerWrapper>(
m_container);
582 template <
typename... D>
583 T&
at_helper(
size_t offset_acc,
size_t axis,
size_t i, D... rest);
598 template <
typename... D>
599 const T&
at_helper(
size_t offset_acc,
size_t axis,
size_t i, D... rest)
const;
604 const T&
at_helper(
size_t offset_acc,
size_t axis)
const;
611 template <
typename... D>
620 template <
typename T>
Iterator(ContainerInterface *container_ptr, size_t offset, size_t row_size, size_t stride, size_t start)
Iterator & operator+=(size_t n)
bool operator!=(const Iterator &other) const
typename std::conditional< Const, const T, T >::type value_t
Iterator & operator-=(size_t n)
bool operator>(const Iterator &other)
Iterator operator+(size_t n)
bool operator<(const Iterator &other)
value_t & operator[](size_t i)
Iterator(ContainerInterface *container_ptr, size_t offset, const std::vector< size_t > &shape, const std::vector< size_t > &strides, size_t start)
ContainerInterface * m_container_ptr
bool operator==(const Iterator &other) const
value_t operator*() const
Iterator(const Iterator< false > &other)
Iterator operator-(size_t n)
value_t operator[](size_t i) const
difference_type operator-(const Iterator &other)
NdArray(const std::vector< size_t > &shape_, Container< T > &&data)
const T & at_helper(size_t offset_acc, size_t axis, const std::string &attr) const
std::vector< std::string > m_attr_names
size_t get_offset(const std::vector< size_t > &coords) const
self_type & reshape(size_t i, D... rest)
NdArray(const std::vector< size_t > &shape_)
NdArray(std::shared_ptr< ContainerInterface > container, size_t offset, const std::vector< size_t > &shape, const std::vector< size_t > &stride, const std::vector< std::string > &attr_names)
T & at(const std::vector< size_t > &coords, const std::string &attr)
T & at_helper(size_t offset_acc, size_t axis, const std::string &attr)
NdArray(const std::vector< size_t > &shape_, const std::vector< std::string > &attr_names, Args &&... args)
NdArray(const self_type *other)
self_type slice(size_t i)
Iterator< true > const_iterator
T & at(const std::vector< size_t > &coords)
const T & at(size_t i, D... rest) const
bool operator!=(const self_type &b) const
self_type & reshape_helper(std::vector< size_t > &acc)
T & at(size_t i, D... rest)
T & at_helper(size_t offset_acc, size_t axis, size_t i, D... rest)
self_type rslice(size_t i)
const std::vector< size_t > shape() const
NdArray & operator=(const NdArray &)=default
std::shared_ptr< ContainerInterface > m_container
std::vector< size_t > m_shape
NdArray(const std::initializer_list< size_t > &shape_)
NdArray(const std::vector< size_t > &shape_, const Container< T > &data)
const_iterator begin() const
std::vector< size_t > m_stride_size
const T & at(const std::vector< size_t > &coords, const std::string &attr) const
NdArray(const self_type &)=default
T & at_helper(size_t offset_acc, size_t axis)
const T & at(const std::vector< size_t > &coords) const
const self_type rslice(size_t i) const
size_t get_attr_offset(const std::string &attr) const
const std::vector< std::string > & attributes() const
NdArray(self_type &&)=default
self_type & reshape_helper(std::vector< size_t > &acc, size_t i, D... rest)
Iterator< false > iterator
const T & at_helper(size_t offset_acc, size_t axis) const
NdArray(const std::vector< size_t > &shape_, Iterator begin, Iterator end)
bool operator==(const self_type &b) const
const T & at_helper(size_t offset_acc, size_t axis, size_t i, D... rest) const
self_type & reshape(const std::vector< size_t > &new_shape)
const_iterator end() const
virtual ~NdArray()=default
const self_type slice(size_t i) const
self_type & concatenate(const self_type &other)
std::ostream & operator<<(std::ostream &out, const NdArray< T > &ndarray)
T at(size_t offset) const
virtual ~ContainerInterface()=default
virtual std::unique_ptr< ContainerInterface > copy() const =0
Expected to generate a deep copy of the underlying data.
virtual void resize(const std::vector< size_t > &shape)=0
Resize container.
virtual size_t size() const =0
std::unique_ptr< ContainerInterface > copy() const final
Expected to generate a deep copy of the underlying data.
Container< T > m_container
ContainerWrapper(const ContainerWrapper &)=delete
~ContainerWrapper()=default
auto resizeImpl(const std::vector< size_t > &shape) -> decltype((void) std::declval< Container< T2 >>().resize(size_t{}), void())
void resize(const std::vector< size_t > &shape) final
ContainerWrapper(ContainerWrapper &&)=default
size_t size() const final
ContainerWrapper(Args &&... args)
auto resizeImpl(const std::vector< size_t > &shape) -> decltype((void) std::declval< Container< T2 >>().resize(std::vector< size_t >{}), void())