11#ifndef EIGEN_ARRAYWRAPPER_H
12#define EIGEN_ARRAYWRAPPER_H
15#include "./InternalHeaderCheck.h"
31template <
typename ExpressionType>
32struct traits<ArrayWrapper<ExpressionType> > :
public traits<remove_all_t<typename ExpressionType::Nested> > {
33 using XprKind = ArrayXpr;
36 Flags0 = traits<remove_all_t<typename ExpressionType::Nested> >::Flags,
37 LvalueBitFlag = is_lvalue<ExpressionType>::value ?
LvalueBit : 0,
38 Flags = (Flags0 & ~(NestByRefBit |
LvalueBit)) | LvalueBitFlag
43template <
typename ExpressionType>
44class ArrayWrapper :
public ArrayBase<ArrayWrapper<ExpressionType> > {
46 using Base = ArrayBase<ArrayWrapper>;
47 EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
48 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
49 using NestedExpression = internal::remove_all_t<ExpressionType>;
51 using ScalarWithConstIfNotLvalue =
52 std::conditional_t<internal::is_lvalue<ExpressionType>::value,
Scalar,
const Scalar>;
54 using NestedExpressionType =
typename internal::ref_selector<ExpressionType>::non_const_type;
58 EIGEN_DEVICE_FUNC
constexpr explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType&
matrix)
61 EIGEN_DEVICE_FUNC
constexpr Index rows()
const noexcept {
return m_expression.rows(); }
62 EIGEN_DEVICE_FUNC
constexpr Index cols()
const noexcept {
return m_expression.cols(); }
63 EIGEN_DEVICE_FUNC
constexpr Index outerStride()
const noexcept {
return m_expression.outerStride(); }
64 EIGEN_DEVICE_FUNC
constexpr Index innerStride()
const noexcept {
return m_expression.innerStride(); }
66 EIGEN_DEVICE_FUNC
constexpr ScalarWithConstIfNotLvalue* data() {
return m_expression.data(); }
67 EIGEN_DEVICE_FUNC
constexpr const Scalar* data()
const {
return m_expression.data(); }
69 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(Index rowId, Index colId)
const {
70 return m_expression.coeffRef(rowId, colId);
73 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(Index index)
const {
return m_expression.coeffRef(index); }
75 template <
typename Dest>
76 EIGEN_DEVICE_FUNC
inline void evalTo(Dest& dst)
const {
80 EIGEN_DEVICE_FUNC
constexpr const internal::remove_all_t<NestedExpressionType>& nestedExpression()
const {
86 EIGEN_DEVICE_FUNC
void resize(Index newSize) { m_expression.resize(newSize); }
89 EIGEN_DEVICE_FUNC
void resize(Index rows, Index cols) { m_expression.resize(rows, cols); }
92 NestedExpressionType m_expression;
107template <
typename ExpressionType>
108struct traits<MatrixWrapper<ExpressionType> > :
public traits<remove_all_t<typename ExpressionType::Nested> > {
109 using XprKind = MatrixXpr;
112 Flags0 = traits<remove_all_t<typename ExpressionType::Nested> >::Flags,
113 LvalueBitFlag = is_lvalue<ExpressionType>::value ?
LvalueBit : 0,
114 Flags = (Flags0 & ~(NestByRefBit |
LvalueBit)) | LvalueBitFlag
119template <
typename ExpressionType>
120class MatrixWrapper :
public MatrixBase<MatrixWrapper<ExpressionType> > {
122 using Base = MatrixBase<MatrixWrapper<ExpressionType>>;
123 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
124 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
125 using NestedExpression = internal::remove_all_t<ExpressionType>;
127 using ScalarWithConstIfNotLvalue =
128 std::conditional_t<internal::is_lvalue<ExpressionType>::value,
Scalar,
const Scalar>;
130 using NestedExpressionType =
typename internal::ref_selector<ExpressionType>::non_const_type;
132 using Base::coeffRef;
134 EIGEN_DEVICE_FUNC
constexpr explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
136 EIGEN_DEVICE_FUNC
constexpr Index rows()
const noexcept {
return m_expression.rows(); }
137 EIGEN_DEVICE_FUNC
constexpr Index cols()
const noexcept {
return m_expression.cols(); }
138 EIGEN_DEVICE_FUNC
constexpr Index outerStride()
const noexcept {
return m_expression.outerStride(); }
139 EIGEN_DEVICE_FUNC
constexpr Index innerStride()
const noexcept {
return m_expression.innerStride(); }
141 EIGEN_DEVICE_FUNC
constexpr ScalarWithConstIfNotLvalue* data() {
return m_expression.data(); }
142 EIGEN_DEVICE_FUNC
constexpr const Scalar* data()
const {
return m_expression.data(); }
144 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(Index rowId, Index colId)
const {
145 return m_expression.derived().coeffRef(rowId, colId);
148 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(Index index)
const {
return m_expression.coeffRef(index); }
150 EIGEN_DEVICE_FUNC
constexpr const internal::remove_all_t<NestedExpressionType>& nestedExpression()
const {
156 EIGEN_DEVICE_FUNC
void resize(Index newSize) { m_expression.resize(newSize); }
159 EIGEN_DEVICE_FUNC
void resize(Index rows, Index cols) { m_expression.resize(rows, cols); }
162 NestedExpressionType m_expression;
constexpr MatrixWrapper< ArrayWrapper< ExpressionType > > matrix()
Definition ArrayBase.h:177
void resize(Index rows, Index cols)
Definition ArrayWrapper.h:89
void resize(Index newSize)
Definition ArrayWrapper.h:86
typename internal::traits< ArrayWrapper< ExpressionType > >::Scalar Scalar
Definition DenseBase.h:63
void resize(Index newSize)
Definition ArrayWrapper.h:156
void resize(Index rows, Index cols)
Definition ArrayWrapper.h:159
constexpr unsigned int LvalueBit
Definition Constants.h:149