10 #ifndef EIGEN_INDEXED_VIEW_H
11 #define EIGEN_INDEXED_VIEW_H
20 template <
typename XprType,
typename RowIndices,
typename ColIndices>
25 MaxRowsAtCompileTime = RowsAtCompileTime,
26 MaxColsAtCompileTime = ColsAtCompileTime,
29 IsRowMajor = (MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1
30 : (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) ? 0
35 InnerIncr = IsRowMajor ? ColIncr : RowIncr,
36 OuterIncr = IsRowMajor ? RowIncr : ColIncr,
38 HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
44 InnerSize = XprTypeIsRowMajor ? ColsAtCompileTime : RowsAtCompileTime,
45 IsBlockAlike = InnerIncr == 1 && OuterIncr == 1,
46 IsInnerPannel = HasSameStorageOrderAsXprType &&
47 is_same<
AllRange<InnerSize>, std::conditional_t<XprTypeIsRowMajor, ColIndices, RowIndices>>::
value,
49 InnerStrideAtCompileTime =
52 : XprInnerStride * InnerIncr,
53 OuterStrideAtCompileTime =
56 : XprOuterstride * OuterIncr,
59 ReturnAsBlock = (!ReturnAsScalar) && IsBlockAlike,
60 ReturnAsIndexedView = (!ReturnAsScalar) && (!ReturnAsBlock),
69 FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ?
LinearAccessBit : 0,
77 template <
typename XprType,
typename RowIndices,
typename ColIndices,
typename StorageKind,
bool DirectAccess>
120 template <
typename XprType,
typename RowIndices,
typename ColIndices>
123 (internal::traits<IndexedView<XprType, RowIndices, ColIndices>>::Flags &
124 DirectAccessBit) != 0> {
133 template <
typename T0,
typename T1>
140 template <
typename XprType,
typename RowIndices,
typename ColIndices,
typename StorageKind,
bool DirectAccess>
150 template <
typename T0,
typename T1>
152 : m_xpr(xpr), m_rowIndices(rowIndices), m_colIndices(colIndices) {}
167 const RowIndices&
rowIndices()
const {
return m_rowIndices; }
170 const ColIndices&
colIndices()
const {
return m_colIndices; }
173 return nestedExpression().coeffRef(m_rowIndices[rowId], m_colIndices[colId]);
177 return nestedExpression().coeffRef(m_rowIndices[rowId], m_colIndices[colId]);
186 template <
typename XprType,
typename RowIndices,
typename ColIndices,
typename StorageKind>
188 :
public IndexedViewImpl<XprType, RowIndices, ColIndices, StorageKind, false> {
196 template <
typename T0,
typename T1>
216 std::decay_t<typename XprType::Scalar>*
data() {
217 Index row_offset = this->rowIndices()[0] * this->nestedExpression().rowStride();
218 Index col_offset = this->colIndices()[0] * this->nestedExpression().colStride();
219 return this->nestedExpression().data() + row_offset + col_offset;
222 const std::decay_t<typename XprType::Scalar>*
data()
const {
223 Index row_offset = this->rowIndices()[0] * this->nestedExpression().rowStride();
224 Index col_offset = this->colIndices()[0] * this->nestedExpression().colStride();
225 return this->nestedExpression().data() + row_offset + col_offset;
232 return innerIncrement() * this->nestedExpression().innerStride();
239 return outerIncrement() * this->nestedExpression().outerStride();
243 template <
typename ArgType,
typename RowIndices,
typename ColIndices>
251 FlagsLinearAccessBit =
257 FlagsLinearAccessBit | FlagsRowMajorBit,
270 eigen_assert(m_xpr.rowIndices()[
row] >= 0 && m_xpr.rowIndices()[
row] < m_xpr.nestedExpression().rows() &&
271 m_xpr.colIndices()[
col] >= 0 && m_xpr.colIndices()[
col] < m_xpr.nestedExpression().cols());
272 return m_argImpl.coeff(m_xpr.rowIndices()[
row], m_xpr.colIndices()[
col]);
276 eigen_assert(m_xpr.rowIndices()[
row] >= 0 && m_xpr.rowIndices()[
row] < m_xpr.nestedExpression().rows() &&
277 m_xpr.colIndices()[
col] >= 0 && m_xpr.colIndices()[
col] < m_xpr.nestedExpression().cols());
278 return m_argImpl.coeffRef(m_xpr.rowIndices()[
row], m_xpr.colIndices()[
col]);
283 Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
284 Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
285 eigen_assert(m_xpr.rowIndices()[
row] >= 0 && m_xpr.rowIndices()[
row] < m_xpr.nestedExpression().rows() &&
286 m_xpr.colIndices()[
col] >= 0 && m_xpr.colIndices()[
col] < m_xpr.nestedExpression().cols());
287 return m_argImpl.coeffRef(m_xpr.rowIndices()[
row], m_xpr.colIndices()[
col]);
291 Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
292 Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
293 eigen_assert(m_xpr.rowIndices()[
row] >= 0 && m_xpr.rowIndices()[
row] < m_xpr.nestedExpression().rows() &&
294 m_xpr.colIndices()[
col] >= 0 && m_xpr.colIndices()[
col] < m_xpr.nestedExpression().cols());
295 return m_argImpl.coeffRef(m_xpr.rowIndices()[
row], m_xpr.colIndices()[
col]);
299 Index row = XprType::RowsAtCompileTime == 1 ? 0 : index;
300 Index col = XprType::RowsAtCompileTime == 1 ? index : 0;
301 eigen_assert(m_xpr.rowIndices()[
row] >= 0 && m_xpr.rowIndices()[
row] < m_xpr.nestedExpression().rows() &&
302 m_xpr.colIndices()[
col] >= 0 && m_xpr.colIndices()[
col] < m_xpr.nestedExpression().cols());
303 return m_argImpl.coeff(m_xpr.rowIndices()[
row], m_xpr.colIndices()[
col]);
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1149
#define EIGEN_NOEXCEPT
Definition: Macros.h:1267
#define EIGEN_CONSTEXPR
Definition: Macros.h:758
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Macro to manually inherit assignment operators. This is necessary, because the implicitly defined ass...
Definition: Macros.h:1126
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
Definition: StaticAssert.h:87
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
Definition: StaticAssert.h:101
SCALAR Scalar
Definition: bench_gemm.cpp:45
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:110
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:79
Expression of a non-sequential sub-matrix defined by arbitrary sequences of row and column indices.
Definition: IndexedView.h:124
IndexedView(XprType &xpr, const T0 &rowIndices, const T1 &colIndices)
Definition: IndexedView.h:134
Definition: IndexedViewHelper.h:278
IndexedViewImpl(XprType &xpr, const T0 &rowIndices, const T1 &colIndices)
Definition: IndexedView.h:197
std::decay_t< typename XprType::Scalar > * data()
Definition: IndexedView.h:216
Index outerIncrement() const
Definition: IndexedView.h:214
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index outerStride() const EIGEN_NOEXCEPT
Definition: IndexedView.h:235
Index colIncrement() const
Definition: IndexedView.h:205
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index innerStride() const EIGEN_NOEXCEPT
Definition: IndexedView.h:228
Index innerIncrement() const
Definition: IndexedView.h:212
const std::decay_t< typename XprType::Scalar > * data() const
Definition: IndexedView.h:222
Index rowIncrement() const
Definition: IndexedView.h:199
Definition: IndexedView.h:141
const RowIndices & rowIndices() const
Definition: IndexedView.h:167
internal::ref_selector< XprType >::non_const_type MatrixTypeNested
Definition: IndexedView.h:144
MatrixTypeNested m_xpr
Definition: IndexedView.h:181
std::remove_reference_t< XprType > & nestedExpression()
Definition: IndexedView.h:164
RowIndices m_rowIndices
Definition: IndexedView.h:182
const ColIndices & colIndices() const
Definition: IndexedView.h:170
const internal::remove_all_t< XprType > & nestedExpression() const
Definition: IndexedView.h:161
Index cols() const
Definition: IndexedView.h:158
internal::generic_xpr_base< IndexedView< XprType, RowIndices, ColIndices > >::type Base
Definition: IndexedView.h:143
Index rows() const
Definition: IndexedView.h:155
ColIndices m_colIndices
Definition: IndexedView.h:183
constexpr const Scalar & coeffRef(Index rowId, Index colId) const
Definition: IndexedView.h:176
constexpr Scalar & coeffRef(Index rowId, Index colId)
Definition: IndexedView.h:172
internal::remove_all_t< XprType > NestedExpression
Definition: IndexedView.h:145
XprType::Scalar Scalar
Definition: IndexedView.h:146
IndexedViewImpl(XprType &xpr, const T0 &rowIndices, const T1 &colIndices)
Definition: IndexedView.h:151
const unsigned int LinearAccessBit
Definition: Constants.h:133
const unsigned int DirectAccessBit
Definition: Constants.h:159
const unsigned int LvalueBit
Definition: Constants.h:148
const unsigned int RowMajorBit
Definition: Constants.h:70
Eigen::DenseIndex ret
Definition: level1_cplx_impl.h:43
typename remove_all< T >::type remove_all_t
Definition: Meta.h:142
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
const int Undefined
Definition: Constants.h:34
squared absolute value
Definition: GlobalFunctions.h:87
const unsigned int HereditaryBits
Definition: Constants.h:198
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int DynamicIndex
Definition: Constants.h:30
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
type
Definition: compute_granudrum_aor.py:141
Definition: Eigen_Colamd.h:49
CwiseBinaryOp< internal::scalar_sum_op< double, double >, const CpyMatrixXd, const CpyMatrixXd > XprType
Definition: nestbyvalue.cpp:15
Definition: Constants.h:577
Definition: IndexedViewHelper.h:137
static constexpr Index incr(const Indices &)
Definition: IndexedViewHelper.h:144
static constexpr Index size(const Indices &indices)
Definition: IndexedViewHelper.h:143
Definition: CoreEvaluators.h:118
Definition: CoreEvaluators.h:104
Definition: XprHelper.h:575
Definition: DenseCoeffsBase.h:546
Definition: XprHelper.h:819
Definition: IndexedViewHelper.h:235
Definition: DenseCoeffsBase.h:556
std::conditional_t< bool(traits< T >::Flags &NestByRefBit), T &, T > non_const_type
Definition: XprHelper.h:509
Block< XprType, RowsAtCompileTime, ColsAtCompileTime, IsInnerPannel > BlockType
Definition: IndexedView.h:74
Definition: ForwardDeclarations.h:21
IndexedView< ArgType, RowIndices, ColIndices > XprType
Definition: IndexedView.h:246
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const
Definition: IndexedView.h:269
evaluator< ArgType > m_argImpl
Definition: IndexedView.h:307
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index index)
Definition: IndexedView.h:281
XprType::CoeffReturnType CoeffReturnType
Definition: IndexedView.h:267
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeffRef(Index index) const
Definition: IndexedView.h:290
const XprType & m_xpr
Definition: IndexedView.h:308
XprType::Scalar Scalar
Definition: IndexedView.h:266
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index row, Index col)
Definition: IndexedView.h:275
EIGEN_DEVICE_FUNC unary_evaluator(const XprType &xpr)
Definition: IndexedView.h:262
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CoeffReturnType coeff(Index index) const
Definition: IndexedView.h:298
Definition: CoreEvaluators.h:82