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> {
211 template <
template <
class...>
class Container =
std::vector>
228 template <
template <
class...>
class Container =
std::vector>
249 template <
template <
class...>
class Container =
std::vector>
264 template <
typename Iterator>
277 template <
typename... Args>
363 template <
typename... D>
369 const T&
front()
const;
421 template <
typename... D>
422 T&
at(
size_t i, D... rest);
434 template <
typename... D>
435 const T&
at(
size_t i, D... rest)
const;
519 T
get(
size_t offset)
const {
520 return *
reinterpret_cast<T*
>(
m_data_ptr + offset);
524 T&
get(
size_t offset) {
525 return *
reinterpret_cast<T*
>(
m_data_ptr + offset);
529 virtual size_t size()
const = 0;
532 virtual size_t nbytes()
const = 0;
541 template <
template <
class...>
class Container>
542 struct ContainerWrapper :
public ContainerInterface {
553 template <
typename... Args>
562 template <
typename T2>
567 template <
typename T2>
573 return nbytesImpl<T>(0);
576 template <
typename T2>
582 template <
typename T2>
597 resizeImpl<T>(
shape);
602 return Euclid::make_unique<ContainerWrapper>(
m_container);
654 template <
typename... D>
655 T&
at_helper(
size_t offset_acc,
size_t axis,
size_t i, D... rest);
660 T&
at_helper(
size_t offset_acc,
size_t axis);
670 template <
typename... D>
671 const T&
at_helper(
size_t offset_acc,
size_t axis,
size_t i, D... rest)
const;
676 const T&
at_helper(
size_t offset_acc,
size_t axis)
const;
683 template <
typename... D>
692 template <
typename T>
693 std::ostream& operator<<(std::ostream& out, const NdArray<T>& ndarray);
702 #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)
virtual size_t nbytes() const =0
Get the size in bytes.
ContainerWrapper(const ContainerWrapper &)=delete
NdArray(std::vector< size_t > shape_)
Container< T > m_container
Iterator & operator-=(size_t n)
~ContainerWrapper()=default
self_type & reshape_helper(std::vector< size_t > &acc, size_t i, D...rest)
bool operator==(const self_type &b) const
std::unique_ptr< Details > m_details_ptr
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)
size_t nbytesImpl(...) const
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
ContainerWrapper(Args &&...args)
size_t shape(std::size_t i) const
Iterator operator+(size_t n) const
std::unique_ptr< ContainerInterface > copy() const final
Expected to generate a deep copy of the underlying data.
self_type & concatenate(const self_type &other)
NdArray(const std::initializer_list< size_t > &shape_)
std::vector< size_t > m_shape
Iterator operator-(size_t n) const
virtual ~ContainerInterface()=default
Iterator & operator+=(size_t n)
bool operator<(const Iterator &other)
auto nbytesImpl(int) const -> decltype(std::declval< Container< T2 >>().nbytes())
bool operator!=(const Iterator &other) const
virtual size_t size() const =0
Iterator< true > const_iterator
self_type rslice(size_t i)
self_type & reshape(const std::vector< size_t > &new_shape)
Iterator< false > iterator
T & at(const std::vector< size_t > &coords)
std::size_t strides(std::size_t i) const
std::shared_ptr< ContainerInterface > m_container
void resize(const std::vector< size_t > &shape) final
typename std::conditional< Const, const T, T >::type value_t
size_t nbytes() const final
Get the size in bytes.
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< size_t > m_stride_size
bool operator==(const Iterator &other) const
ContainerInterface * m_container_ptr
size_t size() const final
std::vector< std::string > m_attr_names
virtual std::unique_ptr< ContainerInterface > copy() const =0
Expected to generate a deep copy of the underlying data.