LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
ndarray::ArrayBase< Derived > Class Template Reference

CRTP implementation for Array and ArrayRef. More...

#include <ArrayBase.h>

Inheritance diagram for ndarray::ArrayBase< Derived >:
ndarray::ExpressionBase< Derived > ndarray::ArrayBaseN< Derived, N > ndarray::ArrayBaseN< Derived, 1 > ndarray::ArrayBaseN< Derived, 2 > ndarray::ArrayBaseN< Derived, 3 > ndarray::ArrayBaseN< Derived, 4 > ndarray::ArrayBaseN< Derived, 5 > ndarray::ArrayBaseN< Derived, 6 > ndarray::Array< double const, 2, 2 > ndarray::Array< double, 1, 1 > ndarray::Array< double, 2, 2 > ndarray::Array< ImagePixelT, 1, 1 > ndarray::Array< int, 1, 1 > ndarray::Array< int, 2, 2 > ndarray::Array< IntT, 1, 1 > ndarray::Array< MaskPixelT, 1, 1 > ndarray::Array< VariancePixelT, 1, 1 >

Classes

struct  ResultOf
 A template metafunction class to determine the result of a view indexing operation. More...
 

Public Types

typedef Traits::Element Element
 Data type of array elements. More...
 
typedef Traits::Iterator Iterator
 Nested array or element iterator. More...
 
typedef Traits::Reference Reference
 Nested array or element reference. More...
 
typedef Traits::Value Value
 Nested array or element value type. More...
 
typedef Traits::ND ND
 Number of dimensions (boost::mpl::int_). More...
 
typedef Traits::RMC RMC
 Number of guaranteed row-major contiguous dimensions, counted from the end (boost::mpl::int_). More...
 
typedef Vector< int, ND::value > Index
 Vector type for N-dimensional indices. More...
 
typedef ArrayRef< Element,
ND::value,-RMC::value > 
FullTranspose
 ArrayRef to a reverse-ordered contiguous array; the result of a call to transpose(). More...
 
typedef ArrayRef< Element,
ND::value, 0 > 
Transpose
 ArrayRef to a noncontiguous array; the result of a call to transpose(...). More...
 
typedef Array< Element,
ND::value, RMC::value > 
Shallow
 The corresponding Array type. More...
 
typedef ArrayRef< Element,
ND::value, RMC::value > 
Deep
 The corresponding ArrayRef type. More...
 
- Public Types inherited from ndarray::ExpressionBase< Derived >
typedef ExpressionTraits
< Derived >::Element 
Element
 Data type of expression elements. More...
 
typedef ExpressionTraits
< Derived >::ND 
ND
 Number of dimensions (boost::mpl::int_). More...
 
typedef ExpressionTraits
< Derived >::Iterator 
Iterator
 Nested expression or element iterator. More...
 
typedef ExpressionTraits
< Derived >::Reference 
Reference
 Nested expression or element reference. More...
 
typedef ExpressionTraits
< Derived >::Value 
Value
 Nested expression or element value type. More...
 
typedef Vector< int, ND::value > Index
 Vector type for N-dimensional indices. More...
 
typedef Derived Self
 CRTP derived type. More...
 
typedef Value value_type
 
typedef Iterator iterator
 
typedef Iterator const_iterator
 
typedef Reference reference
 
typedef Reference const_reference
 
typedef Iterator pointer
 
typedef int difference_type
 
typedef int size_type
 

Public Member Functions

Reference operator[] (int n) const
 Return a single subarray. More...
 
Elementoperator[] (Index const &i) const
 Return a single element from the array. More...
 
Iterator begin () const
 Return an Iterator to the beginning of the array. More...
 
Iterator end () const
 Return an Iterator to one past the end of the array. More...
 
ElementgetData () const
 Return a raw pointer to the first element of the array. More...
 
bool isEmpty () const
 Return true if the array has a null data point. More...
 
Manager::Ptr getManager () const
 Return the opaque object responsible for memory management. More...
 
template<int P>
int getSize () const
 Return the size of a specific dimension. More...
 
template<int P>
int getStride () const
 Return the stride in a specific dimension. More...
 
Index getShape () const
 Return a Vector of the sizes of all dimensions. More...
 
Index getStrides () const
 Return a Vector of the strides of all dimensions. More...
 
int getNumElements () const
 Return the total number of elements in the array. More...
 
FullTranspose transpose () const
 Return a view of the array with the order of the dimensions reversed. More...
 
Transpose transpose (Index const &order) const
 Return a view of the array with the dimensions permuted. More...
 
Shallow const shallow () const
 Return a Array view to this. More...
 
Deep const deep () const
 Return an ArrayRef view to this. More...
 
template<typename Seq >
ResultOf< View< Seq > >::Type operator[] (View< Seq > const &def) const
 Return a general view into this array (see Tutorial). More...
 
Eigen3 Interface

These methods return Eigen3 views to the array. Template parameters optionally control the expression type (Matrix/Array) and the compile-time dimensions.

The inline implementation is included by ndarray/eigen.h.

template<typename XprKind , int Rows, int Cols>
EigenView< Element, ND::value,
RMC::value, XprKind, Rows,
Cols > 
asEigen () const
 
template<typename XprKind >
EigenView< Element, ND::value,
RMC::value, XprKind > 
asEigen () const
 
template<int Rows, int Cols>
EigenView< Element, ND::value,
RMC::value, Eigen::MatrixXpr,
Rows, Cols > 
asEigen () const
 
EigenView< Element, ND::value,
RMC::value, Eigen::MatrixXpr > 
asEigen () const
 
- Public Member Functions inherited from ndarray::ExpressionBase< Derived >
Reference operator[] (int n) const
 Return a single nested expression or element. More...
 
Reference front () const
 Return the first nested expression or element. More...
 
Reference back () const
 Return the last nested expression or element. More...
 
Iterator begin () const
 Return an Iterator to the beginning of the expression. More...
 
Iterator end () const
 Return an Iterator to one past the end of the expression. More...
 
template<int P>
int getSize () const
 Return the size of a specific dimension. More...
 
Index getShape () const
 Return a Vector of the sizes of all dimensions. More...
 
int getNumElements () const
 Return the total number of elements in the expression. More...
 
size_type size () const
 Return the size of the first dimension. More...
 
bool empty () const
 Return true if the first dimension has no elements. More...
 

Protected Types

typedef ExpressionTraits< Derived > Traits
 
typedef Traits::Core Core
 
typedef Traits::CorePtr CorePtr
 

Protected Member Functions

void operator= (ArrayBase const &other)
 
 ArrayBase (Element *data, CorePtr const &core)
 
- Protected Member Functions inherited from ndarray::ExpressionBase< Derived >
SelfgetSelf ()
 
Self const & getSelf () const
 

Protected Attributes

Element_data
 
CorePtr _core
 

Friends

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

Detailed Description

template<typename Derived>
class ndarray::ArrayBase< Derived >

CRTP implementation for Array and ArrayRef.

Implements member functions that need specialization for 1D arrays.

Definition at line 56 of file ArrayBase.h.

Member Typedef Documentation

template<typename Derived>
typedef Traits::Core ndarray::ArrayBase< Derived >::Core
protected

Definition at line 59 of file ArrayBase.h.

template<typename Derived>
typedef Traits::CorePtr ndarray::ArrayBase< Derived >::CorePtr
protected

Definition at line 60 of file ArrayBase.h.

template<typename Derived>
typedef ArrayRef<Element,ND::value,RMC::value> ndarray::ArrayBase< Derived >::Deep

The corresponding ArrayRef type.

Definition at line 83 of file ArrayBase.h.

template<typename Derived>
typedef Traits::Element ndarray::ArrayBase< Derived >::Element

Data type of array elements.

Definition at line 63 of file ArrayBase.h.

template<typename Derived>
typedef ArrayRef<Element,ND::value,-RMC::value> ndarray::ArrayBase< Derived >::FullTranspose

ArrayRef to a reverse-ordered contiguous array; the result of a call to transpose().

Definition at line 77 of file ArrayBase.h.

template<typename Derived>
typedef Vector<int,ND::value> ndarray::ArrayBase< Derived >::Index

Vector type for N-dimensional indices.

Definition at line 75 of file ArrayBase.h.

template<typename Derived>
typedef Traits::Iterator ndarray::ArrayBase< Derived >::Iterator

Nested array or element iterator.

Definition at line 65 of file ArrayBase.h.

template<typename Derived>
typedef Traits::ND ndarray::ArrayBase< Derived >::ND

Number of dimensions (boost::mpl::int_).

Definition at line 71 of file ArrayBase.h.

template<typename Derived>
typedef Traits::Reference ndarray::ArrayBase< Derived >::Reference

Nested array or element reference.

Definition at line 67 of file ArrayBase.h.

template<typename Derived>
typedef Traits::RMC ndarray::ArrayBase< Derived >::RMC

Number of guaranteed row-major contiguous dimensions, counted from the end (boost::mpl::int_).

Definition at line 73 of file ArrayBase.h.

template<typename Derived>
typedef Array<Element,ND::value,RMC::value> ndarray::ArrayBase< Derived >::Shallow

The corresponding Array type.

Definition at line 81 of file ArrayBase.h.

template<typename Derived>
typedef ExpressionTraits<Derived> ndarray::ArrayBase< Derived >::Traits
protected

Definition at line 58 of file ArrayBase.h.

template<typename Derived>
typedef ArrayRef<Element,ND::value,0> ndarray::ArrayBase< Derived >::Transpose

ArrayRef to a noncontiguous array; the result of a call to transpose(...).

Definition at line 79 of file ArrayBase.h.

template<typename Derived>
typedef Traits::Value ndarray::ArrayBase< Derived >::Value

Nested array or element value type.

Definition at line 69 of file ArrayBase.h.

Constructor & Destructor Documentation

template<typename Derived>
ndarray::ArrayBase< Derived >::ArrayBase ( Element data,
CorePtr const &  core 
)
inlineprotected

Definition at line 235 of file ArrayBase.h.

235 : _data(data), _core(core) {}
Element * _data
Definition: ArrayBase.h:227

Member Function Documentation

template<typename Derived>
template<typename XprKind , int Rows, int Cols>
EigenView<Element,ND::value,RMC::value,XprKind,Rows,Cols> ndarray::ArrayBase< Derived >::asEigen ( ) const
template<typename Derived>
template<typename XprKind >
EigenView<Element,ND::value,RMC::value,XprKind> ndarray::ArrayBase< Derived >::asEigen ( ) const
template<typename Derived>
template<int Rows, int Cols>
EigenView<Element,ND::value,RMC::value,Eigen::MatrixXpr,Rows,Cols> ndarray::ArrayBase< Derived >::asEigen ( ) const
template<typename Derived >
EigenView< typename ArrayBase< Derived >::Element, ArrayBase< Derived >::ND::value, ArrayBase< Derived >::RMC::value, Eigen::MatrixXpr > ndarray::ArrayBase< Derived >::asEigen ( ) const
inline

Definition at line 403 of file eigen.h.

403  {
404  return EigenView<typename ArrayBase<Derived>::Element, ArrayBase<Derived>::ND::value,
405  ArrayBase<Derived>::RMC::value, XprKind, Rows, Cols>(this->getSelf());
406 }
template<typename Derived>
Iterator ndarray::ArrayBase< Derived >::begin ( void  ) const
inline

Return an Iterator to the beginning of the array.

Definition at line 99 of file ArrayBase.h.

99  {
100  return Traits::makeIterator(
101  this->_data,
102  this->_core,
103  this->template getStride<0>()
104  );
105  }
Element * _data
Definition: ArrayBase.h:227
template<typename Derived>
Deep const ndarray::ArrayBase< Derived >::deep ( ) const
inline

Return an ArrayRef view to this.

Definition at line 178 of file ArrayBase.h.

178 { return Deep(this->getSelf()); }
ArrayRef< Element, ND::value, RMC::value > Deep
The corresponding ArrayRef type.
Definition: ArrayBase.h:83
template<typename Derived>
Iterator ndarray::ArrayBase< Derived >::end ( void  ) const
inline

Return an Iterator to one past the end of the array.

Definition at line 108 of file ArrayBase.h.

108  {
109  return Traits::makeIterator(
110  this->_data + this->template getSize<0>() * this->template getStride<0>(),
111  this->_core,
112  this->template getStride<0>()
113  );
114  }
Element * _data
Definition: ArrayBase.h:227
template<typename Derived>
Element* ndarray::ArrayBase< Derived >::getData ( ) const
inline

Return a raw pointer to the first element of the array.

Definition at line 117 of file ArrayBase.h.

117 { return _data; }
Element * _data
Definition: ArrayBase.h:227
template<typename Derived>
Manager::Ptr ndarray::ArrayBase< Derived >::getManager ( ) const
inline

Return the opaque object responsible for memory management.

Definition at line 123 of file ArrayBase.h.

123 { return this->_core->getManager(); }
template<typename Derived>
int ndarray::ArrayBase< Derived >::getNumElements ( ) const
inline

Return the total number of elements in the array.

Definition at line 142 of file ArrayBase.h.

142 { return this->_core->getNumElements(); }
template<typename Derived>
Index ndarray::ArrayBase< Derived >::getShape ( ) const
inline

Return a Vector of the sizes of all dimensions.

Definition at line 136 of file ArrayBase.h.

136 { Index r; this->_core->fillShape(r); return r; }
Vector< int, ND::value > Index
Vector type for N-dimensional indices.
Definition: ArrayBase.h:75
template<typename Derived>
template<int P>
int ndarray::ArrayBase< Derived >::getSize ( ) const
inline

Return the size of a specific dimension.

Definition at line 126 of file ArrayBase.h.

126  {
127  return detail::getDimension<P>(*this->_core).getSize();
128  }
int getSize() const
Return the size of a specific dimension.
Definition: ArrayBase.h:126
template<typename Derived>
template<int P>
int ndarray::ArrayBase< Derived >::getStride ( ) const
inline

Return the stride in a specific dimension.

Definition at line 131 of file ArrayBase.h.

131  {
132  return detail::getDimension<P>(*this->_core).getStride();
133  }
int getStride() const
Return the stride in a specific dimension.
Definition: ArrayBase.h:131
template<typename Derived>
Index ndarray::ArrayBase< Derived >::getStrides ( ) const
inline

Return a Vector of the strides of all dimensions.

Definition at line 139 of file ArrayBase.h.

139 { Index r; this->_core->fillStrides(r); return r; }
Vector< int, ND::value > Index
Vector type for N-dimensional indices.
Definition: ArrayBase.h:75
template<typename Derived>
bool ndarray::ArrayBase< Derived >::isEmpty ( ) const
inline

Return true if the array has a null data point.

Definition at line 120 of file ArrayBase.h.

120 { return _data == 0; }
Element * _data
Definition: ArrayBase.h:227
template<typename Derived>
void ndarray::ArrayBase< Derived >::operator= ( ArrayBase< Derived > const &  other)
inlineprotected

Definition at line 230 of file ArrayBase.h.

230  {
231  _data = other._data;
232  _core = other._core;
233  }
Element * _data
Definition: ArrayBase.h:227
template<typename Derived>
Reference ndarray::ArrayBase< Derived >::operator[] ( int  n) const
inline

Return a single subarray.

Definition at line 86 of file ArrayBase.h.

86  {
87  return Traits::makeReference(
88  this->_data + n * this->template getStride<0>(),
89  this->_core
90  );
91  }
Element * _data
Definition: ArrayBase.h:227
template<typename Derived>
Element& ndarray::ArrayBase< Derived >::operator[] ( Index const &  i) const
inline

Return a single element from the array.

Definition at line 94 of file ArrayBase.h.

94  {
95  return *(this->_data + this->_core->template computeOffset(i));
96  }
Element * _data
Definition: ArrayBase.h:227
template<typename Derived>
template<typename Seq >
ResultOf< View<Seq> >::Type ndarray::ArrayBase< Derived >::operator[] ( View< Seq > const &  def) const
inline

Return a general view into this array (see Tutorial).

Definition at line 215 of file ArrayBase.h.

215  {
216  return detail::buildView(this->getSelf(), def._seq);
217  }
ViewBuilder< Array_, Seq_ >::OutputArray buildView(Array_ const &array, Seq_ const &seq)
Definition: ViewBuilder.h:320
template<typename Derived>
Shallow const ndarray::ArrayBase< Derived >::shallow ( ) const
inline

Return a Array view to this.

Definition at line 175 of file ArrayBase.h.

175 { return Shallow(this->getSelf()); }
Array< Element, ND::value, RMC::value > Shallow
The corresponding Array type.
Definition: ArrayBase.h:81
template<typename Derived>
FullTranspose ndarray::ArrayBase< Derived >::transpose ( ) const
inline

Return a view of the array with the order of the dimensions reversed.

Definition at line 145 of file ArrayBase.h.

145  {
146  Index shape = getShape();
147  Index strides = getStrides();
148  for (int n=0; n < ND::value / 2; ++n) {
149  std::swap(shape[n], shape[ND::value-n-1]);
150  std::swap(strides[n], strides[ND::value-n-1]);
151  }
152  return FullTranspose(
153  getData(),
154  Core::create(shape, strides, getManager())
155  );
156  }
Index getStrides() const
Return a Vector of the strides of all dimensions.
Definition: ArrayBase.h:139
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
Definition: Image.cc:291
Vector< int, ND::value > Index
Vector type for N-dimensional indices.
Definition: ArrayBase.h:75
Index getShape() const
Return a Vector of the sizes of all dimensions.
Definition: ArrayBase.h:136
Element * getData() const
Return a raw pointer to the first element of the array.
Definition: ArrayBase.h:117
ArrayRef< Element, ND::value,-RMC::value > FullTranspose
ArrayRef to a reverse-ordered contiguous array; the result of a call to transpose().
Definition: ArrayBase.h:77
Manager::Ptr getManager() const
Return the opaque object responsible for memory management.
Definition: ArrayBase.h:123
template<typename Derived>
Transpose ndarray::ArrayBase< Derived >::transpose ( Index const &  order) const
inline

Return a view of the array with the dimensions permuted.

Definition at line 159 of file ArrayBase.h.

159  {
160  Index newShape;
161  Index newStrides;
162  Index oldShape = getShape();
163  Index oldStrides = getStrides();
164  for (int n=0; n < ND::value; ++n) {
165  newShape[n] = oldShape[order[n]];
166  newStrides[n] = oldStrides[order[n]];
167  }
168  return Transpose(
169  getData(),
170  Core::create(newShape, newStrides, getManager())
171  );
172  }
Index getStrides() const
Return a Vector of the strides of all dimensions.
Definition: ArrayBase.h:139
Vector< int, ND::value > Index
Vector type for N-dimensional indices.
Definition: ArrayBase.h:75
Index getShape() const
Return a Vector of the sizes of all dimensions.
Definition: ArrayBase.h:136
Element * getData() const
Return a raw pointer to the first element of the array.
Definition: ArrayBase.h:117
ArrayRef< Element, ND::value, 0 > Transpose
ArrayRef to a noncontiguous array; the result of a call to transpose(...).
Definition: ArrayBase.h:79
Manager::Ptr getManager() const
Return the opaque object responsible for memory management.
Definition: ArrayBase.h:123

Friends And Related Function Documentation

template<typename Derived>
template<typename Derived_ >
friend class ArrayBase
friend

Definition at line 224 of file ArrayBase.h.

template<typename Derived>
template<typename T_ , int N_, int C_>
friend class Array
friend

Definition at line 220 of file ArrayBase.h.

template<typename Derived>
template<typename T_ , int N_, int C_>
friend class ArrayRef
friend

Definition at line 221 of file ArrayBase.h.

template<typename Derived>
template<typename T_ , int N_, int C_>
friend struct ArrayTraits
friend

Definition at line 222 of file ArrayBase.h.

template<typename Derived>
template<typename Array_ >
friend class detail::ArrayAccess
friend

Definition at line 225 of file ArrayBase.h.

template<typename Derived>
template<typename T_ , int N_, int C_>
friend class detail::NestedIterator
friend

Definition at line 223 of file ArrayBase.h.

Member Data Documentation

template<typename Derived>
CorePtr ndarray::ArrayBase< Derived >::_core
protected

Definition at line 228 of file ArrayBase.h.

template<typename Derived>
Element* ndarray::ArrayBase< Derived >::_data
protected

Definition at line 227 of file ArrayBase.h.


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