25 #ifndef ALEXANDRIA_NDARRAY_H
26 #define ALEXANDRIA_NDARRAY_H
50 template <
template <
class...>
class Container =
std::vector>
62 class Iterator :
public std::iterator<std::random_access_iterator_tag, typename std::conditional<Const, const T, T>::type> {
199 template <
template <
class...>
class Container =
std::vector>
216 template <
template <
class...>
class Container =
std::vector>
231 template <
typename Iterator>
244 template <
typename... Args>
314 template <
typename... D>
367 template <
typename... D>
368 T&
at(
size_t i, D... rest);
380 template <
typename... D>
381 const T&
at(
size_t i, D... rest)
const;
447 T
at(
size_t offset)
const {
452 T&
at(
size_t offset) {
457 virtual size_t size()
const = 0;
466 template <
template <
class...>
class Container>
477 template <
typename... Args>
486 template <
typename T2>
492 template <
typename T2>
506 resizeImpl<T>(
shape);
511 return Euclid::make_unique<ContainerWrapper>(
m_container);
544 template <
typename... D>
560 template <
typename... D>
568 template <
typename... D>
577 template <
typename T>
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)
ContainerInterface * m_container_ptr
bool operator==(const Iterator &other) const
value_t operator*() const
Iterator(const Iterator< false > &other)
Iterator operator-(size_t n)
Iterator(ContainerInterface *container_ptr, size_t offset)
difference_type operator-(const Iterator &other)
NdArray(const std::vector< size_t > &shape_, Container< T > &&data)
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_)
T & at(const std::vector< size_t > &coords, const std::string &attr)
NdArray(const std::vector< size_t > &shape_, const std::vector< std::string > &attr_names, Args &&... args)
T & at_helper(std::vector< size_t > &acc, const std::string &attr)
NdArray(const self_type *other)
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)
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
T & at_helper(std::vector< size_t > &acc, size_t i, D... rest)
NdArray(const self_type &)=default
const T & at(const std::vector< size_t > &coords) const
const std::vector< std::string > & attributes() const
const T & at_helper(std::vector< size_t > &acc, size_t i, D... rest) const
NdArray(self_type &&)=default
self_type & reshape_helper(std::vector< size_t > &acc, size_t i, D... rest)
Iterator< false > iterator
NdArray(const std::vector< size_t > &shape_, Iterator begin, Iterator end)
bool operator==(const self_type &b) const
self_type & reshape(const std::vector< size_t > new_shape)
T & at_helper(std::vector< size_t > &acc)
const_iterator end() const
size_t get_offset(std::vector< size_t > coords, const std::string &attr) const
virtual ~NdArray()=default
const T & at_helper(std::vector< size_t > &acc) 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())