Eigen  5.0.1
 
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 EIGEN_DEVICE_FUNC constexpr std::enable_if_t<HasDirectAccess, const Scalar*> data() const {
57 return m_expression.data();
58 }
59
60 EIGEN_DEVICE_FUNC constexpr std::enable_if_t<HasDirectAccess, Index> innerStride() const {
61 return m_expression.innerStride();
62 }
63
64 EIGEN_DEVICE_FUNC constexpr std::enable_if_t<HasDirectAccess, Index> outerStride() const {
65 return m_expression.outerStride();
66 }
67
68 protected:
69 const ExpressionType m_expression;
70};
71
74template <typename Derived>
75EIGEN_DEVICE_FUNC constexpr inline const NestByValue<Derived> DenseBase<Derived>::nestByValue() const {
76 return NestByValue<Derived>(derived());
77}
78
79namespace internal {
80
81// Evaluator of NestByValue<> -> forwards to the evaluator of the nested expression
82template <typename ArgType>
83struct evaluator<NestByValue<ArgType> > : public evaluator<ArgType> {
84 using Base = evaluator<ArgType>;
85
86 EIGEN_DEVICE_FUNC constexpr explicit evaluator(const NestByValue<ArgType>& xpr) : Base(xpr.nestedExpression()) {}
87};
88} // namespace internal
89
90} // end namespace Eigen
91
92#endif // EIGEN_NESTBYVALUE_H
constexpr const NestByValue< Derived > nestByValue() const
Definition NestByValue.h:75
Expression which must be nested by value.
Definition NestByValue.h:40