Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
constants.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2005-08-16
7 
8  Copyright (C) 2009 Université de Grenoble 1
9  Copyright (C) 2005,2006 EPFL
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #ifndef __Constants_H
31 #define __Constants_H 1
32 
33 #include <cmath>
34 #include <feel/feelcore/traits.hpp>
35 
36 namespace Feel
37 {
44 namespace math
45 {
57 template <typename Tag, typename Rep = double>
58 struct Constant
59 {
60  Constant() {} // Returns the value of the constant.
61  operator Rep() const; // Fully specialized for each Rep/Tag pair.
62 };
63 
64 
65 struct pi_tag {};
66 namespace float_constants
67 {
68 Constant<pi_tag, float> const pi;
69 }
70 namespace double_constants
71 {
72 Constant<pi_tag, double> const pi;
73 }
74 namespace long_double_constants
75 {
76 Constant<pi_tag, long double> const pi;
77 }
78 #if defined(FEELPP_HAS_QD_REAL)
79 namespace dd_real_constants
80 {
81 Constant<pi_tag, dd_real> const pi;
82 }
83 namespace qd_real_constants
84 {
85 Constant<pi_tag, qd_real> const pi;
86 }
87 #endif /*FEELPP_HAS_QD_REAL*/
88 template<> inline Constant<pi_tag, long double>::operator long double() const
89 {
90  return 3.141592653589793238462643383279502884197L;
91 }
92 template<> inline Constant<pi_tag, double>::operator double() const
93 {
94  return 3.141592653589793238462643383279502884197;
95 }
96 template<> inline Constant<pi_tag, float>::operator float() const
97 {
98  return 3.141592653589793238462643383279502884197F;
99 }
100 #if defined(FEELPP_HAS_QD_REAL)
101 template<> inline Constant<pi_tag, dd_real>::operator dd_real() const
102 {
103  return dd_real::_pi;
104 }
105 template<> inline Constant<pi_tag, qd_real>::operator qd_real() const
106 {
107  return qd_real::_pi;
108 }
109 #endif /*FEELPP_HAS_QD_REAL*/
110 } // namespace math
111 } // namespace Feel
112 #endif /* __Constants_H */

Generated on Fri Oct 25 2013 14:24:04 for Feel++ by doxygen 1.8.4