Eigen::RefBase< Derived > Class Template Reference
+ Inheritance diagram for Eigen::RefBase< Derived >:

Public Types

typedef MapBase< Derived > Base
 

Public Member Functions

EIGEN_CONSTEXPR Index innerStride () const
 
EIGEN_CONSTEXPR Index outerStride () const
 
 RefBase ()
 

Protected Types

typedef Stride< StrideType::OuterStrideAtCompileTime, StrideType::InnerStrideAtCompileTime > StrideBase
 

Protected Member Functions

template<typename Expression >
bool construct (Expression &expr)
 

Static Protected Member Functions

static EIGEN_CONSTEXPR Index resolveInnerStride (Index inner)
 
static EIGEN_CONSTEXPR Index resolveOuterStride (Index inner, Index outer, Index rows, Index cols, bool isVectorAtCompileTime, bool isRowMajor)
 

Protected Attributes

StrideBase m_stride
 

Private Types

typedef internal::traits< Derived >::PlainObjectType PlainObjectType
 
typedef internal::traits< Derived >::StrideType StrideType
 

Detailed Description

template<typename Derived>
class Eigen::RefBase< Derived >

Definition at line 61 of file Ref.h.

Member Typedef Documentation

◆ Base

template<typename Derived >
typedef MapBase<Derived> Eigen::RefBase< Derived >::Base

Definition at line 69 of file Ref.h.

◆ PlainObjectType

template<typename Derived >
typedef internal::traits<Derived>::PlainObjectType Eigen::RefBase< Derived >::PlainObjectType
private

Definition at line 64 of file Ref.h.

◆ StrideBase

template<typename Derived >
typedef Stride<StrideType::OuterStrideAtCompileTime,StrideType::InnerStrideAtCompileTime> Eigen::RefBase< Derived >::StrideBase
protected

Definition at line 96 of file Ref.h.

◆ StrideType

template<typename Derived >
typedef internal::traits<Derived>::StrideType Eigen::RefBase< Derived >::StrideType
private

Definition at line 65 of file Ref.h.

Constructor & Destructor Documentation

◆ RefBase()

template<typename Derived >
Eigen::RefBase< Derived >::RefBase ( )
inline

Definition at line 85 of file Ref.h.

86  : Base(0,RowsAtCompileTime==Dynamic?0:RowsAtCompileTime,ColsAtCompileTime==Dynamic?0:ColsAtCompileTime),
87  // Stride<> does not allow default ctor for Dynamic strides, so let' initialize it with dummy values:
88  m_stride(StrideType::OuterStrideAtCompileTime==Dynamic?0:StrideType::OuterStrideAtCompileTime,
89  StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime)
90  {}
StrideBase m_stride
Definition: Ref.h:209
MapBase< Derived > Base
Definition: Ref.h:69
const int Dynamic
Definition: Constants.h:24

Member Function Documentation

◆ construct()

template<typename Derived >
template<typename Expression >
bool Eigen::RefBase< Derived >::construct ( Expression &  expr)
inlineprotected

Definition at line 111 of file Ref.h.

112  {
113  // Check matrix sizes. If this is a compile-time vector, we do allow
114  // implicitly transposing.
117  // If it is a vector, the transpose sizes might match.
118  || ( PlainObjectType::IsVectorAtCompileTime
119  && ((int(PlainObjectType::RowsAtCompileTime)==Eigen::Dynamic
120  || int(Expression::ColsAtCompileTime)==Eigen::Dynamic
121  || int(PlainObjectType::RowsAtCompileTime)==int(Expression::ColsAtCompileTime))
122  && (int(PlainObjectType::ColsAtCompileTime)==Eigen::Dynamic
123  || int(Expression::RowsAtCompileTime)==Eigen::Dynamic
124  || int(PlainObjectType::ColsAtCompileTime)==int(Expression::RowsAtCompileTime)))),
125  YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES
126  )
127 
128  // Determine runtime rows and columns.
129  Index rows = expr.rows();
130  Index cols = expr.cols();
131  if(PlainObjectType::RowsAtCompileTime==1)
132  {
133  eigen_assert(expr.rows()==1 || expr.cols()==1);
134  rows = 1;
135  cols = expr.size();
136  }
137  else if(PlainObjectType::ColsAtCompileTime==1)
138  {
139  eigen_assert(expr.rows()==1 || expr.cols()==1);
140  rows = expr.size();
141  cols = 1;
142  }
143  // Verify that the sizes are valid.
144  eigen_assert(
145  (PlainObjectType::RowsAtCompileTime == Dynamic) || (PlainObjectType::RowsAtCompileTime == rows));
146  eigen_assert(
147  (PlainObjectType::ColsAtCompileTime == Dynamic) || (PlainObjectType::ColsAtCompileTime == cols));
148 
149 
150  // If this is a vector, we might be transposing, which means that stride should swap.
151  const bool transpose = PlainObjectType::IsVectorAtCompileTime && (rows != expr.rows());
152  // If the storage format differs, we also need to swap the stride.
153  const bool row_major = ((PlainObjectType::Flags)&RowMajorBit) != 0;
154  const bool expr_row_major = (Expression::Flags&RowMajorBit) != 0;
155  const bool storage_differs = (row_major != expr_row_major);
156 
157  const bool swap_stride = (transpose != storage_differs);
158 
159  // Determine expr's actual strides, resolving any defaults if zero.
160  const Index expr_inner_actual = resolveInnerStride(expr.innerStride());
161  const Index expr_outer_actual = resolveOuterStride(expr_inner_actual,
162  expr.outerStride(),
163  expr.rows(),
164  expr.cols(),
165  Expression::IsVectorAtCompileTime != 0,
166  expr_row_major);
167 
168  // If this is a column-major row vector or row-major column vector, the inner-stride
169  // is arbitrary, so set it to either the compile-time inner stride or 1.
170  const bool row_vector = (rows == 1);
171  const bool col_vector = (cols == 1);
172  const Index inner_stride =
173  ( (!row_major && row_vector) || (row_major && col_vector) ) ?
174  ( StrideType::InnerStrideAtCompileTime > 0 ? Index(StrideType::InnerStrideAtCompileTime) : 1)
175  : swap_stride ? expr_outer_actual : expr_inner_actual;
176 
177  // If this is a column-major column vector or row-major row vector, the outer-stride
178  // is arbitrary, so set it to either the compile-time outer stride or vector size.
179  const Index outer_stride =
180  ( (!row_major && col_vector) || (row_major && row_vector) ) ?
181  ( StrideType::OuterStrideAtCompileTime > 0 ? Index(StrideType::OuterStrideAtCompileTime) : rows * cols * inner_stride)
182  : swap_stride ? expr_inner_actual : expr_outer_actual;
183 
184  // Check if given inner/outer strides are compatible with compile-time strides.
185  const bool inner_valid = (StrideType::InnerStrideAtCompileTime == Dynamic)
186  || (resolveInnerStride(Index(StrideType::InnerStrideAtCompileTime)) == inner_stride);
187  if (!inner_valid) {
188  return false;
189  }
190 
191  const bool outer_valid = (StrideType::OuterStrideAtCompileTime == Dynamic)
192  || (resolveOuterStride(
193  inner_stride,
194  Index(StrideType::OuterStrideAtCompileTime),
195  rows, cols, PlainObjectType::IsVectorAtCompileTime != 0,
196  row_major)
197  == outer_stride);
198  if (!outer_valid) {
199  return false;
200  }
201 
202  internal::construct_at<Base>(this, expr.data(), rows, cols);
204  (StrideType::OuterStrideAtCompileTime == 0) ? 0 : outer_stride,
205  (StrideType::InnerStrideAtCompileTime == 0) ? 0 : inner_stride );
206  return true;
207  }
#define eigen_assert(x)
Definition: Macros.h:902
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:68
internal::traits< Derived >::PlainObjectType PlainObjectType
Definition: Ref.h:64
static EIGEN_CONSTEXPR Index resolveInnerStride(Index inner)
Definition: Ref.h:99
static EIGEN_CONSTEXPR Index resolveOuterStride(Index inner, Index outer, Index rows, Index cols, bool isVectorAtCompileTime, bool isRowMajor)
Definition: Ref.h:104
const unsigned int RowMajorBit
Definition: Constants.h:68
T * construct_at(T *p, Args &&... args)
Definition: Memory.h:1248
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82

◆ innerStride()

template<typename Derived >
EIGEN_CONSTEXPR Index Eigen::RefBase< Derived >::innerStride ( ) const
inline

Definition at line 72 of file Ref.h.

73  {
74  return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
75  }
EIGEN_CONSTEXPR Index inner() const
Definition: Stride.h:91

◆ outerStride()

template<typename Derived >
EIGEN_CONSTEXPR Index Eigen::RefBase< Derived >::outerStride ( ) const
inline

Definition at line 77 of file Ref.h.

78  {
79  return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
80  : IsVectorAtCompileTime ? this->size()
81  : int(Flags)&RowMajorBit ? this->cols()
82  : this->rows();
83  }
EIGEN_CONSTEXPR Index outer() const
Definition: Stride.h:88

◆ resolveInnerStride()

template<typename Derived >
static EIGEN_CONSTEXPR Index Eigen::RefBase< Derived >::resolveInnerStride ( Index  inner)
inlinestaticprotected

Definition at line 99 of file Ref.h.

99  {
100  return inner == 0 ? 1 : inner;
101  }

◆ resolveOuterStride()

template<typename Derived >
static EIGEN_CONSTEXPR Index Eigen::RefBase< Derived >::resolveOuterStride ( Index  inner,
Index  outer,
Index  rows,
Index  cols,
bool  isVectorAtCompileTime,
bool  isRowMajor 
)
inlinestaticprotected

Definition at line 104 of file Ref.h.

104  {
105  return outer == 0 ? isVectorAtCompileTime ? inner * rows * cols : isRowMajor ? inner * cols : inner * rows : outer;
106  }

Member Data Documentation

◆ m_stride

template<typename Derived >
StrideBase Eigen::RefBase< Derived >::m_stride
protected

Definition at line 209 of file Ref.h.


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