SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
linear_algebra_traits.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 
68 
69 #ifndef LINEAR_ALGEBRA_TRAITS_HPP
70 #define LINEAR_ALGEBRA_TRAITS_HPP
71 
72 #include <complex>
73 #include <iterator>
74 #include <limits>
75 
76 namespace slip
77 {
78 
79  struct __true_type { };
80  struct __false_type { };
81 
82  // Real types
83  //
84  template<typename _Tp>
85  struct __is_real
86  {
87  enum { __val = 0 };
88  typedef __false_type __type;
89  };
90 
91  template<>
92  struct __is_real<float>
93  {
94  enum { __val = 1 };
95  typedef __true_type __type;
96  };
97 
98  template<>
99  struct __is_real<double>
100  {
101  enum { __val = 1 };
102  typedef __true_type __type;
103  };
104 
105  template<>
106  struct __is_real<long double>
107  {
108  enum { __val = 1 };
109  typedef __true_type __type;
110  };
111 
127  template<typename T>
128  bool is_real(const T& val)
129  {
130  return slip::__is_real<T>::__val;
131  }
132 
133  // Complex types
134  //
135  template<typename _Tp>
136  struct __is_complex
137  {
138  enum { __val = 0 };
139  typedef __false_type __type;
140  };
141 
142  template<>
143  struct __is_complex<std::complex<float> >
144  {
145  enum { __val = 1 };
146  typedef __true_type __type;
147  };
148 
149  template<>
150  struct __is_complex<std::complex<double> >
151  {
152  enum { __val = 1 };
153  typedef __true_type __type;
154  };
155 
156  template<>
157  struct __is_complex<std::complex<long double> >
158  {
159  enum { __val = 1 };
160  typedef __true_type __type;
161  };
162 
178  template<typename T>
179  bool is_complex(const T& val)
180  {
181  return slip::__is_complex<T>::__val;
182  }
183 
184 
185  template<typename _Tp>
187  {
188  typedef _Tp value_type;
189  };
190 
191  template<typename _Tp>
192  struct lin_alg_traits<std::complex<_Tp> >
193  {
194  typedef typename std::complex<_Tp>::value_type value_type;
195  };
196 
210  template<typename T>
212  {
213  return std::numeric_limits<typename slip::lin_alg_traits<T>::value_type>::epsilon();
214  }
215 
216 
217 }//slip::
218 
219 #endif //LINEAR_ALGEBRA_TRAITS_HPP
bool is_complex(const T &val)
Test if an element is complex.
slip::lin_alg_traits< T >::value_type epsilon()
Returns the epsilon value of a real or a complex.
bool is_real(const T &val)
Test if an element is real.