23 #ifndef NDARRAY_eigen_h_INCLUDED
24 #define NDARRAY_eigen_h_INCLUDED
43 InnerStride = Eigen::Dynamic,
44 OuterStride = Eigen::Dynamic,
46 Flags = Eigen::LinearAccessBit,
47 Options = Eigen::ColMajor | Eigen::AutoAlign
60 InnerStride = Eigen::Dynamic,
61 OuterStride = Eigen::Dynamic,
63 Flags = Eigen::LinearAccessBit | Eigen::RowMajorBit,
64 Options = Eigen::RowMajor | Eigen::AutoAlign
77 InnerStride = Eigen::Dynamic,
78 OuterStride = Eigen::Dynamic,
80 Flags = Eigen::LinearAccessBit,
81 Options = Eigen::ColMajor | Eigen::AutoAlign
91 template <
int C,
int Rows>
95 OuterStride = Eigen::Dynamic,
97 Flags = Eigen::LinearAccessBit | Eigen::PacketAccessBit,
98 Options = Eigen::ColMajor | Eigen::AutoAlign
108 template <
int C,
int Cols>
112 OuterStride = Eigen::Dynamic,
114 Flags = Eigen::LinearAccessBit | Eigen::RowMajorBit | Eigen::PacketAccessBit,
115 Options = Eigen::RowMajor | Eigen::AutoAlign
125 template <
int Rows,
int Cols>
128 InnerStride = Eigen::Dynamic,
129 OuterStride = Eigen::Dynamic,
132 Options = Eigen::ColMajor | Eigen::AutoAlign
142 template <
int Rows,
int Cols>
146 OuterStride = Eigen::Dynamic,
148 Flags = Eigen::RowMajorBit | Eigen::PacketAccessBit,
149 Options = Eigen::RowMajor | Eigen::AutoAlign
159 template <
int Rows,
int Cols>
162 template <
int Rows,
int Cols>
166 OuterStride = Eigen::Dynamic,
168 Flags = Eigen::PacketAccessBit,
169 Options = Eigen::ColMajor | Eigen::AutoAlign
179 template <
int Rows,
int Cols>
189 template <
typename T,
int N,
int C,
typename XprKind_,
int Rows,
int Cols>
190 struct traits< ndarray::EigenView<T,N,C,XprKind_,Rows,Cols> > {
194 typedef typename boost::remove_const<T>::type
Scalar;
196 RowsAtCompileTime = Rows,
197 ColsAtCompileTime = Cols,
198 MaxRowsAtCompileTime = Rows,
199 MaxColsAtCompileTime = Cols,
204 | Eigen::NestByRefBit | Eigen::DirectAccessBit
205 | (boost::is_const<T>::value ? 0 : Eigen::LvalueBit),
206 CoeffReadCost = NumTraits<Scalar>::ReadCost
231 template <
typename T,
int N,
int C,
typename XprKind_,
int Rows_,
int Cols_>
233 :
public Eigen::internal::dense_xpr_base< EigenView<T,N,C,XprKind_,Rows_,Cols_> >::type
245 typedef typename Eigen::internal::dense_xpr_base< EigenView<T,N,C,XprKind_,Rows_,Cols_> >::type
Base;
249 enum { Options = ST::Options };
251 typedef typename boost::mpl::if_<
252 boost::is_same<XprKind_,Eigen::MatrixXpr>,
253 Eigen::Matrix<Scalar,Rows_,Cols_,Options,Rows_,Cols_>,
254 Eigen::Array<Scalar,Rows_,Cols_,Options,Rows_,Cols_>
268 if (
_array.getData() == 0) {
271 Base::operator=(other);
276 template <
typename Other>
278 return Base::operator=(other);
281 template <
typename Other>
283 return Base::operator=(other);
286 template <
typename Other>
288 return Base::operator=(other);
297 inline Index
rows()
const {
return ST::getRows(*Access::getCore(
_array)); }
298 inline Index
cols()
const {
return ST::getCols(*Access::getCore(
_array)); }
305 return _array.getData()[row * rowStride() + col * colStride()];
308 inline T&
coeff(Index index)
const {
309 return _array.getData()[index * innerStride()];
313 return _array.getData()[row * rowStride() + col * colStride()];
317 return _array.getData()[row * rowStride() + col * colStride()];
321 return _array.getData()[index * innerStride()];
325 return _array.getData()[index * innerStride()];
328 template <
int LoadMode>
330 return Eigen::internal::ploadt<PacketScalar, LoadMode>(
331 _array.getData() + (col * colStride() + row * rowStride())
335 template<
int LoadMode>
336 inline PacketScalar
packet(Index index)
const {
337 BOOST_STATIC_ASSERT( N == 1 );
338 return Eigen::internal::ploadt<PacketScalar, LoadMode>(
339 _array.getData() + index * innerStride()
343 template<
int StoreMode>
345 BOOST_STATIC_ASSERT( !boost::is_const<T>::value );
346 Eigen::internal::pstoret<Scalar, PacketScalar, StoreMode>(
347 _array.getData() + (col * colStride() + row * rowStride()), x
351 template<
int StoreMode>
353 BOOST_STATIC_ASSERT( !boost::is_const<T>::value );
354 BOOST_STATIC_ASSERT( N == 1 );
355 Eigen::internal::pstoret<Scalar, PacketScalar, StoreMode>(
356 _array.getData() + index * innerStride(),
x
371 template <
typename T,
bool contiguous=true>
373 typedef Eigen::internal::traits<T>
Traits;
379 C = ((contiguous) ? ((Traits::Flags & Eigen::RowMajorBit) ? 2 : -2) : 0),
380 Rows = Traits::RowsAtCompileTime,
381 Cols = Traits::ColsAtCompileTime
389 template <
typename T>
394 result = other.derived();
398 template <
typename Derived>
399 template <
typename XprKind,
int Rows,
int Cols>
400 inline EigenView<typename ArrayBase<Derived>::Element, ArrayBase<Derived>::ND::value,
401 ArrayBase<Derived>::RMC::value, XprKind, Rows, Cols
408 template <
typename Derived>
409 template <
typename XprKind>
417 template <
typename Derived>
418 template <
int Rows,
int Cols>
419 inline EigenView<typename ArrayBase<Derived>::Element, ArrayBase<Derived>::ND::value,
420 ArrayBase<Derived>::RMC::value, Eigen::MatrixXpr, Rows, Cols>
421 ArrayBase<Derived>::asEigen()
const {
422 return EigenView<typename ArrayBase<Derived>::Element, ArrayBase<Derived>::ND::value,
423 ArrayBase<Derived>::RMC::value, Eigen::MatrixXpr, Rows, Cols>(this->getSelf());
426 template <
typename Derived>
427 inline EigenView<typename ArrayBase<Derived>::Element, ArrayBase<Derived>::ND::value,
428 ArrayBase<Derived>::RMC::value, Eigen::MatrixXpr>
429 ArrayBase<Derived>::asEigen()
const {
430 return EigenView<typename ArrayBase<Derived>::Element, ArrayBase<Derived>::ND::value,
431 ArrayBase<Derived>::RMC::value>(this->getSelf());
436 #endif // !NDARRAY_eigen_h_INCLUDED
static int getCols(Core< 1 > const &core)
A proxy class for Array with deep assignment operators.
static int getCols(Core< 1 > const &core)
static int getRowStride(Core< 1 > const &core)
void reset(ArrayRef< T, N, C > const &array)
int getStride() const
Return the stride of the Nth dimension.
int getSize() const
Return the size of the Nth dimension.
static int getRowStride(Core< 2 > const &core)
static int getRowStride(Core< 1 > const &core)
static int getOuterStride(Core< 1 > const &core)
Array< Element, N, C > Shallow
static int getInnerStride(Core< 1 > const &core)
void writePacket(Index row, Index col, const PacketScalar &x)
Eigen3 view into an ndarray::Array.
T & coeff(Index index) const
static int getCols(Core< 1 > const &core)
Eigen::internal::dense_xpr_base< EigenView< T, N, C, XprKind_, Rows_, Cols_ > >::type Base
static int getColStride(Core< 1 > const &core)
T & coeff(Index row, Index col) const
T & coeffRef(Index index) const
T & coeffRef(Index row, Index col) const
static int getColStride(Core< 1 > const &core)
SelectEigenView< T >::Type copy(Eigen::EigenBase< T > const &other)
Copy an arbitrary Eigen expression into a new EigenView.
EigenView(Array< T, N, C > const &array)
boost::mpl::if_< boost::is_same< XprKind_, Eigen::MatrixXpr >, Eigen::Matrix< Scalar, Rows_, Cols_, Options, Rows_, Cols_ >, Eigen::Array< Scalar, Rows_, Cols_, Options, Rows_, Cols_ > >::type PlainEigenType
void reset(Array< T, N, C > const &array)
detail::ArrayAccess< Array< T, N, C > > Access
static int getRowStride(Core< 1 > const &core)
T & coeffRef(Index row, Index col)
static int getCols(Core< 1 > const &core)
A metafunction that computes the EigenView instantiation that most closely matches an Eigen type...
boost::mpl::if_< boost::is_const< T >, Scalar const, Scalar >::type Element
ArrayRef< Element, N, C > Deep
static int getRows(Core< 1 > const &core)
static int getCols(Core< 1 > const &core)
#define NDARRAY_ASSERT(ARG)
static int getOuterStride(Core< 1 > const &core)
static int getRows(Core< 1 > const &core)
T & coeffRef(Index index)
static int getRowStride(Core< 2 > const &core)
Index outerStride() const
EigenView & operator=(EigenView const &other)
EigenView & operator=(Eigen::DenseBase< Other > const &other)
static int getColStride(Core< 1 > const &core)
static int getRowStride(Core< 1 > const &core)
detail::EigenStrideTraits< N, C, Rows_, Cols_ > ST
static int getOuterStride(Core< 1 > const &core)
boost::remove_const< T >::type Scalar
Forward declarations for ndarray/eigen interface.
static int getInnerStride(Core< 2 > const &core)
static int getColStride(Core< 1 > const &core)
CRTP implementation for Array and ArrayRef.
static int getCols(Core< 1 > const &core)
static int getOuterStride(Core< 1 > const &core)
static int getRows(Core< 1 > const &core)
EigenView(EigenView const &other)
detail::SimpleInitializer< N > allocate(Vector< int, N > const &shape)
Create an expression that allocates uninitialized memory for an array.
EigenView & operator=(Eigen::ReturnByValue< Other > const &other)
EigenView & operator=(Eigen::EigenBase< Other > const &other)
static int getCols(Core< 1 > const &core)
static int getRows(Core< 2 > const &core)
A multidimensional strided array.
ArrayRef< T, N, C > deep() const
static int getColStride(Core< 1 > const &core)
static int getRowStride(Core< 1 > const &core)
static int getColStride(Core< 1 > const &core)
ndarray::Array< typename ImageT::Pixel, 2, 2 > & _array
static int getInnerStride(Core< 1 > const &core)
static int getOuterStride(Core< 1 > const &core)
Index innerStride() const
PacketScalar packet(Index row, Index col) const
Shallow const shallow() const
Return a Array view to this.
Eigen::internal::traits< T > Traits
static int getColStride(Core< 1 > const &core)
static int getRows(Core< 1 > const &core)
static int getRows(Core< 1 > const &core)
static int getInnerStride(Core< 1 > const &core)
static int getRows(Core< 2 > const &core)
static int getOuterStride(Core< 1 > const &core)
static int getInnerStride(Core< 1 > const &core)
static int getOuterStride(Core< 1 > const &core)
static int getCols(Core< 1 > const &core)
static int getOuterStride(Core< 2 > const &core)
static int getRows(Core< 2 > const &core)
static int getRowStride(Core< 2 > const &core)
static int getColStride(Core< 1 > const &core)
static int getInnerStride(Core< 2 > const &core)
void writePacket(Index index, const PacketScalar &x)
static int getInnerStride(Core< 1 > const &core)
static int getInnerStride(Core< 1 > const &core)
EigenView< Element, N, C, XprKind, Rows, Cols > Type
Array< T, N, C > const & shallow() const
PacketScalar packet(Index index) const