11#ifndef NDARRAY_ArrayBase_h_INCLUDED
12#define NDARRAY_ArrayBase_h_INCLUDED
21#include <boost/iterator/counting_iterator.hpp>
42template <
typename Derived>
46 typedef typename Traits::Core Core;
47 typedef typename Traits::CorePtr CorePtr;
56 typedef typename Traits::Value
Value;
58 typedef typename Traits::ND
ND;
60 typedef typename Traits::RMC
RMC;
76 return Traits::makeReference(
77 this->_data + n * this->
88 return *(this->_data + this->_core->
97 return Traits::makeIterator(
110 return Traits::makeIterator(
115 getSize<0>() * this->
136 Manager::Ptr
getManager()
const {
return this->_core->getManager(); }
140 return detail::getDimension<P>(*this->_core).getSize();
145 return detail::getDimension<P>(*this->_core).getStride();
161 for (
int n=0; n < ND::value / 2; ++n) {
162 std::swap(shape[n], shape[ND::value-n-1]);
163 std::swap(strides[n], strides[ND::value-n-1]);
177 for (
int n=0; n < ND::value; ++n) {
178 newShape[n] = oldShape[order[n]];
179 newStrides[n] = oldStrides[order[n]];
183 Core::create(newShape, newStrides,
getManager())
194 template <
typename View_>
204 template <
typename Seq>
207 return detail::buildView(this->getSelf(), def.
_seq);
211 template <
typename T_,
int N_,
int C_>
friend class Array;
212 template <
typename T_,
int N_,
int C_>
friend class ArrayRef;
213 template <
typename T_,
int N_,
int C_>
friend struct ArrayTraits;
215 template <
typename Derived_>
friend class ArrayBase;
221 void operator=(
ArrayBase const & other) {
226 template <
typename Other>
227 ArrayBase(ArrayBase<Other>
const & other) : _data(other._data), _core(other._core) {}
229 ArrayBase(
Element * data, CorePtr
const & core) : _data(data), _core(core) {}
Definitions for ArrayAccess.
Definitions for ExpressionBase.
Definition of NestedIterator.
Definition of StridedIterator.
Implementation of arbitrary views into arrays.
CRTP implementation for Array and ArrayRef.
Definition ArrayBase.h:43
Offset getStride() const
Return the stride in a specific dimension.
Definition ArrayBase.h:144
Manager::Ptr getManager() const
Return the opaque object responsible for memory management.
Definition ArrayBase.h:136
Shallow const shallow() const
Return a Array view to this.
Definition ArrayBase.h:188
Reference operator[](Size n) const
Return a single subarray.
Definition ArrayBase.h:75
FullTranspose transpose() const
Return a view of the array with the order of the dimensions reversed.
Definition ArrayBase.h:158
ArrayRef< Element, ND::value,-RMC::value > FullTranspose
ArrayRef to a reverse-ordered contiguous array; the result of a call to transpose().
Definition ArrayBase.h:66
Array< Element, ND::value, RMC::value > Shallow
The corresponding Array type.
Definition ArrayBase.h:70
ArrayRef< Element, ND::value, 0 > Transpose
ArrayRef to a noncontiguous array; the result of a call to transpose(...).
Definition ArrayBase.h:68
bool isEmpty() const
Return true if the array has a null data point.
Definition ArrayBase.h:133
ResultOf< View< Seq > >::Type operator[](View< Seq > const &def) const
Return a general view into this array (see Tutorial).
Definition ArrayBase.h:206
Transpose transpose(Index const &order) const
Return a view of the array with the dimensions permuted.
Definition ArrayBase.h:172
Traits::ND ND
Number of dimensions (boost::mpl::int_).
Definition ArrayBase.h:58
Size getNumElements() const
Return the total number of elements in the array.
Definition ArrayBase.h:155
Size getSize() const
Return the size of a specific dimension.
Definition ArrayBase.h:139
Traits::Element Element
Data type of array elements.
Definition ArrayBase.h:50
Traits::Iterator Iterator
Nested array or element iterator.
Definition ArrayBase.h:52
Traits::Value Value
Nested array or element value type.
Definition ArrayBase.h:56
Deep const deep() const
Return an ArrayRef view to this.
Definition ArrayBase.h:191
Iterator end() const
Return an Iterator to one past the end of the array.
Definition ArrayBase.h:109
Vector< Offset, ND::value > Strides
Vector type for N-dimensional offsets and strides.
Definition ArrayBase.h:64
Traits::Reference Reference
Nested array or element reference.
Definition ArrayBase.h:54
ArrayRef< Element, ND::value, RMC::value > Deep
The corresponding ArrayRef type.
Definition ArrayBase.h:72
Element * getData() const
Return a raw pointer to the first element of the array.
Definition ArrayBase.h:130
Strides getStrides() const
Return a Vector of the strides of all dimensions.
Definition ArrayBase.h:152
Iterator begin() const
Return an Iterator to the beginning of the array.
Definition ArrayBase.h:96
Element & operator[](Index const &i) const
Return a single element from the array.
Definition ArrayBase.h:87
Index getShape() const
Return a Vector of the sizes of all dimensions.
Definition ArrayBase.h:149
Vector< Size, ND::value > Index
Vector type for N-dimensional indices and shapes.
Definition ArrayBase.h:62
Traits::RMC RMC
Number of guaranteed row-major contiguous dimensions, counted from the end (boost::mpl::int_).
Definition ArrayBase.h:60
A proxy class for Array with deep assignment operators.
Definition ArrayRef.h:34
A multidimensional strided array.
Definition Array.h:35
CRTP base class for all multidimensional expressions.
Definition ExpressionBase.h:40
Definition ArrayAccess.h:26
Definition NestedIterator.h:46
A template metafunction class to determine the result of a view indexing operation.
Definition ArrayBase.h:195
Dimension-specialized traits shared by Array and ArrayRef.
Definition ArrayTraits.h:44
Traits for expressions.
Definition ExpressionTraits.h:30
A fixed-size 1D array class.
Definition Vector.h:82
A template meta-sequence that defines an arbitrary view into an unspecified array.
Definition views.h:74
Sequence _seq
A boost::fusion sequence of index objects.
Definition views.h:76
Definition ViewBuilder.h:206