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>
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;
59 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index rows()
const EIGEN_NOEXCEPT {
return m_expression.rows(); }
60 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index cols()
const EIGEN_NOEXCEPT {
return m_expression.cols(); }
61 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index outerStride()
const EIGEN_NOEXCEPT {
62 return m_expression.outerStride();
64 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index innerStride()
const EIGEN_NOEXCEPT {
65 return m_expression.innerStride();
68 EIGEN_DEVICE_FUNC
inline ScalarWithConstIfNotLvalue* data() {
return m_expression.data(); }
69 EIGEN_DEVICE_FUNC
inline const Scalar* data()
const {
return m_expression.data(); }
71 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index rowId,
Index colId)
const {
72 return m_expression.coeffRef(rowId, colId);
75 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index index)
const {
return m_expression.coeffRef(index); }
77 template <
typename Dest>
78 EIGEN_DEVICE_FUNC
inline void evalTo(Dest& dst)
const {
82 EIGEN_DEVICE_FUNC
const internal::remove_all_t<NestedExpressionType>& nestedExpression()
const {
88 EIGEN_DEVICE_FUNC
void resize(
Index newSize) { m_expression.resize(newSize); }
91 EIGEN_DEVICE_FUNC
void resize(
Index rows,
Index cols) { m_expression.resize(rows, cols); }
94 NestedExpressionType m_expression;
109template <
typename ExpressionType>
110struct traits<MatrixWrapper<ExpressionType> > :
public traits<remove_all_t<typename ExpressionType::Nested> > {
111 typedef MatrixXpr XprKind;
114 Flags0 = traits<remove_all_t<typename ExpressionType::Nested> >::Flags,
115 LvalueBitFlag = is_lvalue<ExpressionType>::value ? LvalueBit : 0,
116 Flags = (Flags0 & ~(NestByRefBit | LvalueBit)) | LvalueBitFlag
121template <
typename ExpressionType>
127 typedef internal::remove_all_t<ExpressionType> NestedExpression;
129 typedef std::conditional_t<internal::is_lvalue<ExpressionType>::value,
Scalar,
const Scalar>
130 ScalarWithConstIfNotLvalue;
132 typedef typename internal::ref_selector<ExpressionType>::non_const_type NestedExpressionType;
134 using Base::coeffRef;
136 EIGEN_DEVICE_FUNC
explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
138 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index rows()
const EIGEN_NOEXCEPT {
return m_expression.rows(); }
139 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index cols()
const EIGEN_NOEXCEPT {
return m_expression.cols(); }
140 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index outerStride()
const EIGEN_NOEXCEPT {
141 return m_expression.outerStride();
143 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
inline Index innerStride()
const EIGEN_NOEXCEPT {
144 return m_expression.innerStride();
147 EIGEN_DEVICE_FUNC
inline ScalarWithConstIfNotLvalue* data() {
return m_expression.data(); }
148 EIGEN_DEVICE_FUNC
inline const Scalar* data()
const {
return m_expression.data(); }
150 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index rowId,
Index colId)
const {
151 return m_expression.derived().coeffRef(rowId, colId);
154 EIGEN_DEVICE_FUNC
inline const Scalar& coeffRef(
Index index)
const {
return m_expression.coeffRef(index); }
156 EIGEN_DEVICE_FUNC
const internal::remove_all_t<NestedExpressionType>& nestedExpression()
const {
162 EIGEN_DEVICE_FUNC
void resize(
Index newSize) { m_expression.resize(newSize); }
168 NestedExpressionType m_expression;
Base class for all 1D and 2D array, and related expressions.
Definition ArrayBase.h:44
MatrixWrapper< ArrayWrapper< ExpressionType > > matrix()
Definition ArrayBase.h:141
Expression of a mathematical vector or matrix as an array object.
Definition ArrayWrapper.h:43
void resize(Index rows, Index cols)
Definition ArrayWrapper.h:91
void resize(Index newSize)
Definition ArrayWrapper.h:88
internal::traits< ArrayWrapper< ExpressionType > >::Scalar Scalar
Definition DenseBase.h:62
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
Expression of an array as a mathematical vector or matrix.
Definition ArrayWrapper.h:122
void resize(Index newSize)
Definition ArrayWrapper.h:162
void resize(Index rows, Index cols)
Definition ArrayWrapper.h:165
const unsigned int LvalueBit
Definition Constants.h:148
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83