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
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ > Class Template Reference

Eigen3 view into an ndarray::Array. More...

#include <eigen.h>

Inheritance diagram for ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >:

Public Types

enum  { Options = ST::Options }
 
typedef
Eigen::internal::dense_xpr_base
< EigenView< T, N, C, XprKind_,
Rows_, Cols_ > >::type 
Base
 
typedef 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
 
typedef T * PointerType
 

Public Member Functions

 EigenView ()
 
 EigenView (EigenView const &other)
 
 EigenView (Array< T, N, C > const &array)
 
EigenViewoperator= (EigenView const &other)
 
template<typename Other >
EigenViewoperator= (Eigen::DenseBase< Other > const &other)
 
template<typename Other >
EigenViewoperator= (Eigen::EigenBase< Other > const &other)
 
template<typename Other >
EigenViewoperator= (Eigen::ReturnByValue< Other > const &other)
 
Index innerStride () const
 
Index outerStride () const
 
Index rowStride () const
 
Index colStride () const
 
Index rows () const
 
Index cols () const
 
T * data () const
 
T * data ()
 
T & coeff (Index row, Index col) const
 
T & coeff (Index index) const
 
T & coeffRef (Index row, Index col) const
 
T & coeffRef (Index row, Index col)
 
T & coeffRef (Index index) const
 
T & coeffRef (Index index)
 
template<int LoadMode>
PacketScalar packet (Index row, Index col) const
 
template<int LoadMode>
PacketScalar packet (Index index) const
 
template<int StoreMode>
void writePacket (Index row, Index col, const PacketScalar &x)
 
template<int StoreMode>
void writePacket (Index index, const PacketScalar &x)
 
Array< T, N, C > const & shallow () const
 
ArrayRef< T, N, C > deep () const
 
void reset (Array< T, N, C > const &array)
 
void reset (ArrayRef< T, N, C > const &array)
 

Private Types

typedef
detail::EigenStrideTraits< N,
C, Rows_, Cols_ > 
ST
 
typedef detail::ArrayAccess
< Array< T, N, C > > 
Access
 

Private Member Functions

void checkDimensions ()
 

Private Attributes

Array< T, N, C > _array
 

Detailed Description

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
class ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >

Eigen3 view into an ndarray::Array.

EigenView provides an Eigen DenseBase-derived object based on an ndarray::Array internally. Any one or two dimensional Array can be viewed as an Eigen object.

Assignment to an EigenView is deep, and uses the Eigen assignment operators, but construction from an ndarray::Array or ArrayRef is shallow with reference counting. Block and transpose operations use the standard Eigen Block and Transpose classes, and do not do reference counting (in fact, they hold a plain C++ reference to the EigenView, so they should be considered extremely temporary).

Todo:
Add reference-counted share and transpose operations that return EigenViews.

Definition at line 232 of file eigen.h.

Member Typedef Documentation

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
typedef detail::ArrayAccess< Array<T,N,C> > ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::Access
private

Definition at line 236 of file eigen.h.

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
typedef Eigen::internal::dense_xpr_base< EigenView<T,N,C,XprKind_,Rows_,Cols_> >::type ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::Base

Definition at line 245 of file eigen.h.

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
typedef 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 ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::PlainEigenType

Definition at line 255 of file eigen.h.

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
typedef T* ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::PointerType

Definition at line 257 of file eigen.h.

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
typedef detail::EigenStrideTraits<N,C,Rows_,Cols_> ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::ST
private

Definition at line 235 of file eigen.h.

Member Enumeration Documentation

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
anonymous enum
Enumerator
Options 

Definition at line 249 of file eigen.h.

249 { Options = ST::Options };

Constructor & Destructor Documentation

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::EigenView ( )
inline

Definition at line 259 of file eigen.h.

259 : _array() {}
Array< T, N, C > _array
Definition: eigen.h:367
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::EigenView ( EigenView< T, N, C, XprKind_, Rows_, Cols_ > const &  other)
inline

Definition at line 261 of file eigen.h.

261 : _array(other._array) {}
Array< T, N, C > _array
Definition: eigen.h:367
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::EigenView ( Array< T, N, C > const &  array)
inlineexplicit

Definition at line 263 of file eigen.h.

263 : _array(array) { checkDimensions(); }
Array< T, N, C > _array
Definition: eigen.h:367
void checkDimensions()
Definition: eigen.h:238

Member Function Documentation

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
void ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::checkDimensions ( )
inlineprivate

Definition at line 238 of file eigen.h.

238  {
239  NDARRAY_ASSERT( Rows_ == Eigen::Dynamic || Rows_ == rows() );
240  NDARRAY_ASSERT( Cols_ == Eigen::Dynamic || Cols_ == cols() );
241  }
Index rows() const
Definition: eigen.h:297
#define NDARRAY_ASSERT(ARG)
Definition: ndarray_fwd.h:51
Index cols() const
Definition: eigen.h:298
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::coeff ( Index  row,
Index  col 
) const
inline

Definition at line 304 of file eigen.h.

304  {
305  return _array.getData()[row * rowStride() + col * colStride()];
306  }
Array< T, N, C > _array
Definition: eigen.h:367
Index rowStride() const
Definition: eigen.h:294
Index colStride() const
Definition: eigen.h:295
int row
Definition: CR.cc:153
int col
Definition: CR.cc:152
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::coeff ( Index  index) const
inline

Definition at line 308 of file eigen.h.

308  {
309  return _array.getData()[index * innerStride()];
310  }
Array< T, N, C > _array
Definition: eigen.h:367
Index innerStride() const
Definition: eigen.h:291
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::coeffRef ( Index  row,
Index  col 
) const
inline

Definition at line 312 of file eigen.h.

312  {
313  return _array.getData()[row * rowStride() + col * colStride()];
314  }
Array< T, N, C > _array
Definition: eigen.h:367
Index rowStride() const
Definition: eigen.h:294
Index colStride() const
Definition: eigen.h:295
int row
Definition: CR.cc:153
int col
Definition: CR.cc:152
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::coeffRef ( Index  row,
Index  col 
)
inline

Definition at line 316 of file eigen.h.

316  {
317  return _array.getData()[row * rowStride() + col * colStride()];
318  }
Array< T, N, C > _array
Definition: eigen.h:367
Index rowStride() const
Definition: eigen.h:294
Index colStride() const
Definition: eigen.h:295
int row
Definition: CR.cc:153
int col
Definition: CR.cc:152
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::coeffRef ( Index  index) const
inline

Definition at line 320 of file eigen.h.

320  {
321  return _array.getData()[index * innerStride()];
322  }
Array< T, N, C > _array
Definition: eigen.h:367
Index innerStride() const
Definition: eigen.h:291
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::coeffRef ( Index  index)
inline

Definition at line 324 of file eigen.h.

324  {
325  return _array.getData()[index * innerStride()];
326  }
Array< T, N, C > _array
Definition: eigen.h:367
Index innerStride() const
Definition: eigen.h:291
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Index ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::cols ( ) const
inline

Definition at line 298 of file eigen.h.

298 { return ST::getCols(*Access::getCore(_array)); }
Array< T, N, C > _array
Definition: eigen.h:367
static CorePtr const & getCore(Array_ const &array)
Definition: ArrayAccess.h:44
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Index ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::colStride ( ) const
inline

Definition at line 295 of file eigen.h.

295 { return ST::getColStride(*Access::getCore(_array)); }
Array< T, N, C > _array
Definition: eigen.h:367
static CorePtr const & getCore(Array_ const &array)
Definition: ArrayAccess.h:44
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T* ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::data ( ) const
inline

Definition at line 300 of file eigen.h.

300 { return _array.getData(); }
Array< T, N, C > _array
Definition: eigen.h:367
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
T* ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::data ( )
inline

Definition at line 302 of file eigen.h.

302 { return _array.getData(); }
Array< T, N, C > _array
Definition: eigen.h:367
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
ArrayRef<T,N,C> ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::deep ( ) const
inline

Definition at line 361 of file eigen.h.

361 { return _array.deep(); }
Array< T, N, C > _array
Definition: eigen.h:367
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Index ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::innerStride ( ) const
inline

Definition at line 291 of file eigen.h.

291 { return ST::getInnerStride(*Access::getCore(_array)); }
Array< T, N, C > _array
Definition: eigen.h:367
static CorePtr const & getCore(Array_ const &array)
Definition: ArrayAccess.h:44
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
EigenView& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::operator= ( EigenView< T, N, C, XprKind_, Rows_, Cols_ > const &  other)
inline

Definition at line 265 of file eigen.h.

265  {
266  // Weird behavior to please SWIG: if we're default-constructed, and it's an exact match,
267  // do shallow assignment; otherwise all assignment is deep.
268  if (_array.getData() == 0) {
269  _array = other._array;
270  } else {
271  Base::operator=(other);
272  }
273  return *this;
274  }
Array< T, N, C > _array
Definition: eigen.h:367
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
template<typename Other >
EigenView& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::operator= ( Eigen::DenseBase< Other > const &  other)
inline

Definition at line 277 of file eigen.h.

277  {
278  return Base::operator=(other);
279  }
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
template<typename Other >
EigenView& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::operator= ( Eigen::EigenBase< Other > const &  other)
inline

Definition at line 282 of file eigen.h.

282  {
283  return Base::operator=(other);
284  }
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
template<typename Other >
EigenView& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::operator= ( Eigen::ReturnByValue< Other > const &  other)
inline

Definition at line 287 of file eigen.h.

287  {
288  return Base::operator=(other);
289  }
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Index ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::outerStride ( ) const
inline

Definition at line 292 of file eigen.h.

292 { return ST::getOuterStride(*Access::getCore(_array)); }
Array< T, N, C > _array
Definition: eigen.h:367
static CorePtr const & getCore(Array_ const &array)
Definition: ArrayAccess.h:44
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
template<int LoadMode>
PacketScalar ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::packet ( Index  row,
Index  col 
) const
inline

Definition at line 329 of file eigen.h.

329  {
330  return Eigen::internal::ploadt<PacketScalar, LoadMode>(
331  _array.getData() + (col * colStride() + row * rowStride())
332  );
333  }
Array< T, N, C > _array
Definition: eigen.h:367
Index rowStride() const
Definition: eigen.h:294
Index colStride() const
Definition: eigen.h:295
int row
Definition: CR.cc:153
int col
Definition: CR.cc:152
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
template<int LoadMode>
PacketScalar ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::packet ( Index  index) const
inline

Definition at line 336 of file eigen.h.

336  {
337  BOOST_STATIC_ASSERT( N == 1 );
338  return Eigen::internal::ploadt<PacketScalar, LoadMode>(
339  _array.getData() + index * innerStride()
340  );
341  }
Array< T, N, C > _array
Definition: eigen.h:367
Index innerStride() const
Definition: eigen.h:291
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
void ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::reset ( Array< T, N, C > const &  array)
inline

Definition at line 363 of file eigen.h.

363 { _array = array; checkDimensions(); }
Array< T, N, C > _array
Definition: eigen.h:367
void checkDimensions()
Definition: eigen.h:238
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
void ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::reset ( ArrayRef< T, N, C > const &  array)
inline

Definition at line 364 of file eigen.h.

364 { reset(array.shallow()); }
void reset(Array< T, N, C > const &array)
Definition: eigen.h:363
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Index ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::rows ( ) const
inline

Definition at line 297 of file eigen.h.

297 { return ST::getRows(*Access::getCore(_array)); }
Array< T, N, C > _array
Definition: eigen.h:367
static CorePtr const & getCore(Array_ const &array)
Definition: ArrayAccess.h:44
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Index ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::rowStride ( ) const
inline

Definition at line 294 of file eigen.h.

294 { return ST::getRowStride(*Access::getCore(_array)); }
Array< T, N, C > _array
Definition: eigen.h:367
static CorePtr const & getCore(Array_ const &array)
Definition: ArrayAccess.h:44
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Array<T,N,C> const& ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::shallow ( ) const
inline

Definition at line 360 of file eigen.h.

360 { return _array; }
Array< T, N, C > _array
Definition: eigen.h:367
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
template<int StoreMode>
void ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::writePacket ( Index  row,
Index  col,
const PacketScalar &  x 
)
inline

Definition at line 344 of file eigen.h.

344  {
345  BOOST_STATIC_ASSERT( !boost::is_const<T>::value );
346  Eigen::internal::pstoret<Scalar, PacketScalar, StoreMode>(
347  _array.getData() + (col * colStride() + row * rowStride()), x
348  );
349  }
Array< T, N, C > _array
Definition: eigen.h:367
Index rowStride() const
Definition: eigen.h:294
Index colStride() const
Definition: eigen.h:295
int x
int row
Definition: CR.cc:153
int col
Definition: CR.cc:152
template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
template<int StoreMode>
void ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::writePacket ( Index  index,
const PacketScalar &  x 
)
inline

Definition at line 352 of file eigen.h.

352  {
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
357  );
358  }
Array< T, N, C > _array
Definition: eigen.h:367
int x
Index innerStride() const
Definition: eigen.h:291

Member Data Documentation

template<typename T, int N, int C, typename XprKind_, int Rows_, int Cols_>
Array<T,N,C> ndarray::EigenView< T, N, C, XprKind_, Rows_, Cols_ >::_array
private

Definition at line 367 of file eigen.h.


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