11#ifndef EIGEN_INTEGRAL_CONSTANT_H
12#define EIGEN_INTEGRAL_CONSTANT_H
18template<
int N>
class FixedInt;
19template<
int N>
class VariableAndFixedInt;
51template<
int N>
class FixedInt
54 static const int value = N;
55 EIGEN_CONSTEXPR
operator int()
const {
return value; }
57 FixedInt( VariableAndFixedInt<N> other) {
58 #ifndef EIGEN_INTERNAL_DEBUGGING
59 EIGEN_UNUSED_VARIABLE(other);
61 eigen_internal_assert(
int(other)==N);
64 FixedInt<-N> operator-()
const {
return FixedInt<-N>(); }
66 FixedInt<N+M> operator+( FixedInt<M>)
const {
return FixedInt<N+M>(); }
68 FixedInt<N-M> operator-( FixedInt<M>)
const {
return FixedInt<N-M>(); }
70 FixedInt<N*M> operator*( FixedInt<M>)
const {
return FixedInt<N*M>(); }
72 FixedInt<N/M> operator/( FixedInt<M>)
const {
return FixedInt<N/M>(); }
74 FixedInt<N%M> operator%( FixedInt<M>)
const {
return FixedInt<N%M>(); }
76 FixedInt<N|M> operator|( FixedInt<M>)
const {
return FixedInt<N|M>(); }
78 FixedInt<N&M> operator&( FixedInt<M>)
const {
return FixedInt<N&M>(); }
80#if EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
82 FixedInt operator() ()
const {
return *
this; }
84 VariableAndFixedInt<N> operator() (
int val)
const {
return VariableAndFixedInt<N>(val); }
86 FixedInt ( FixedInt<N> (*)() ) {}
90 FixedInt(std::integral_constant<int,N>) {}
123template<
int N>
class VariableAndFixedInt
126 static const int value = N;
127 operator int()
const {
return m_value; }
128 VariableAndFixedInt(
int val) { m_value = val; }
133template<
typename T,
int Default=Dynamic>
struct get_fixed_value {
134 static const int value = Default;
137template<
int N,
int Default>
struct get_fixed_value<FixedInt<N>,Default> {
138 static const int value = N;
142template<
int N,
int Default>
struct get_fixed_value<FixedInt<N> (*)(),Default> {
143 static const int value = N;
147template<
int N,
int Default>
struct get_fixed_value<VariableAndFixedInt<N>,Default> {
148 static const int value = N ;
151template<
typename T,
int N,
int Default>
152struct get_fixed_value<variable_if_dynamic<T,N>,Default> {
153 static const int value = N;
156template<
typename T> EIGEN_DEVICE_FUNC
Index get_runtime_value(
const T &x) {
return x; }
158template<
int N> EIGEN_DEVICE_FUNC
Index get_runtime_value(FixedInt<N> (*)()) {
return N; }
164template<
typename T,
int DynamicKey=Dynamic,
typename EnableIf=
void>
struct cleanup_index_type {
typedef T type; };
167template<
typename T,
int DynamicKey>
struct cleanup_index_type<T,DynamicKey,typename internal::enable_if<internal::is_integral<T>::value>::type> {
typedef Index type; };
171template<
int N,
int DynamicKey>
struct cleanup_index_type<FixedInt<N> (*)(), DynamicKey> {
typedef FixedInt<N> type; };
175template<
int N,
int DynamicKey>
struct cleanup_index_type<VariableAndFixedInt<N>, DynamicKey> {
typedef FixedInt<N> type; };
177template<
int DynamicKey>
struct cleanup_index_type<VariableAndFixedInt<DynamicKey>, DynamicKey> {
typedef Index type; };
180template<
int N,
int DynamicKey>
struct cleanup_index_type<std::integral_constant<int,N>, DynamicKey> {
typedef FixedInt<N> type; };
185#ifndef EIGEN_PARSED_BY_DOXYGEN
187#if EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
189static const internal::FixedInt<N>
fix{};
192inline internal::FixedInt<N>
fix() {
return internal::FixedInt<N>(); }
196template<
int N,
typename T>
197inline internal::VariableAndFixedInt<N>
fix(T val) {
return internal::VariableAndFixedInt<N>(internal::convert_index<int>(val)); }
266static const auto fix(
int val);
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74