Main Page
Classes
Files
File List
File Members
include
KernelMath.h
Go to the documentation of this file.
1
// this is a -*- C++ -*- file
2
3
// -- BEGIN LICENSE BLOCK ----------------------------------------------
4
//
5
// You received this file as part of MCA2
6
// Modular Controller Architecture Version 2
7
//
8
// Copyright (C) FZI Forschungszentrum Informatik Karlsruhe
9
//
10
// This program is free software; you mild_base_driving redistribute it and/or
11
// modify it under the terms of the GNU General Public License
12
// as published by the Free Software Foundation; either version 2
13
// of the License, or (at your option) any later version.
14
//
15
// This program is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU General Public License for more details.
19
//
20
// You should have received a copy of the GNU General Public License
21
// along with this program; if not, write to the Free Software
22
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
//
24
// -- END LICENSE BLOCK ------------------------------------------------
25
26
//----------------------------------------------------------------------
36
//----------------------------------------------------------------------
37
#ifndef _KernelMath_h_
38
#define _KernelMath_h_
39
40
//----------------------------------------------------------------------
41
// non MCA Includes - include with <>
42
// MCA Includes - include with ""
43
//----------------------------------------------------------------------
44
#include <limits.h>
45
46
//----------------------------------------------------------------------
47
// Mathematical Function
48
//----------------------------------------------------------------------
49
52
template
<
class
T>
53
inline
T
Max
(T a, T b)
54
{
55
return
a > b ? a : b;
56
}
57
58
61
inline
double
Max
(
double
a,
double
b)
62
{
63
return
a > b ? a : b;
64
}
65
68
inline
double
Max
(
double
a,
long
b)
69
{
70
return
a > b ? a : b;
71
}
72
75
inline
double
Max
(
double
a,
unsigned
long
b)
76
{
77
return
a > b ? a : b;
78
}
79
82
inline
double
Max
(
double
a,
int
b)
83
{
84
return
a > b ? a : b;
85
}
86
89
inline
double
Max
(
double
a,
unsigned
b)
90
{
91
return
a > b ? a : b;
92
}
93
96
inline
double
Max
(
long
a,
double
b)
97
{
98
return
a > b ? a : b;
99
}
100
103
inline
double
Max
(
unsigned
long
a,
double
b)
104
{
105
return
a > b ? a : b;
106
}
107
110
inline
double
Max
(
int
a,
double
b)
111
{
112
return
a > b ? a : b;
113
}
114
117
inline
double
Max
(
unsigned
a,
double
b)
118
{
119
return
a > b ? a : b;
120
}
121
124
inline
int
Max
(
int
a,
int
b)
125
{
126
return
a > b ? a : b;
127
}
128
129
#if 1
130
//#ifdef _SYSTEM_DARWIN_
133
inline
unsigned
long
Max
(
unsigned
long
a,
int
b)
134
{
135
// !!!Be Carefull size_t will be casted to unsigned!!!
136
return
b < 0 ? a :
Max
(
unsigned
(a),
unsigned
(b));
137
}
138
141
inline
unsigned
long
Max
(
int
a,
unsigned
long
b)
142
{
143
// !!!Be Carefull size_t will be casted to unsigned!!!
144
return
a < 0 ? b :
Max
(
unsigned
(a),
unsigned
(b));
145
}
146
149
inline
unsigned
long
Max
(
unsigned
a,
unsigned
long
b)
150
{
151
return
a > b ? a : b;
152
}
153
#endif
154
157
inline
unsigned
Max
(
unsigned
a,
unsigned
b)
158
{
159
return
a > b ? a : b;
160
}
161
164
inline
unsigned
Max
(
int
a,
unsigned
b)
165
{
166
return
a < 0 ? b :
Max
(
unsigned
(a), b);
167
}
168
171
inline
unsigned
Max
(
unsigned
a,
int
b)
172
{
173
return
Max
(b, a);
174
}
175
178
inline
double
Max
(
double
a,
double
b,
double
c)
179
{
180
return
Max
(a,
Max
(b, c));
181
}
182
185
template
<
typename
A,
typename
B,
typename
C,
typename
D,
typename
R>
186
inline
R
Max
(A a, B b, C c, D d)
187
{
188
return
Max
(a,
Max
(b,
Max
(c, d)));
189
}
190
193
template
<
class
T>
194
inline
T
Min
(T a, T b)
195
{
196
return
a < b ? a : b;
197
}
198
201
inline
double
Min
(
double
a,
double
b)
202
{
203
return
a < b ? a : b;
204
}
205
208
inline
double
Min
(
double
a,
long
b)
209
{
210
return
a < b ? a : b;
211
}
212
215
inline
double
Min
(
double
a,
int
b)
216
{
217
return
a < b ? a : b;
218
}
219
222
inline
double
Min
(
double
a,
unsigned
long
b)
223
{
224
return
a < b ? a : b;
225
}
226
229
inline
double
Min
(
double
a,
unsigned
b)
230
{
231
return
a < b ? a : b;
232
}
233
236
inline
double
Min
(
long
a,
double
b)
237
{
238
return
a < b ? a : b;
239
}
240
243
inline
double
Min
(
int
a,
double
b)
244
{
245
return
a < b ? a : b;
246
}
247
250
inline
double
Min
(
unsigned
long
a,
double
b)
251
{
252
return
a < b ? a : b;
253
}
254
257
inline
double
Min
(
unsigned
a,
double
b)
258
{
259
return
a < b ? a : b;
260
}
261
264
inline
int
Min
(
int
a,
int
b)
265
{
266
return
a < b ? a : b;
267
}
268
271
inline
void
*
Min
(
void
* a,
void
* b)
272
{
273
return
a < b ? a : b;
274
}
275
278
inline
unsigned
Min
(
unsigned
a,
unsigned
b)
279
{
280
return
a < b ? a : b;
281
}
282
285
inline
int
Min
(
int
a,
unsigned
int
b)
286
{
287
return
b > INT_MAX ? a : (
Min
(
int
(b), a));
288
}
289
292
inline
int
Min
(
unsigned
int
a,
int
b)
293
{
294
return
Min
(b, a);
295
}
296
299
inline
double
Min
(
double
a,
double
b,
double
c)
300
{
301
return
Min
(a,
Min
(b, c));
302
}
303
306
template
<
typename
A,
typename
B,
typename
C,
typename
D,
typename
R>
307
inline
R
Min
(A a, B b, C c, D d)
308
{
309
return
Min
(a,
Min
(b,
Min
(c, d)));
310
}
311
314
template
<
typename
T>
315
inline
T
Abs
(T x)
316
{
317
return
(x > 0 ? x : -x);
318
}
319
320
#endif
Max
T Max(T a, T b)
Definition:
KernelMath.h:53
Abs
T Abs(T x)
Definition:
KernelMath.h:315
Min
T Min(T a, T b)
Definition:
KernelMath.h:194
asr_mild_base_driving
Author(s): Aumann Florian, Borella Jocelyn, Dehmani Souheil, Marek Felix, Meißner Pascal, Reckling Reno
autogenerated on Mon Jun 10 2019 12:43:40