11#ifndef NDARRAY_ArrayRef_h_INCLUDED
12#define NDARRAY_ArrayRef_h_INCLUDED
33template <
typename T,
int N,
int C>
36 typedef typename Super::Core Core;
37 typedef typename Super::CorePtr CorePtr;
49 explicit ArrayRef(Size n1, Size n2=1, Size n3=1, Size n4=1, Size n5=1, Size n6=1, Size n7=1, Size n8=1);
70 template <
typename T_,
int C_>
76 ) :
Super(other._data, other._core) {}
84 template <
typename T_,
int C_>
90 ) :
Super(other._data, other._core) {}
102 NDARRAY_ASSERT(other.
getShape() == this->getShape());
103 std::copy(other.
begin(), other.
end(), this->begin());
107 ArrayRef
const & operator=(ArrayRef
const & other)
const {
108 NDARRAY_ASSERT(other.getShape() == this->getShape());
109 std::copy(other.begin(), other.end(), this->begin());
115 template <
typename Other>
120 std::copy(expr.
begin(),expr.
end(),this->begin());
125 template <
typename Scalar>
127 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
131 operator =(Scalar
const & scalar)
const {
132 Super::Traits::fill(this->
begin(),this->
end(),scalar);
137 template <
typename Other>
142 Iterator
const i_end = this->
end();
143 typename Other::Iterator j = expr.
begin();
144 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) += (*j);
149 template <
typename Scalar>
151 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
156 Iterator
const i_end = this->
end();
157 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) += scalar;
162 template <
typename Other>
167 Iterator
const i_end = this->
end();
168 typename Other::Iterator j = expr.
begin();
169 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) -= (*j);
174 template <
typename Scalar>
176 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
181 Iterator
const i_end = this->
end();
182 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) -= scalar;
187 template <
typename Other>
192 Iterator
const i_end = this->
end();
193 typename Other::Iterator j = expr.
begin();
194 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) *= (*j);
199 template <
typename Scalar>
201 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
206 Iterator
const i_end = this->
end();
207 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) *= scalar;
212 template <
typename Other>
217 Iterator
const i_end = this->
end();
218 typename Other::Iterator j = expr.
begin();
219 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) /= (*j);
224 template <
typename Scalar>
226 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
231 Iterator
const i_end = this->
end();
232 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) /= scalar;
237 template <
typename Other>
242 Iterator
const i_end = this->
end();
243 typename Other::Iterator j = expr.
begin();
244 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) %= (*j);
249 template <
typename Scalar>
251 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
256 Iterator
const i_end = this->
end();
257 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) %= scalar;
262 template <
typename Other>
267 Iterator
const i_end = this->
end();
268 typename Other::Iterator j = expr.
begin();
269 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) ^= (*j);
274 template <
typename Scalar>
276 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
281 Iterator
const i_end = this->
end();
282 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) ^= scalar;
287 template <
typename Other>
292 Iterator
const i_end = this->
end();
293 typename Other::Iterator j = expr.
begin();
294 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) &= (*j);
299 template <
typename Scalar>
301 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
306 Iterator
const i_end = this->
end();
307 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) &= scalar;
312 template <
typename Other>
317 Iterator
const i_end = this->
end();
318 typename Other::Iterator j = expr.
begin();
319 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) |= (*j);
324 template <
typename Scalar>
326 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
331 Iterator
const i_end = this->
end();
332 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) |= scalar;
337 template <
typename Other>
342 Iterator
const i_end = this->
end();
343 typename Other::Iterator j = expr.
begin();
344 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) <<= (*j);
349 template <
typename Scalar>
351 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
356 Iterator
const i_end = this->
end();
357 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) <<= scalar;
362 template <
typename Other>
367 Iterator
const i_end = this->
end();
368 typename Other::Iterator j = expr.
begin();
369 for (Iterator i = this->
begin(); i != i_end; ++i, ++j) (*i) >>= (*j);
374 template <
typename Scalar>
376 typename boost::enable_if<boost::is_convertible<Scalar,T>,
ArrayRef const &>::type
381 Iterator
const i_end = this->
end();
382 for (Iterator i = this->
begin(); i != i_end; ++i) (*i) >>= scalar;
388 template <
typename T_,
int N_,
int C_>
friend class Array;
389 template <
typename T_,
int N_,
int C_>
friend class ArrayRef;
390 template <
typename T_,
int N_,
int C_>
friend struct ArrayTraits;
391 template <
typename Derived>
friend class ArrayBase;
395 ArrayRef(T * data, CorePtr
const & core) : Super(data, core) {}
Definitions for ArrayAccess.
Definition of ArrayBaseN, a dimension-specialized CRTP base class for Array and ArrayRef.
An intermediate CRTP base class for Array and ArrayRef.
Definition ArrayBaseN.h:29
CRTP implementation for Array and ArrayRef.
Definition ArrayBase.h:43
Traits::Iterator Iterator
Nested array or element iterator.
Definition ArrayBase.h:52
Iterator end() const
Return an Iterator to one past the end of the array.
Definition ArrayBase.h:109
Iterator begin() const
Return an Iterator to the beginning of the array.
Definition ArrayBase.h:96
Index getShape() const
Return a Vector of the sizes of all dimensions.
Definition ArrayBase.h:149
A proxy class for Array with deep assignment operators.
Definition ArrayRef.h:34
ArrayRef const & operator|=(ExpressionBase< Other > const &expr) const
|= assignment of arrays and array expressions.
Definition ArrayRef.h:314
ArrayRef const & operator^=(ExpressionBase< Other > const &expr) const
^= assignment of arrays and array expressions.
Definition ArrayRef.h:264
ArrayRef const & operator*=(ExpressionBase< Other > const &expr) const
*= assignment of arrays and array expressions.
Definition ArrayRef.h:189
ArrayRef const & operator&=(ExpressionBase< Other > const &expr) const
&= assignment of arrays and array expressions.
Definition ArrayRef.h:289
ArrayRef const & operator%=(ExpressionBase< Other > const &expr) const
%= assignment of arrays and array expressions.
Definition ArrayRef.h:239
ArrayRef const & operator/=(ExpressionBase< Other > const &expr) const
/= assignment of arrays and array expressions.
Definition ArrayRef.h:214
ArrayRef const & operator-=(ExpressionBase< Other > const &expr) const
-= assignment of arrays and array expressions.
Definition ArrayRef.h:164
ArrayRef const & operator+=(ExpressionBase< Other > const &expr) const
+= assignment of arrays and array expressions.
Definition ArrayRef.h:139
ArrayRef(Array< T_, N, C_ > const &other, typename boost::enable_if< detail::Convertible< N, T_, C_, T, C >, void * >::type=0)
Converting copy constructor.
Definition ArrayRef.h:71
ArrayRef const & operator>>=(ExpressionBase< Other > const &expr) const
>>= assignment of arrays and array expressions.
Definition ArrayRef.h:364
ArrayRef const & operator<<=(ExpressionBase< Other > const &expr) const
<<= assignment of arrays and array expressions.
Definition ArrayRef.h:339
ArrayRef(ArrayRef< T_, N, C_ > const &other, typename boost::enable_if< detail::Convertible< N, T_, C_, T, C >, void * >::type=0)
Converting copy constructor.
Definition ArrayRef.h:85
ArrayRef(ArrayRef const &other)
Non-converting copy constructor.
Definition ArrayRef.h:62
A multidimensional strided array.
Definition Array.h:35
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
Iterator end() const
Return an Iterator to one past the end of the expression.
Definition ExpressionBase.h:70
Iterator begin() const
Return an Iterator to the beginning of the expression.
Definition ExpressionBase.h:67
Definition ArrayAccess.h:26
Forward declarations and default template parameters for ndarray.
Dimension-specialized traits shared by Array and ArrayRef.
Definition ArrayTraits.h:44
A fixed-size 1D array class.
Definition Vector.h:82
Definition ArrayTraits.h:33
Public interface for arbitrary views into arrays.