ndarray
NumPy-friendly multidimensional arrays in C++
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
ndarray::Array< T, N, C > Class Template Reference

A multidimensional strided array. More...

#include <Array.h>

Inheritance diagram for ndarray::Array< T, N, C >:
ndarray::ArrayBaseN< Array< T, N, C > > ndarray::ArrayBase< Derived > ndarray::ExpressionBase< Derived >

Public Member Functions

 Array ()
 Default constructor.
 
 Array (Array const &other)
 Non-converting copy constructor.
 
template<typename T_ , int C_>
 Array (Array< T_, N, C_ > const &other, typename boost::enable_if< detail::Convertible< N, T_, C_, T, C >, void * >::type=0)
 Converting copy constructor.
 
template<typename T_ , int C_>
 Array (ArrayRef< T_, N, C_ > const &other, typename boost::enable_if< detail::Convertible< N, T_, C_, T, C >, void * >::type=0)
 Converting copy constructor.
 
 Array (Size n1, Size n2=1, Size n3=1, Size n4=1, Size n5=1, Size n6=1, Size n7=1, Size n8=1)
 Construct an array with the given dimensions and allocated but uninitialized memory.
 
template<typename U >
 Array (Vector< U, N > const &shape)
 Construct an array with the given dimensions and allocated but uninitialized memory.
 
Arrayoperator= (Array const &other)
 Non-converting shallow assignment.
 
template<typename T_ , int C_>
boost::enable_if< detail::Convertible< N, T_, C_, T, C >, Array & >::type operator= (Array< T_, N, C_ > const &other)
 Converting shallow assignment.
 
template<typename T_ , int C_>
boost::enable_if< detail::Convertible< N, T_, C_, T, C >, Array & >::type operator= (ArrayRef< T_, N, C_ > const &other)
 Converting shallow assignment.
 
template<typename T_ , int N_, int C_>
bool operator== (Array< T_, N_, C_ > const &other) const
 Shallow equality comparison: return true if the arrays share data and have the same shape and strides.
 
template<typename T_ , int N_, int C_>
bool operator!= (Array< T_, N_, C_ > const &other) const
 Shallow inequality comparison.
 
void swap (Array &other)
 Lightweight shallow swap.
 
bool isUnique () const
 Return true if the Array is definitely unique.
 
- Public Member Functions inherited from ndarray::ArrayBase< Derived >
Reference operator[] (Size n) const
 Return a single subarray.
 
Elementoperator[] (Index const &i) const
 Return a single element from the array.
 
Iterator begin () const
 Return an Iterator to the beginning of the array.
 
Iterator end () const
 Return an Iterator to one past the end of the array.
 
ElementgetData () const
 Return a raw pointer to the first element of the array.
 
bool isEmpty () const
 Return true if the array has a null data point.
 
Manager::Ptr getManager () const
 Return the opaque object responsible for memory management.
 
template<int P>
Size getSize () const
 Return the size of a specific dimension.
 
template<int P>
Offset getStride () const
 Return the stride in a specific dimension.
 
Index getShape () const
 Return a Vector of the sizes of all dimensions.
 
Strides getStrides () const
 Return a Vector of the strides of all dimensions.
 
Size getNumElements () const
 Return the total number of elements in the array.
 
FullTranspose transpose () const
 Return a view of the array with the order of the dimensions reversed.
 
Transpose transpose (Index const &order) const
 Return a view of the array with the dimensions permuted.
 
Shallow const shallow () const
 Return a Array view to this.
 
Deep const deep () const
 Return an ArrayRef view to this.
 
template<typename Seq >
ResultOf< View< Seq > >::Type operator[] (View< Seq > const &def) const
 Return a general view into this array (see Tutorial).
 
- Public Member Functions inherited from ndarray::ExpressionBase< Derived >
Reference operator[] (Size n) const
 Return a single nested expression or element.
 
Reference front () const
 Return the first nested expression or element.
 
Reference back () const
 Return the last nested expression or element.
 
Iterator begin () const
 Return an Iterator to the beginning of the expression.
 
Iterator end () const
 Return an Iterator to one past the end of the expression.
 
template<int P>
Size getSize () const
 Return the size of a specific dimension.
 
Index getShape () const
 Return a Vector of the sizes of all dimensions.
 
Size getNumElements () const
 Return the total number of elements in the expression.
 
size_type size () const
 Return the size of the first dimension.
 
bool empty () const
 Return true if the first dimension has no elements.
 

Friends

template<typename T_ , int N_, int C_>
class ArrayRef
 
template<typename T_ , int N_, int C_>
struct ArrayTraits
 
template<typename Derived >
class ArrayBase
 
template<typename Array_ >
class detail::ArrayAccess
 

Additional Inherited Members

- Public Types inherited from ndarray::ArrayBaseN< Array< T, N, C > >
typedef Super::Element Element
 
- Public Types inherited from ndarray::ArrayBase< Derived >
typedef Traits::Element Element
 Data type of array elements.
 
typedef Traits::Iterator Iterator
 Nested array or element iterator.
 
typedef Traits::Reference Reference
 Nested array or element reference.
 
typedef Traits::Value Value
 Nested array or element value type.
 
typedef Traits::ND ND
 Number of dimensions (boost::mpl::int_).
 
typedef Traits::RMC RMC
 Number of guaranteed row-major contiguous dimensions, counted from the end (boost::mpl::int_).
 
typedef Vector< Size, ND::value > Index
 Vector type for N-dimensional indices and shapes.
 
typedef Vector< Offset, ND::value > Strides
 Vector type for N-dimensional offsets and strides.
 
typedef ArrayRef< Element, ND::value,-RMC::value > FullTranspose
 ArrayRef to a reverse-ordered contiguous array; the result of a call to transpose().
 
typedef ArrayRef< Element, ND::value, 0 > Transpose
 ArrayRef to a noncontiguous array; the result of a call to transpose(...).
 
typedef Array< Element, ND::value, RMC::value > Shallow
 The corresponding Array type.
 
typedef ArrayRef< Element, ND::value, RMC::value > Deep
 The corresponding ArrayRef type.
 
- Public Types inherited from ndarray::ExpressionBase< Derived >
typedef ExpressionTraits< Derived >::Element Element
 Data type of expression elements.
 
typedef ExpressionTraits< Derived >::ND ND
 Number of dimensions (boost::mpl::int_).
 
typedef ExpressionTraits< Derived >::Iterator Iterator
 Nested expression or element iterator.
 
typedef ExpressionTraits< Derived >::Reference Reference
 Nested expression or element reference.
 
typedef ExpressionTraits< Derived >::Value Value
 Nested expression or element value type.
 
typedef Vector< Size, ND::value > Index
 Vector type for N-dimensional indices.
 
typedef Derived Self
 CRTP derived type.
 
typedef Value value_type
 
typedef Iterator iterator
 
typedef Iterator const_iterator
 
typedef Reference reference
 
typedef Reference const_reference
 
typedef Iterator pointer
 
typedef Offset difference_type
 
typedef Size size_type
 
- Protected Types inherited from ndarray::ArrayBaseN< Array< T, N, C > >
typedef Super::Core Core
 
typedef Super::CorePtr CorePtr
 
- Protected Types inherited from ndarray::ArrayBase< Derived >
typedef ExpressionTraits< Derived > Traits
 
typedef Traits::Core Core
 
typedef Traits::CorePtr CorePtr
 
- Protected Member Functions inherited from ndarray::ArrayBase< Derived >
void operator= (ArrayBase const &other)
 
template<typename Other >
 ArrayBase (ArrayBase< Other > const &other)
 
 ArrayBase (Element *data, CorePtr const &core)
 
- Protected Member Functions inherited from ndarray::ExpressionBase< Derived >
SelfgetSelf ()
 
Self const & getSelf () const
 
- Protected Attributes inherited from ndarray::ArrayBase< Derived >
Element_data
 
CorePtr _core
 

Detailed Description

template<typename T, int N, int C>
class ndarray::Array< T, N, C >

A multidimensional strided array.

Array is the workhorse class of the ndarray library.

Constructor & Destructor Documentation

◆ Array() [1/5]

template<typename T , int N, int C>
ndarray::Array< T, N, C >::Array ( )
inline

Default constructor.

Creates an empty array with zero dimensions and null memory.

◆ Array() [2/5]

template<typename T , int N, int C>
template<typename T_ , int C_>
ndarray::Array< T, N, C >::Array ( Array< T_, N, C_ > const &  other,
typename boost::enable_if< detail::Convertible< N, T_, C_, T, C >, void * >::type  = 0 
)
inline

Converting copy constructor.

Implicit conversion is allowed for non-const to const and for more guaranteed RMC to less guaranteed RMC (see ndarray; Multidimensional Arrays in C++).

◆ Array() [3/5]

template<typename T , int N, int C>
template<typename T_ , int C_>
ndarray::Array< T, N, C >::Array ( ArrayRef< T_, N, C_ > const &  other,
typename boost::enable_if< detail::Convertible< N, T_, C_, T, C >, void * >::type  = 0 
)
inline

Converting copy constructor.

Implicit conversion is allowed for non-const to const and for more guaranteed RMC to less guaranteed RMC (see ndarray; Multidimensional Arrays in C++).

◆ Array() [4/5]

template<typename T , int N, int C>
ndarray::Array< T, N, C >::Array ( Size  n1,
Size  n2 = 1,
Size  n3 = 1,
Size  n4 = 1,
Size  n5 = 1,
Size  n6 = 1,
Size  n7 = 1,
Size  n8 = 1 
)
explicit

Construct an array with the given dimensions and allocated but uninitialized memory.

Unspecified dimensions will have unit size, and if the number of argmuments is greater than the number of dimensions of the array, the extra arguments will be silently ignored.

This is implemented in initialization.h.

◆ Array() [5/5]

template<typename T , int N, int C>
template<typename U >
ndarray::Array< T, N, C >::Array ( Vector< U, N > const &  shape)
explicit

Construct an array with the given dimensions and allocated but uninitialized memory.

This is implemented in initialization.h.

Member Function Documentation

◆ isUnique()

template<typename T , int N, int C>
bool ndarray::Array< T, N, C >::isUnique ( ) const
inline

Return true if the Array is definitely unique.

This will only return true if the manager overrides Manager::isUnique(); this is true for the SimpleManager used by ndarray::allocate, but it is not true for ExternalManager.

◆ operator=() [1/2]

template<typename T , int N, int C>
template<typename T_ , int C_>
boost::enable_if< detail::Convertible< N, T_, C_, T, C >, Array & >::type ndarray::Array< T, N, C >::operator= ( Array< T_, N, C_ > const &  other)
inline

Converting shallow assignment.

Implicit conversion is allowed for non-const -> const and for more guaranteed RMC -> less guaranteed RMC (see ndarray; Multidimensional Arrays in C++).

◆ operator=() [2/2]

template<typename T , int N, int C>
template<typename T_ , int C_>
boost::enable_if< detail::Convertible< N, T_, C_, T, C >, Array & >::type ndarray::Array< T, N, C >::operator= ( ArrayRef< T_, N, C_ > const &  other)
inline

Converting shallow assignment.

Implicit conversion is allowed for non-const -> const and for more guaranteed RMC -> less guaranteed RMC (see ndarray; Multidimensional Arrays in C++).


The documentation for this class was generated from the following files: