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>
467 struct ContainerWrapper :
public ContainerInterface {
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>
578 std::ostream& operator<<(std::ostream& out, const NdArray<T>& ndarray);
587 #endif // ALEXANDRIA_NDARRAY_H
bool operator>(const Iterator &other)
ContainerWrapper(const ContainerWrapper &)=delete
const std::vector< size_t > shape() const
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
const std::vector< std::string > & attributes() const
NdArray(const std::vector< size_t > &shape_)
T at(size_t offset) const
auto resizeImpl(const std::vector< size_t > &shape) -> decltype((void) std::declval< Container< T2 >>().resize(std::vector< size_t >
ContainerWrapper(Args &&...args)
Iterator< false > iterator
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_)
T & at_helper(std::vector< size_t > &acc, size_t i, D...rest)
virtual ~NdArray()=default
virtual ~ContainerInterface()=default
Iterator & operator+=(size_t n)
Iterator operator-(size_t n)
bool operator<(const Iterator &other)
Iterator(ContainerInterface *container_ptr, size_t offset)
NdArray & operator=(const NdArray &)=default
bool operator!=(const Iterator &other) const
virtual size_t size() const =0
std::shared_ptr< ContainerInterface > m_container
T & at(const std::vector< size_t > &coords)
Iterator< true > const_iterator
void resize(const std::vector< size_t > &shape) final
typename std::conditional< Const, const T, T >::type value_t
size_t get_offset(const std::vector< size_t > &coords) const
Iterator operator+(size_t n)
std::vector< std::string > m_attr_names
self_type & reshape(const std::vector< size_t > new_shape)
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.