Eigen  5.0.1-dev+master
 
Loading...
Searching...
No Matches
NestByValue.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6//
7// This Source Code Form is subject to the terms of the Mozilla
8// Public License v. 2.0. If a copy of the MPL was not distributed
9// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10// SPDX-License-Identifier: MPL-2.0
11
12#ifndef EIGEN_NESTBYVALUE_H
13#define EIGEN_NESTBYVALUE_H
14
15// IWYU pragma: private
16#include "./InternalHeaderCheck.h"
17
18namespace Eigen {
19
20namespace internal {
21template <typename ExpressionType>
22struct traits<NestByValue<ExpressionType> > : public traits<ExpressionType> {
23 enum { Flags = traits<ExpressionType>::Flags & ~NestByRefBit };
24};
25} // namespace internal
26
39template <typename ExpressionType>
40class NestByValue : public internal::dense_xpr_base<NestByValue<ExpressionType> >::type {
41 public:
42 using Base = typename internal::dense_xpr_base<NestByValue>::type;
43 static constexpr bool HasDirectAccess = internal::has_direct_access<ExpressionType>::value;
44
45 EIGEN_DENSE_PUBLIC_INTERFACE(NestByValue)
46
47 EIGEN_DEVICE_FUNC constexpr explicit inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
48
49 EIGEN_DEVICE_FUNC constexpr Index rows() const noexcept { return m_expression.rows(); }
50 EIGEN_DEVICE_FUNC constexpr Index cols() const noexcept { return m_expression.cols(); }
51
52 EIGEN_DEVICE_FUNC constexpr operator const ExpressionType&() const { return m_expression; }
53
54 EIGEN_DEVICE_FUNC constexpr const ExpressionType& nestedExpression() const { return m_expression; }
55
56 template <bool Enable = HasDirectAccess, std::enable_if_t<Enable, bool> = true>
57 EIGEN_DEVICE_FUNC constexpr const Scalar* data() const {
58 return m_expression.data();
59 }
60
61 template <bool Enable = HasDirectAccess, std::enable_if_t<Enable, bool> = true>
62 EIGEN_DEVICE_FUNC constexpr Index innerStride() const {
63 return m_expression.innerStride();
64 }
65
66 template <bool Enable = HasDirectAccess, std::enable_if_t<Enable, bool> = true>
67 EIGEN_DEVICE_FUNC constexpr Index outerStride() const {
68 return m_expression.outerStride();
69 }
70
71 protected:
72 const ExpressionType m_expression;
73};
74
77template <typename Derived>
78EIGEN_DEVICE_FUNC constexpr inline const NestByValue<Derived> DenseBase<Derived>::nestByValue() const {
79 return NestByValue<Derived>(derived());
80}
81
82namespace internal {
83
84// Evaluator of NestByValue<> -> forwards to the evaluator of the nested expression
85template <typename ArgType>
86struct evaluator<NestByValue<ArgType> > : public evaluator<ArgType> {
87 using Base = evaluator<ArgType>;
88
89 EIGEN_DEVICE_FUNC constexpr explicit evaluator(const NestByValue<ArgType>& xpr) : Base(xpr.nestedExpression()) {}
90};
91} // namespace internal
92
93} // end namespace Eigen
94
95#endif // EIGEN_NESTBYVALUE_H
constexpr const NestByValue< Derived > nestByValue() const
Definition NestByValue.h:78
Expression which must be nested by value.
Definition NestByValue.h:40