SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
complex_cast.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
67 
78 #ifndef SLIP_COMPLEX_CAST_HPP
79 #define SLIP_COMPLEX_CAST_HPP
80 
81 #include <complex>
82 
83 #if __cplusplus <= 199711L //if < C++11
84 namespace std
85 {
86 
87  inline int conj (const int arg) {return arg;}
88  inline unsigned conj (const unsigned arg) {return arg;}
89  inline long conj (const long arg) {return arg;}
90  inline short conj (const short arg) {return arg;}
91  inline char conj (const char arg) {return arg;}
92  inline float conj (const float arg) {return arg;}
93  inline double conj (const double arg) {return arg;}
94  inline long double conj (const long double arg) {return arg;}
95 
96  inline int real (const int d) { return d; }
97  inline unsigned real (const unsigned d) { return d; }
98  inline float real (const float d) { return d; }
99  inline double real (const double d) { return d; }
100  inline long double real (const long double d) { return d; }
101 
102  inline int imag (const int d) { return 0; }
103  inline unsigned imag (const unsigned d) { return 0; }
104  inline float imag (const float d) { return 0.0f; }
105  inline double imag (const double d) { return 0.0; }
106  inline long double imag (const long double d) { return 0.0; }
107 
108  inline int norm (const int arg) {return arg;}
109  inline unsigned norm (const unsigned arg) {return arg;}
110  inline long norm (const long arg) {return arg;}
111  inline short norm (const short arg) {return arg;}
112  inline char norm (const char arg) {return arg;}
113  inline float norm (const float arg) {return arg;}
114  inline double norm (const double arg) {return arg;}
115  inline long double norm (const long double arg) {return arg;}
116 }//::std
117 #endif //__cplusplus <= 199711L (<c++11)
118 
119 #if __cplusplus <= 199711L //if < C++11
120 namespace slip
121 {
122  inline int conj (const int arg) {return arg;}
123  inline unsigned conj (const unsigned arg) {return arg;}
124  inline long conj (const long arg) {return arg;}
125  inline short conj (const short arg) {return arg;}
126  inline char conj (const char arg) {return arg;}
127  inline float conj (const float arg) {return arg;}
128  inline double conj (const double arg) {return arg;}
129  inline long double conj (const long double arg) {return arg;}
130  template <typename T>
131  inline std::complex<T> conj(const std::complex<T>& arg) {return std::conj(arg);}
132 
133 }//::slip
134 #else //if > c++11
135 namespace slip
136 {
137  inline int conj (const int arg) {return std::real(std::conj(arg));}
138  inline unsigned conj (const unsigned arg) {return std::real(std::conj(arg));}
139  inline long conj (const long arg) {return std::real(std::conj(arg));}
140  inline short conj (const short arg) {return std::real(std::conj(arg));}
141  inline char conj (const char arg) {return std::real(std::conj(arg));}
142  inline float conj (const float arg) {return std::real(std::conj(arg));}
143  inline double conj (const double arg) {return std::real(std::conj(arg));}
144  inline long double conj (const long double arg) {return std::real(std::conj(arg));}
145  template <typename T>
146  inline std::complex<T> conj(const std::complex<T>& arg) {return std::conj(arg);}
147 }//::slip
148 #endif //__cplusplus <= 199711L (<c++11)
149 
150 
151 
152 
153 namespace std
154 {
155 
156 
158  template<class _Tp>
159  struct less<std::complex<_Tp> >
160  {
161  bool
162  operator()(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y) const
163  { return std::norm(__x) < std::norm(__y); }
164  };
165 
167  template<class _Tp>
168  struct greater<std::complex<_Tp> >
169  {
170  bool
171  operator()(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y) const
172  { return std::norm(__x) > std::norm(__y); }
173  };
174 
175 }
176 
177 
178 #endif /* SLIP_COMPLEX_CAST_HPP */
bool operator()(const std::complex< _Tp > &__x, const std::complex< _Tp > &__y) const
std::complex< T > conj(const std::complex< T > &arg)
bool operator()(const std::complex< _Tp > &__x, const std::complex< _Tp > &__y) const
int conj(const int arg)