IndexedViewHelper.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 
11 #ifndef EIGEN_INDEXED_VIEW_HELPER_H
12 #define EIGEN_INDEXED_VIEW_HELPER_H
13 
14 namespace Eigen {
15 
16 namespace internal {
18 }
19 
38 static const symbolic::SymbolExpr<internal::symbolic_last_tag> last; // PLEASE use Eigen::last instead of Eigen::placeholders::last
39 
52 #ifdef EIGEN_PARSED_BY_DOXYGEN
53 static const auto lastp1 = last+fix<1>;
54 #else
55 // Using a FixedExpr<1> expression is important here to make sure the compiler
56 // can fully optimize the computation starting indices with zero overhead.
58 #endif
59 
60 namespace internal {
61 
62  // Replace symbolic last/end "keywords" by their true runtime value
63 inline Index eval_expr_given_size(Index x, Index /* size */) { return x; }
64 
65 template<int N>
67 
68 template<typename Derived>
70 {
71  return x.derived().eval(last=size-1);
72 }
73 
74 // Extract increment/step at compile time
75 template<typename T, typename EnableIf = void> struct get_compile_time_incr {
76  enum { value = UndefinedIncr };
77 };
78 
79 // Analogue of std::get<0>(x), but tailored for our needs.
80 template<typename T>
81 EIGEN_CONSTEXPR Index first(const T& x) EIGEN_NOEXCEPT { return x.first(); }
82 
83 // IndexedViewCompatibleType/makeIndexedViewCompatible turn an arbitrary object of type T into something usable by MatrixSlice
84 // The generic implementation is a no-op
85 template<typename T,int XprSize,typename EnableIf=void>
87  typedef T type;
88 };
89 
90 template<typename T,typename Q>
91 const T& makeIndexedViewCompatible(const T& x, Index /*size*/, Q) { return x; }
92 
93 //--------------------------------------------------------------------------------
94 // Handling of a single Index
95 //--------------------------------------------------------------------------------
96 
97 struct SingleRange {
98  enum {
100  };
101  SingleRange(Index val) : m_value(val) {}
102  Index operator[](Index) const { return m_value; }
103  static EIGEN_CONSTEXPR Index size() EIGEN_NOEXCEPT { return 1; }
104  Index first() const EIGEN_NOEXCEPT { return m_value; }
106 };
107 
108 template<> struct get_compile_time_incr<SingleRange> {
109  enum { value = 1 }; // 1 or 0 ??
110 };
111 
112 // Turn a single index into something that looks like an array (i.e., that exposes a .size(), and operator[](int) methods)
113 template<typename T, int XprSize>
114 struct IndexedViewCompatibleType<T,XprSize,typename internal::enable_if<internal::is_integral<T>::value>::type> {
115  // Here we could simply use Array, but maybe it's less work for the compiler to use
116  // a simpler wrapper as SingleRange
117  //typedef Eigen::Array<Index,1,1> type;
118  typedef SingleRange type;
119 };
120 
121 template<typename T, int XprSize>
122 struct IndexedViewCompatibleType<T, XprSize, typename enable_if<symbolic::is_symbolic<T>::value>::type> {
123  typedef SingleRange type;
124 };
125 
126 
127 template<typename T>
130  return eval_expr_given_size(id,size);
131 }
132 
133 //--------------------------------------------------------------------------------
134 // Handling of all
135 //--------------------------------------------------------------------------------
136 
137 struct all_t { all_t() {} };
138 
139 // Convert a symbolic 'all' into a usable range type
140 template<int XprSize>
141 struct AllRange {
142  enum { SizeAtCompileTime = XprSize };
143  AllRange(Index size = XprSize) : m_size(size) {}
148 };
149 
150 template<int XprSize>
153 };
154 
155 template<typename XprSizeType>
158 }
159 
160 template<int Size> struct get_compile_time_incr<AllRange<Size> > {
161  enum { value = 1 };
162 };
163 
164 } // end namespace internal
165 
166 
171 static const Eigen::internal::all_t all; // PLEASE use Eigen::all instead of Eigen::placeholders::all
172 
173 
174 namespace placeholders {
178 
179  EIGEN_DEPRECATED static const all_t all = Eigen::all; // PLEASE use Eigen::all instead of Eigen::placeholders::all
180  EIGEN_DEPRECATED static const last_t last = Eigen::last; // PLEASE use Eigen::last instead of Eigen::placeholders::last
181  EIGEN_DEPRECATED static const end_t end = Eigen::lastp1; // PLEASE use Eigen::lastp1 instead of Eigen::placeholders::end
182 }
183 
184 } // end namespace Eigen
185 
186 #endif // EIGEN_INDEXED_VIEW_HELPER_H
Eigen::internal::SingleRange::SingleRange
SingleRange(Index val)
Definition: IndexedViewHelper.h:101
Eigen::internal::AllRange::first
EIGEN_CONSTEXPR Index first() const EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:146
Eigen::internal::variable_if_dynamic< Index, XprSize >
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::internal::IndexedViewCompatibleType
Definition: IndexedViewHelper.h:86
Eigen::placeholders::last
static const EIGEN_DEPRECATED last_t last
Definition: IndexedViewHelper.h:180
Eigen::internal::AllRange::operator[]
EIGEN_CONSTEXPR Index operator[](Index i) const EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:144
Eigen::SpecializedType
SpecializedType
Definition: Constants.h:309
Eigen::UndefinedIncr
const int UndefinedIncr
Definition: Constants.h:31
Eigen::internal::eval_expr_given_size
Index eval_expr_given_size(Index x, Index)
Definition: IndexedViewHelper.h:63
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
EIGEN_CONSTEXPR
#define EIGEN_CONSTEXPR
Definition: Macros.h:787
EIGEN_DEPRECATED
#define EIGEN_DEPRECATED
Definition: Macros.h:1058
Eigen::internal::FixedInt
Definition: IntegralConstant.h:18
type
Definition: pytypes.h:1525
Eigen::internal::get_compile_time_incr::value
@ value
Definition: IndexedViewHelper.h:76
Eigen::last
static const symbolic::SymbolExpr< internal::symbolic_last_tag > last
Definition: IndexedViewHelper.h:38
Eigen::internal::makeIndexedViewCompatible
ArithmeticSequence< Index, typename make_size_type< SizeType >::type, IncrType > makeIndexedViewCompatible(const ArithmeticSequence< FirstType, SizeType, IncrType > &ids, Index size, SpecializedType)
Definition: ArithmeticSequence.h:366
Eigen::symbolic::ValueExpr
Definition: SymbolicIndex.h:52
Eigen::internal::SingleRange
Definition: IndexedViewHelper.h:97
Eigen::internal::AllRange
Definition: IndexedViewHelper.h:141
Eigen::placeholders::end_t
symbolic::AddExpr< symbolic::SymbolExpr< internal::symbolic_last_tag >, symbolic::ValueExpr< Eigen::internal::FixedInt< 1 > > > end_t
Definition: IndexedViewHelper.h:176
Eigen::internal::SingleRange::size
static EIGEN_CONSTEXPR Index size() EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:103
Eigen::symbolic::BaseExpr
Definition: SymbolicIndex.h:77
Eigen::internal::AllRange::size
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:145
Eigen::all
static const Eigen::internal::all_t all
Definition: IndexedViewHelper.h:171
Eigen::internal::AllRange::SizeAtCompileTime
@ SizeAtCompileTime
Definition: IndexedViewHelper.h:142
Eigen::internal::variable_if_dynamic::value
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value()
Definition: XprHelper.h:135
Eigen::internal::first
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:81
Eigen::internal::IndexedViewCompatibleType< T, XprSize, typename internal::enable_if< internal::is_integral< T >::value >::type >::type
SingleRange type
Definition: IndexedViewHelper.h:118
Eigen::internal::IndexedViewCompatibleType< T, XprSize, typename enable_if< symbolic::is_symbolic< T >::value >::type >::type
SingleRange type
Definition: IndexedViewHelper.h:123
Eigen::internal::all_t::all_t
all_t()
Definition: IndexedViewHelper.h:137
Eigen::Triplet
A small structure to hold a non zero as a triplet (i,j,value).
Definition: SparseUtil.h:162
Eigen::placeholders::last_t
symbolic::SymbolExpr< internal::symbolic_last_tag > last_t
Definition: IndexedViewHelper.h:175
Eigen::symbolic::AddExpr
Definition: SymbolicIndex.h:45
Eigen::Quaternion
The quaternion class used to represent 3D orientations and rotations.
Definition: ForwardDeclarations.h:293
Eigen::internal::SingleRange::SizeAtCompileTime
@ SizeAtCompileTime
Definition: IndexedViewHelper.h:99
Eigen::internal::SingleRange::m_value
Index m_value
Definition: IndexedViewHelper.h:105
Eigen::internal::AllRange::m_size
variable_if_dynamic< Index, XprSize > m_size
Definition: IndexedViewHelper.h:147
Eigen::placeholders::all_t
Eigen::internal::all_t all_t
Definition: IndexedViewHelper.h:177
Eigen::internal::IndexedViewCompatibleType< all_t, XprSize >::type
AllRange< XprSize > type
Definition: IndexedViewHelper.h:152
Eigen::lastp1
static const symbolic::AddExpr< symbolic::SymbolExpr< internal::symbolic_last_tag >, symbolic::ValueExpr< Eigen::internal::FixedInt< 1 > > > lastp1(last+fix< 1 >())
Eigen::internal::symbolic_last_tag
Definition: IndexedViewHelper.h:17
Eigen::placeholders::all
static const EIGEN_DEPRECATED all_t all
Definition: IndexedViewHelper.h:179
Eigen::internal::SingleRange::operator[]
Index operator[](Index) const
Definition: IndexedViewHelper.h:102
EIGEN_NOEXCEPT
#define EIGEN_NOEXCEPT
Definition: Macros.h:1418
internal
Definition: BandTriangularSolver.h:13
Eigen::internal::SingleRange::first
Index first() const EIGEN_NOEXCEPT
Definition: IndexedViewHelper.h:104
Eigen::internal::enable_if
Definition: Meta.h:273
Eigen::internal::size
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
Eigen::placeholders::end
static const EIGEN_DEPRECATED end_t end
Definition: IndexedViewHelper.h:181
Eigen::internal::IndexedViewCompatibleType::type
T type
Definition: IndexedViewHelper.h:87
Eigen::internal::AllRange::AllRange
AllRange(Index size=XprSize)
Definition: IndexedViewHelper.h:143
test_callbacks.value
value
Definition: test_callbacks.py:160
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::internal::get_compile_time_incr
Definition: IndexedViewHelper.h:75
Eigen::internal::all_t
Definition: IndexedViewHelper.h:137
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Eigen::symbolic::SymbolExpr
Definition: SymbolicIndex.h:213


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:28