10#ifndef EIGEN_ARRAYWRAPPER_H
11#define EIGEN_ARRAYWRAPPER_H
14#include "./InternalHeaderCheck.h"
30template <
typename ExpressionType>
31struct traits<ArrayWrapper<ExpressionType> > :
public traits<remove_all_t<typename ExpressionType::Nested> > {
32 typedef ArrayXpr XprKind;
35 Flags0 = traits<remove_all_t<typename ExpressionType::Nested> >::Flags,
36 LvalueBitFlag = is_lvalue<ExpressionType>::value ?
LvalueBit : 0,
37 Flags = (Flags0 & ~(NestByRefBit |
LvalueBit)) | LvalueBitFlag
42template <
typename ExpressionType>
43class ArrayWrapper :
public ArrayBase<ArrayWrapper<ExpressionType> > {
45 typedef ArrayBase<ArrayWrapper> Base;
46 EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
47 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
48 typedef internal::remove_all_t<ExpressionType> NestedExpression;
50 typedef std::conditional_t<internal::is_lvalue<ExpressionType>::value,
Scalar,
const Scalar>
51 ScalarWithConstIfNotLvalue;
53 typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
57 EIGEN_DEVICE_FUNC
explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType&
matrix) : m_expression(
matrix) {}
59 EIGEN_DEVICE_FUNC
constexpr Index rows()
const noexcept {
return m_expression.rows(); }
60 EIGEN_DEVICE_FUNC
constexpr Index cols()
const noexcept {
return m_expression.cols(); }
61 EIGEN_DEVICE_FUNC
constexpr Index outerStride()
const noexcept {
return m_expression.outerStride(); }
62 EIGEN_DEVICE_FUNC
constexpr Index innerStride()
const noexcept {
return m_expression.innerStride(); }
64 EIGEN_DEVICE_FUNC
constexpr ScalarWithConstIfNotLvalue* data() {
return m_expression.data(); }
65 EIGEN_DEVICE_FUNC
constexpr const Scalar* data()
const {
return m_expression.data(); }
67 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index rowId,
Index colId)
const {
68 return m_expression.coeffRef(rowId, colId);
71 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index index)
const {
return m_expression.coeffRef(index); }
73 template <
typename Dest>
74 EIGEN_DEVICE_FUNC
inline void evalTo(Dest& dst)
const {
78 EIGEN_DEVICE_FUNC
const internal::remove_all_t<NestedExpressionType>& nestedExpression()
const {
84 EIGEN_DEVICE_FUNC
void resize(
Index newSize) { m_expression.resize(newSize); }
87 EIGEN_DEVICE_FUNC
void resize(
Index rows,
Index cols) { m_expression.resize(rows, cols); }
90 NestedExpressionType m_expression;
105template <
typename ExpressionType>
106struct traits<MatrixWrapper<ExpressionType> > :
public traits<remove_all_t<typename ExpressionType::Nested> > {
107 typedef MatrixXpr XprKind;
110 Flags0 = traits<remove_all_t<typename ExpressionType::Nested> >::Flags,
111 LvalueBitFlag = is_lvalue<ExpressionType>::value ?
LvalueBit : 0,
112 Flags = (Flags0 & ~(NestByRefBit |
LvalueBit)) | LvalueBitFlag
117template <
typename ExpressionType>
118class MatrixWrapper :
public MatrixBase<MatrixWrapper<ExpressionType> > {
120 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
121 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
122 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
123 typedef internal::remove_all_t<ExpressionType> NestedExpression;
125 typedef std::conditional_t<internal::is_lvalue<ExpressionType>::value,
Scalar,
const Scalar>
126 ScalarWithConstIfNotLvalue;
128 typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
130 using Base::coeffRef;
132 EIGEN_DEVICE_FUNC
explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
134 EIGEN_DEVICE_FUNC
constexpr Index rows()
const noexcept {
return m_expression.rows(); }
135 EIGEN_DEVICE_FUNC
constexpr Index cols()
const noexcept {
return m_expression.cols(); }
136 EIGEN_DEVICE_FUNC
constexpr Index outerStride()
const noexcept {
return m_expression.outerStride(); }
137 EIGEN_DEVICE_FUNC
constexpr Index innerStride()
const noexcept {
return m_expression.innerStride(); }
139 EIGEN_DEVICE_FUNC
constexpr ScalarWithConstIfNotLvalue* data() {
return m_expression.data(); }
140 EIGEN_DEVICE_FUNC
constexpr const Scalar* data()
const {
return m_expression.data(); }
142 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index rowId,
Index colId)
const {
143 return m_expression.derived().coeffRef(rowId, colId);
146 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index index)
const {
return m_expression.coeffRef(index); }
148 EIGEN_DEVICE_FUNC
const internal::remove_all_t<NestedExpressionType>& nestedExpression()
const {
154 EIGEN_DEVICE_FUNC
void resize(
Index newSize) { m_expression.resize(newSize); }
160 NestedExpressionType m_expression;
MatrixWrapper< ArrayWrapper< ExpressionType > > matrix()
Definition ArrayBase.h:176
void resize(Index rows, Index cols)
Definition ArrayWrapper.h:87
void resize(Index newSize)
Definition ArrayWrapper.h:84
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:62
void resize(Index newSize)
Definition ArrayWrapper.h:154
void resize(Index rows, Index cols)
Definition ArrayWrapper.h:157
const unsigned int LvalueBit
Definition Constants.h:148
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82