11#ifndef NDARRAY_initialization_h_INCLUDED
12#define NDARRAY_initialization_h_INCLUDED
27template <
int N,
typename Derived>
31 template <
typename T,
int C>
33 return static_cast<Derived
const *
>(
this)->
template apply<
Array<T,N,C> >();
36 template <
typename T,
int C>
38 return static_cast<Derived
const *
>(
this)->
template apply<
ArrayRef<T,N,C> >();
47 template <
typename Target>
48 Target apply()
const {
50 typedef typename Access::Core
Core;
51 typedef typename Access::Element Element;
64template <
typename T,
int N,
typename Owner>
68 template <
typename Target>
69 Target apply()
const {
71 typedef typename Access::Core
Core;
73 if (!boost::is_same<Owner,NullOwner>::value) {
74 manager = makeManager(_owner);
76 return Access::construct(_data,
Core::create(_shape, _strides, manager));
84 ) : _data(data), _owner(owner), _shape(shape), _strides(strides) {}
103template <
int N,
typename U>
138template <
typename Derived>
139inline ArrayRef<typename boost::remove_const<typename Derived::Element>::type,
140 Derived::ND::value, Derived::ND::value>
143 Derived::ND::value,Derived::ND::value> r(
154 if (order == ROW_MAJOR) {
155 for (
int n=N-1; n > 0; --n) r[n-1] = r[n] * shape[n];
157 for (
int n=1; n < N; ++n) r[n] = r[n-1] * shape[n-1];
175template <
typename T,
int N,
typename U,
typename V,
typename Owner>
202template <
typename T,
int N,
typename U,
typename V>
229template <
typename T,
int N,
typename U,
typename Owner>
256template <
typename T,
int N,
typename U>
272template <
typename T,
int N,
int C>
274 :
Super(0, CorePtr())
277 if (N > 0) shape[0] = n1;
278 if (N > 1) shape[1] = n2;
279 if (N > 2) shape[2] = n3;
280 if (N > 3) shape[3] = n4;
281 if (N > 4) shape[4] = n5;
282 if (N > 5) shape[5] = n6;
283 if (N > 6) shape[6] = n7;
284 if (N > 7) shape[7] = n8;
288template <
typename T,
int N,
int C>
291 :
Super(0, CorePtr())
296template <
typename T,
int N,
int C>
298 :
Super(
Array<T,N,C>(n1, n2, n3, n4, n5, n6, n7, n8))
301template <
typename T,
int N,
int C>
Definitions for ArrayRef.
Definition of Manager, which manages the ownership of array data.
An intermediate CRTP base class for Array and ArrayRef.
Definition ArrayBaseN.h:29
A proxy class for Array with deep assignment operators.
Definition ArrayRef.h:34
A multidimensional strided array.
Definition Array.h:35
Array & operator=(Array const &other)
Non-converting shallow assignment.
Definition Array.h:102
CRTP base class for all multidimensional expressions.
Definition ExpressionBase.h:40
Index getShape() const
Return a Vector of the sizes of all dimensions.
Definition ExpressionBase.h:76
Definition ArrayAccess.h:26
static Ptr create(Vector< Size, M > const &shape, Vector< Offset, M > const &strides, Manager::Ptr const &manager=Manager::Ptr())
Create a Core::Ptr with the given shape, strides, and manager.
Definition Core.h:56
Definition initialization.h:65
Definition initialization.h:28
Definition initialization.h:44
ArrayRef< typename boost::remove_const< typename Derived::Element >::type, Derived::ND::value, Derived::ND::value > copy(ExpressionBase< Derived > const &expr)
Create a new Array by copying an Expression.
Definition initialization.h:141
detail::SimpleInitializer< N > allocate(Vector< U, N > const &shape)
Create an expression that allocates uninitialized memory for an array.
Definition initialization.h:104
detail::ExternalInitializer< T, N, Owner > external(T *data, Vector< U, N > const &shape, Vector< V, N > const &strides, Owner const &owner)
Create an expression that initializes an Array with externally allocated memory.
Definition initialization.h:176
Vector< Offset, N > computeStrides(Vector< Size, N > const &shape, DataOrderEnum order=ROW_MAJOR)
Compute row- or column-major strides for the given shape.
Definition initialization.h:152
DataOrderEnum
An enumeration for stride computation.
Definition ndarray_fwd.h:51
Traits for expressions.
Definition ExpressionTraits.h:30
A fixed-size 1D array class.
Definition Vector.h:82
Vector< T, M > first() const
Create a new Vector from the first M elements of this.
Definition Vector.h:150
T product() const
Return the product of all elements.
Definition Vector.h:214
Definition initialization.h:25