30 #ifndef FEELPP_UBLAS_TRAITS_HPP
31 #define FEELPP_UBLAS_TRAITS_HPP 1
33 #if !defined( FEELPP_TRAITS_HPP)
34 #error feel/feelcore/ublas_traits.hpp must not be used directly, use feel/feelcore/traits.hpp instead
37 #include <boost/numeric/ublas/traits.hpp>
46 #if defined( FEELPP_HAS_MPFR )
48 struct type_traits<Feel::mp_type>
50 typedef type_traits<Feel::mp_type> self_type;
51 typedef Feel::mp_type value_type;
52 typedef const value_type &const_reference;
53 typedef value_type &reference;
54 typedef value_type real_type;
55 typedef Feel::mp_type precision_type;
57 static const unsigned plus_complexity = 1;
58 static const unsigned multiplies_complexity = 1;
62 real_type real ( const_reference t )
68 real_type imag ( const_reference )
74 value_type conj ( const_reference t )
81 real_type abs ( const_reference t )
88 value_type sqrt ( const_reference t )
95 value_type type_sqrt ( const_reference t )
102 real_type norm_1 ( const_reference t )
104 return self_type::abs ( t );
108 real_type norm_2 ( const_reference t )
110 return self_type::abs ( t );
114 real_type norm_inf ( const_reference t )
116 return self_type::abs ( t );
121 bool equals ( const_reference t1, const_reference t2 )
123 return self_type::norm_inf ( t1 - t2 ) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
124 ( std::max ) ( ( std::max ) ( self_type::norm_inf ( t1 ),
125 self_type::norm_inf ( t2 ) ),
126 BOOST_UBLAS_TYPE_CHECK_MIN );
129 #endif // FEELPP_HAS_MPFR
131 #if defined ( FEELPP_HAS_QD_REAL )
133 struct type_traits<qd_real>
135 typedef type_traits<qd_real> self_type;
136 typedef qd_real value_type;
137 typedef const value_type &const_reference;
138 typedef value_type &reference;
139 typedef value_type real_type;
140 typedef qd_real precision_type;
142 static const unsigned plus_complexity = 1;
143 static const unsigned multiplies_complexity = 1;
147 real_type real ( const_reference t )
153 real_type imag ( const_reference )
159 value_type conj ( const_reference t )
166 real_type abs ( const_reference t )
173 value_type sqrt ( const_reference t )
180 value_type type_sqrt ( const_reference t )
187 real_type norm_1 ( const_reference t )
189 return self_type::abs ( t );
193 real_type norm_2 ( const_reference t )
195 return self_type::abs ( t );
199 real_type norm_inf ( const_reference t )
201 return self_type::abs ( t );
206 bool equals ( const_reference t1, const_reference t2 )
208 return self_type::norm_inf ( t1 - t2 ) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
209 ( std::max ) ( ( std::max ) ( self_type::norm_inf ( t1 ),
210 self_type::norm_inf ( t2 ) ),
211 BOOST_UBLAS_TYPE_CHECK_MIN );
215 #if defined ( FEELPP_HAS_DD_REAL )
217 struct type_traits<dd_real>
219 typedef type_traits<dd_real> self_type;
220 typedef dd_real value_type;
221 typedef const value_type &const_reference;
222 typedef value_type &reference;
223 typedef value_type real_type;
224 typedef dd_real precision_type;
226 static const unsigned plus_complexity = 1;
227 static const unsigned multiplies_complexity = 1;
231 real_type real ( const_reference t )
237 real_type imag ( const_reference )
243 value_type conj ( const_reference t )
250 real_type abs ( const_reference t )
256 value_type sqrt ( const_reference t )
263 value_type type_sqrt ( const_reference t )
270 real_type norm_1 ( const_reference t )
272 return self_type::abs ( t );
276 real_type norm_2 ( const_reference t )
278 return self_type::abs ( t );
282 real_type norm_inf ( const_reference t )
284 return self_type::abs ( t );
289 bool equals ( const_reference t1, const_reference t2 )
291 return self_type::norm_inf ( t1 - t2 ) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
292 ( std::max ) ( ( std::max ) ( self_type::norm_inf ( t1 ),
293 self_type::norm_inf ( t2 ) ),
294 BOOST_UBLAS_TYPE_CHECK_MIN );
299 #if defined ( FEELPP_HAS_MP_REAL )
301 struct type_traits<mp_real>
303 typedef type_traits<mp_real> self_type;
304 typedef mp_real value_type;
305 typedef const value_type &const_reference;
306 typedef value_type &reference;
307 typedef value_type real_type;
308 typedef double precision_type;
310 static const unsigned plus_complexity = 1;
311 static const unsigned multiplies_complexity = 1;
315 real_type real ( const_reference t )
321 real_type imag ( const_reference )
327 value_type conj ( const_reference t )
334 real_type abs ( const_reference t )
340 value_type sqrt ( const_reference t )
347 value_type type_sqrt ( const_reference t )
354 real_type norm_1 ( const_reference t )
356 return self_type::abs ( t );
360 real_type norm_2 ( const_reference t )
362 return self_type::abs ( t );
366 real_type norm_inf ( const_reference t )
368 return self_type::abs ( t );
373 bool equals ( const_reference t1, const_reference t2 )
375 return self_type::norm_inf ( t1 - t2 ) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
376 ( std::max ) ( ( std::max ) ( self_type::norm_inf ( t1 ),
377 self_type::norm_inf ( t2 ) ),
378 BOOST_UBLAS_TYPE_CHECK_MIN );