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

A fixed-size 1D array class. More...

#include <Vector.h>

Public Types

typedef T Element
 
typedef T Value
 
typedef T & Reference
 
typedef T const & ConstReference
 
typedef T * Iterator
 
typedef T const * ConstIterator
 
typedef Value value_type
 
typedef Iterator iterator
 
typedef ConstIterator const_iterator
 
typedef Reference reference
 
typedef ConstReference const_reference
 
typedef boost::reverse_iterator< T * > reverse_iterator
 
typedef boost::reverse_iterator< const T * > const_reverse_iterator
 
typedef T * pointer
 
typedef int difference_type
 
typedef int size_type
 
typedef boost::mpl::int_< N > ND
 

Public Member Functions

size_type size () const
 Return the size of the Vector.
 
size_type max_size () const
 Return the size of the Vector.
 
bool empty () const
 
iterator begin ()
 Return an iterator to the beginning of the Vector.
 
const_iterator begin () const
 Return a const_iterator to the beginning of the Vector.
 
iterator end ()
 Return an iterator to the end of the Vector.
 
const_iterator end () const
 Return a const_iterator to the end of the Vector.
 
reverse_iterator rbegin ()
 Return a reverse_iterator to the beginning of the reversed Vector.
 
const_reverse_iterator rbegin () const
 Return a const_reverse_iterator to the beginning of the reversed Vector.
 
reverse_iterator rend ()
 Return a reverse_iterator to the end of the reversed Vector.
 
const_reverse_iterator rend () const
 Return a const_reverse_iterator to the end of the reversed Vector.
 
reference front ()
 Return a reference to the first element.
 
reference back ()
 Return a reference to the last element.
 
const_reference front () const
 Return a const_reference to the first element.
 
const_reference back () const
 Return a const_reference to the last element.
 
reference operator[] (int i)
 Return a reference to the element with the given index.
 
const_reference operator[] (int i) const
 Return a const_reference to the element with the given index.
 
template<int Start, int Stop>
Vector< T, Stop-Start > getRange () const
 Create a new Vector that is a subset of this.
 
template<int M>
Vector< T, M > first () const
 Create a new Vector from the first M elements of this.
 
template<int M>
Vector< T, M > last () const
 Create a new Vector from the last M elements of this.
 
 Vector ()
 Default constructor.
 
 Vector (T scalar)
 Construct with copies of a scalar.
 
template<typename U >
 Vector (Vector< U, N > const &other)
 Converting copy constructor.
 
bool operator== (Vector const &other) const
 Return true if elements of other are equal to the elements of this.
 
bool operator!= (Vector const &other) const
 Return false if any elements of other are not equal to the elements of this.
 
sum () const
 Return the sum of all elements.
 
product () const
 Return the product of all elements.
 
Vector reverse () const
 Return a Vector with the elements reversed.
 
template<typename U >
Vector< U, N > cast () const
 Cast the vector element-wise to another type.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator= (Vector< U, N > const &other)
 Augmented = assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator= (U scalar)
 Augmented = assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator+= (Vector< U, N > const &other)
 Augmented += assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator+= (U scalar)
 Augmented += assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator-= (Vector< U, N > const &other)
 Augmented -= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator-= (U scalar)
 Augmented -= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator*= (Vector< U, N > const &other)
 Augmented *= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator*= (U scalar)
 Augmented *= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator/= (Vector< U, N > const &other)
 Augmented /= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator/= (U scalar)
 Augmented /= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator%= (Vector< U, N > const &other)
 Augmented %= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator%= (U scalar)
 Augmented %= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator&= (Vector< U, N > const &other)
 Augmented &= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator&= (U scalar)
 Augmented &= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator^= (Vector< U, N > const &other)
 Augmented ^= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator^= (U scalar)
 Augmented ^= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator|= (Vector< U, N > const &other)
 Augmented |= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator|= (U scalar)
 Augmented |= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator<<= (Vector< U, N > const &other)
 Augmented <<= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator<<= (U scalar)
 Augmented <<= assignment from a scalar.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator>>= (Vector< U, N > const &other)
 Augmented >>= assignment from another vector.
 
template<typename U >
boost::enable_if< boost::is_convertible< U, T >, Vector & >::type operator>>= (U scalar)
 Augmented >>= assignment from a scalar.
 

Public Attributes

elems [N]
 

Friends

std::ostream & operator<< (std::ostream &os, Vector< T, N > const &obj)
 Stream output.
 

Detailed Description

template<typename T, int N>
class ndarray::Vector< T, N >

A fixed-size 1D array class.

Vector is primarily used as the data type for the shape (with T==Size) and strides (with T==Offset) attributes of Array.

Vector is implemented almost exactly as a non-aggregate boost::array, but with the addition of mathematical operators and a few other utility functions.

Constructor & Destructor Documentation

◆ Vector()

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

Default constructor.

Initializes the elements to zero.

Member Function Documentation

◆ max_size()

template<typename T , int N>
size_type ndarray::Vector< T, N >::max_size ( ) const
inline

Return the size of the Vector.

Return true if size() == 0.


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