radarlib 1.4.6
math.hpp
Go to the documentation of this file.
1/*
2 * Radar Library
3 *
4 * Copyright (C) 2009-2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Author: Guido Billi <guidobilli@gmail.com>
21 */
22
27#ifndef __RADAR_MATH_HPP__
28#define __RADAR_MATH_HPP__
29
30#include <limits>
31#include <climits>
32#include <cmath>
33
34#include <radarlib/defs.h>
35
36namespace Radar { namespace math {
37
38/*===========================================================================*/
39/* USEFULL DEFINES TO SIMPLIFY CODE */
40/*===========================================================================*/
41
42#define FLOAT_NAN std::numeric_limits<float>::quiet_NaN()
43#define FLOAT_MAX std::numeric_limits<float>::max()
44#define FLOAT_MIN std::numeric_limits<float>::min()
45
46#define DOUBLE_NAN std::numeric_limits<double>::quiet_NaN()
47#define DOUBLE_MAX std::numeric_limits<double>::max()
48#define DOUBLE_MIN std::numeric_limits<double>::min()
49
50/*===========================================================================*/
51
52#if defined(WIN32)
53
54//#ifndef isnan
55static inline bool isnan(double x) { return x != x; }
56//#endif
57
58#endif
59
60static inline bool isnan(float x) { return x != x; }
61
62static inline float abs(float x) { return (x > 0 ? x : -x); }
63static inline double abs(double x) { return (x > 0 ? x : -x); }
64
65/*===========================================================================*/
66
67} }
68
69#endif
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Internal library macros.