ivl 679
ivl/details/core/math/constant.hpp
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>.
00002    A C++ template library extending syntax towards mathematical notation.
00003 
00004    Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr>
00005    Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr>
00006 
00007    ivl is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU Lesser General Public License 
00009    version 3 as published by the Free Software Foundation.
00010 
00011    Alternatively, you can redistribute it and/or modify it under the terms 
00012    of the GNU General Public License version 2 as published by the Free 
00013    Software Foundation.
00014 
00015    ivl is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00018    See the GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License 
00021    and a copy of the GNU Lesser General Public License along 
00022    with ivl. If not, see <http://www.gnu.org/licenses/>. */
00023 
00024 #ifndef IVL_CORE_DETAILS_MATH_BASIC_HPP
00025 #define IVL_CORE_DETAILS_MATH_BASIC_HPP
00026 
00027 namespace ivl {
00028 
00029 /*
00031 extern const double epsilon;
00032 
00034 extern const double infty;
00035 
00037 extern const double pi;
00038 
00040 extern const std::complex<double> i;
00041 extern const std::complex<double> j;
00042 */
00043 
00045 static const double pi = 3.14159265358979323846264338327950288419716939937510;
00046 
00048 static const double infty = std::numeric_limits<double>::infinity();
00049 
00051 static const double epsilon = std::numeric_limits<double>::epsilon();
00052 
00053 namespace math {
00054 
00055 namespace math_details {
00056 
00057 inline double get_infty() { return infty; } // suppress unused warning
00058 
00059 }
00060 
00062 static const std::complex<double> i(0, 1);
00063 
00065 static const std::complex<double> j(0, 1);
00066 
00067 };
00068 
00069 
00070 inline double eps(double p = 1.0)
00071 {
00072         return pow(epsilon, p);
00073 }
00074 
00076 template<class T>
00077 inline T inf()
00078 {
00079         return std::numeric_limits<typename types::to_real<T>::type>::infinity();
00080 }
00081 
00083 template<class T>
00084 inline T nan()
00085 {
00086         return std::numeric_limits<typename types::to_real<T>::type>::quiet_NaN();
00087 }
00088 
00090 template<class T>
00091 inline T NaN()
00092 {
00093         return std::numeric_limits<typename types::to_real<T>::type>::quiet_NaN();
00094 }
00095 
00096 } /* namespace ivl */
00097 
00098 #endif // IVL_CORE_DETAILS_MATH_BASIC_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations