vnl_complex.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_complex.h
2 #ifndef vnl_complex_h_
3 #define vnl_complex_h_
4 //:
5 // \file
6 // \brief Complex additions to vnl_math.
7 //
8 // We don't want everyone to pay for complex when they don't need it, as
9 // its ratio of expense to frequency of use is high. So we define those
10 // functions from vnl_math which use complex here instead.
11 // So this file adds to the vnl_math namespace.
12 //
13 // \verbatim
14 // Modifications
15 // LSB (Manchester) 26/03/2001 Tidied documentation
16 // Peter Vanroose 24/10/2012 Now adds to the vnl_math namespace
17 // \endverbatim
18 
19 #include <cmath>
20 #include <complex>
21 #include <iosfwd>
22 #ifdef _MSC_VER
23 # include <vcl_msvc_warnings.h>
24 #endif
25 #include <vnl/vnl_math.h>
26 #include "vnl/vnl_export.h"
27 
28 namespace vnl_math
29 {
30  // should consider making these function templated,
31 #define type_macro(T) \
32  inline bool isnan(std::complex<T >const& z) { return isnan(std::real(z)) || isnan(std::imag(z)); } \
33  inline bool isfinite(std::complex<T >const& z) { return isfinite(std::real(z)) && isfinite(std::imag(z)); } \
34  inline T abs(std::complex<T > const& z) { return std::abs(z); } \
35  inline std::complex<T > sqr(std::complex<T > const& z) { return z*z; } \
36  inline T squared_magnitude(std::complex<T > const& z) { return std::norm(z); }
37  type_macro(float)
38  type_macro(double)
39  type_macro(long double)
40 #undef type_macro
41 
42 } // end namespace vnl_math
43 
44 #endif // vnl_complex_h_
#define type_macro(T)
Definition: vnl_complex.h:31
Namespace with standard math functions.
real numerical constants.
Definition: vnl_bignum.h:430