WPILibC++ 2023.4.3-108-ge5452e3
is_inf.hpp
Go to the documentation of this file.
1/*################################################################################
2 ##
3 ## Copyright (C) 2016-2022 Keith O'Hara
4 ##
5 ## This file is part of the GCE-Math C++ library.
6 ##
7 ## Licensed under the Apache License, Version 2.0 (the "License");
8 ## you may not use this file except in compliance with the License.
9 ## You may obtain a copy of the License at
10 ##
11 ## http://www.apache.org/licenses/LICENSE-2.0
12 ##
13 ## Unless required by applicable law or agreed to in writing, software
14 ## distributed under the License is distributed on an "AS IS" BASIS,
15 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ## See the License for the specific language governing permissions and
17 ## limitations under the License.
18 ##
19 ################################################################################*/
20
21/*
22 * compile-time check if a float is +/-Inf
23 */
24
25#ifndef _gcem_is_inf_HPP
26#define _gcem_is_inf_HPP
27
28namespace internal
29{
30
31template<typename T>
32constexpr
33bool
34is_neginf(const T x)
35noexcept
36{
37 return x == - GCLIM<T>::infinity();
38}
39
40template<typename T1, typename T2>
41constexpr
42bool
43any_neginf(const T1 x, const T2 y)
44noexcept
45{
46 return( is_neginf(x) || is_neginf(y) );
47}
48
49template<typename T1, typename T2>
50constexpr
51bool
52all_neginf(const T1 x, const T2 y)
53noexcept
54{
55 return( is_neginf(x) && is_neginf(y) );
56}
57
58template<typename T1, typename T2, typename T3>
59constexpr
60bool
61any_neginf(const T1 x, const T2 y, const T3 z)
62noexcept
63{
64 return( is_neginf(x) || is_neginf(y) || is_neginf(z) );
65}
66
67template<typename T1, typename T2, typename T3>
68constexpr
69bool
70all_neginf(const T1 x, const T2 y, const T3 z)
71noexcept
72{
73 return( is_neginf(x) && is_neginf(y) && is_neginf(z) );
74}
75
76//
77
78template<typename T>
79constexpr
80bool
81is_posinf(const T x)
82noexcept
83{
84 return x == GCLIM<T>::infinity();
85}
86
87template<typename T1, typename T2>
88constexpr
89bool
90any_posinf(const T1 x, const T2 y)
91noexcept
92{
93 return( is_posinf(x) || is_posinf(y) );
94}
95
96template<typename T1, typename T2>
97constexpr
98bool
99all_posinf(const T1 x, const T2 y)
100noexcept
101{
102 return( is_posinf(x) && is_posinf(y) );
103}
104
105template<typename T1, typename T2, typename T3>
106constexpr
107bool
108any_posinf(const T1 x, const T2 y, const T3 z)
109noexcept
110{
111 return( is_posinf(x) || is_posinf(y) || is_posinf(z) );
112}
113
114template<typename T1, typename T2, typename T3>
115constexpr
116bool
117all_posinf(const T1 x, const T2 y, const T3 z)
118noexcept
119{
120 return( is_posinf(x) && is_posinf(y) && is_posinf(z) );
121}
122
123//
124
125template<typename T>
126constexpr
127bool
128is_inf(const T x)
129noexcept
130{
131 return( is_neginf(x) || is_posinf(x) );
132}
133
134template<typename T1, typename T2>
135constexpr
136bool
137any_inf(const T1 x, const T2 y)
138noexcept
139{
140 return( is_inf(x) || is_inf(y) );
141}
142
143template<typename T1, typename T2>
144constexpr
145bool
146all_inf(const T1 x, const T2 y)
147noexcept
148{
149 return( is_inf(x) && is_inf(y) );
150}
151
152template<typename T1, typename T2, typename T3>
153constexpr
154bool
155any_inf(const T1 x, const T2 y, const T3 z)
156noexcept
157{
158 return( is_inf(x) || is_inf(y) || is_inf(z) );
159}
160
161template<typename T1, typename T2, typename T3>
162constexpr
163bool
164all_inf(const T1 x, const T2 y, const T3 z)
165noexcept
166{
167 return( is_inf(x) && is_inf(y) && is_inf(z) );
168}
169
170}
171
172#endif
const Scalar & y
Definition: MathFunctions.h:821
Definition: Eigen_Colamd.h:50
constexpr bool is_posinf(const T x) noexcept
Definition: is_inf.hpp:81
constexpr bool all_neginf(const T1 x, const T2 y) noexcept
Definition: is_inf.hpp:52
constexpr bool is_neginf(const T x) noexcept
Definition: is_inf.hpp:34
constexpr bool any_neginf(const T1 x, const T2 y) noexcept
Definition: is_inf.hpp:43
constexpr bool any_inf(const T1 x, const T2 y) noexcept
Definition: is_inf.hpp:137
constexpr bool any_posinf(const T1 x, const T2 y) noexcept
Definition: is_inf.hpp:90
constexpr bool all_inf(const T1 x, const T2 y) noexcept
Definition: is_inf.hpp:146
constexpr bool all_posinf(const T1 x, const T2 y) noexcept
Definition: is_inf.hpp:99
constexpr bool is_inf(const T x) noexcept
Definition: is_inf.hpp:128