acros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/cstdio * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_CSTDIO #define _GLIBCXX_TR1_CSTDIO 1 #pragma GCC system_header #if defined(_GLIBCXX_INCLUDE_AS_CXX0X) # error TR1 header cannot be included from C++0x header #endif #include #if defined(_GLIBCXX_INCLUDE_AS_TR1) # include #else # define _GLIBCXX_INCLUDE_AS_TR1 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { # define _GLIBCXX_END_NAMESPACE_TR1 } # define _GLIBCXX_TR1 tr1:: # include # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_TR1 #endif #endif // _GLIBCXX_TR1_CSTDIO // Special functions -*- C++ -*- // Copyright (C) 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/special_function_util.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ // // ISO C++ 14882 TR1: 5.2 Special functions // // Written by Edward Smith-Rowland based on numerous mathematics books. #ifndef _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H #define _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H 1 namespace std { namespace tr1 { namespace __detail { /// A class to encapsulate type dependent floating point /// constants. Not everything will be able to be expressed as /// type logic. template struct __floating_point_constant { static const _Tp __value; }; /// A structure for numeric constants. template struct __numeric_constants { /// Constant @f$ \pi @f$. static _Tp __pi() throw() { return static_cast<_Tp>(3.1415926535897932384626433832795029L); } /// Constant @f$ \pi / 2 @f$. static _Tp __pi_2() throw() { return static_cast<_Tp>(1.5707963267948966192313216916397514L); } /// Constant @f$ \pi / 3 @f$. static _Tp __pi_3() throw() { return static_cast<_Tp>(1.0471975511965977461542144610931676L); } /// Constant @f$ \pi / 4 @f$. static _Tp __pi_4() throw() { return static_cast<_Tp>(0.7853981633974483096156608458198757L); } /// Constant @f$ 1 / \pi @f$. static _Tp __1_pi() throw() { return static_cast<_Tp>(0.3183098861837906715377675267450287L); } /// Constant @f$ 2 / \sqrt(\pi) @f$. static _Tp __2_sqrtpi() throw() { return static_cast<_Tp>(1.1283791670955125738961589031215452L); } /// Constant @f$ \sqrt(2) @f$. static _Tp __sqrt2() throw() { return static_cast<_Tp>(1.4142135623730950488016887242096981L); } /// Constant @f$ \sqrt(3) @f$. static _Tp __sqrt3() throw() { return static_cast<_Tp>(1.7320508075688772935274463415058723L); } /// Constant @f$ \sqrt(\pi/2) @f$. static _Tp __sqrtpio2() throw() { return static_cast<_Tp>(1.2533141373155002512078826424055226L); } /// Constant @f$ 1 / sqrt(2) @f$. static _Tp __sqrt1_2() throw() { return static_cast<_Tp>(0.7071067811865475244008443621048490L); } /// Constant @f$ \log(\pi) @f$. static _Tp __lnpi() throw() { return static_cast<_Tp>(1.1447298858494001741434273513530587L); } /// Constant Euler's constant @f$ \gamma_E @f$. static _Tp __gamma_e() throw() { return static_cast<_Tp>(0.5772156649015328606065120900824024L); } /// Constant Euler-Mascheroni @f$ e @f$ static _Tp __euler() throw() { return static_cast<_Tp>(2.7182818284590452353602874713526625L); } }; #if _GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC /// This is a wrapper for the isnan function. Otherwise, for NaN, /// all comparisons result in false. If/when we build a std::isnan /// out of intrinsics, this will disappear completely in favor of /// std::isnan. template inline bool __isnan(const _Tp __x) { return std::isnan(__x); } #else template inline bool __isnan(const _Tp __x) { return __builtin_isnan(__x); } template<> inline bool __isnan(const float __x) { return __builtin_isnanf(__x); } template<> inline bool __isnan(const long double __x) { return __builtin_isnanl(__x); } #endif } // namespace __detail } } #endif // _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H // TR1 math.h -*- C++ -*- // Copyright (C) 2006, 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/math.h * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_MATH_H #define _GLIBCXX_TR1_MATH_H 1 #include #if _GLIBCXX_USE_C99_MATH_TR1 using std::tr1::acos; using std::tr1::acosh; using std::tr1::asin; using std::tr1::asinh; using std::tr1::atan; using std::tr1::atan2; using std::tr1::atanh; using std::tr1::cbrt; using std::tr1::ceil; using std::tr1::copysign; using std::tr1::cos; using std::tr1::cosh; using std::tr1::erf; using std::tr1::erfc; using std::tr1::exp; using std::tr1::exp2; using std::tr1::expm1; using std::tr1::fabs; using std::tr1::fdim; using std::tr1::floor; using std::tr1::fma; using std::tr1::fmax; using std::tr1::fmin; using std::tr1::fmod; using std::tr1::frexp; using std::tr1::hypot; using std::tr1::ilogb; using std::tr1::ldexp; using std::tr1::lgamma; using std::tr1::llrint; using std::tr1::llround; using std::tr1::log; using std::tr1::log10; using std::tr1::log1p; using std::tr1::log2; using std::tr1::logb; using std::tr1::lrint; using std::tr1::lround; using std::tr1::nearbyint; using std::tr1::nextafter; using std::tr1::nexttoward; using std::tr1::pow; using std::tr1::remainder; using std::tr1::remquo; using std::tr1::rint; using std::tr1::round; using std::tr1::scalbln; using std::tr1::scalbn; using std::tr1::sin; using std::tr1::sinh; using std::tr1::sqrt; using std::tr1::tan; using std::tr1::tanh; using std::tr1::tgamma; using std::tr1::trunc; #endif using std::tr1::assoc_laguerref; using std::tr1::assoc_laguerre; using std::tr1::assoc_laguerrel; using std::tr1::assoc_legendref; using std::tr1::assoc_legendre; using std::tr1::assoc_legendrel; using std::tr1::betaf; using std::tr1::beta; using std::tr1::betal; using std::tr1::comp_ellint_1f; using std::tr1::comp_ellint_1; using std::tr1::comp_ellint_1l; using std::tr1::comp_ellint_2f; using std::tr1::comp_ellint_2; using std::tr1::comp_ellint_2l; using std::tr1::comp_ellint_3f; using std::tr1::comp_ellint_3; using std::tr1::comp_ellint_3l; using std::tr1::conf_hypergf; using std::tr1::conf_hyperg; using std::tr1::conf_hypergl; using std::tr1::cyl_bessel_if; using std::tr1::cyl_bessel_i; using std::tr1::cyl_bessel_il; using std::tr1::cyl_bessel_jf; using std::tr1::cyl_bessel_j; using std::tr1::cyl_bessel_jl; using std::tr1::cyl_bessel_kf; using std::tr1::cyl_bessel_k; using std::tr1::cyl_bessel_kl; using std::tr1::cyl_neumannf; using std::tr1::cyl_neumann; using std::tr1::cyl_neumannl; using std::tr1::ellint_1f; using std::tr1::ellint_1; using std::tr1::ellint_1l; using std::tr1::ellint_2f; using std::tr1::ellint_2; using std::tr1::ellint_2l; using std::tr1::ellint_3f; using std::tr1::ellint_3; using std::tr1::ellint_3l; using std::tr1::expintf; using std::tr1::expint; using std::tr1::expintl; using std::tr1::hermitef; using std::tr1::hermite; using std::tr1::hermitel; using std::tr1::hypergf; using std::tr1::hyperg; using std::tr1::hypergl; using std::tr1::laguerref; using std::tr1::laguerre; using std::tr1::laguerrel; using std::tr1::legendref; using std::tr1::legendre; using std::tr1::legendrel; using std::tr1::riemann_zetaf; using std::tr1::riemann_zeta; using std::tr1::riemann_zetal; using std::tr1::sph_besself; using std::tr1::sph_bessel; using std::tr1::sph_bessell; using std::tr1::sph_legendref; using std::tr1::sph_legendre; using std::tr1::sph_legendrel; using std::tr1::sph_neumannf; using std::tr1::sph_neumann; using std::tr1::sph_neumannl; #endif // _GLIBCXX_TR1_MATH_H // TR1 wchar.h -*- C++ -*- // Copyright (C) 2006, 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/wchar.h * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_WCHAR_H #define _GLIBCXX_TR1_WCHAR_H 1 #include #endif // _GLIBCXX_TR1_WCHAR_H // TR1 cfenv -*- C++ -*- // Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/cfenv * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_CFENV #define _GLIBCXX_TR1_CFENV 1 #pragma GCC system_header #include #if _GLIBCXX_HAVE_FENV_H # include #endif #if defined(_GLIBCXX_INCLUDE_AS_TR1) # include #else # define _GLIBCXX_INCLUDE_AS_TR1 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { # define _GLIBCXX_END_NAMESPACE_TR1 } # define _GLIBCXX_TR1 tr1:: # include # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_TR1 #endif #endif // _GLIBCXX_TR1_CFENV // TR1 cstdbool -*- C++ -*- // Copyright (C) 2006, 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/cstdbool * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_CSTDBOOL #define _GLIBCXX_TR1_CSTDBOOL 1 #pragma GCC system_header #include #if _GLIBCXX_HAVE_STDBOOL_H #include #endif #endif // _GLIBCXX_TR1_CSTDBOOL // TR1 fenv.h -*- C++ -*- // Copyright (C) 2006 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/fenv.h * This is a TR1 C++ Library header. */ #ifndef _TR1_FENV_H #define _TR1_FENV_H 1 #include #endif // TR1 stdio.h -*- C++ -*- // Copyright (C) 2006 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/stdio.h * This is a TR1 C++ Library header. */ #ifndef _TR1_STDIO_H #define _TR1_STDIO_H 1 #include #endif // TR1 limits.h -*- C++ -*- // Copyright (C) 2006 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/limits.h * This is a TR1 C++ Library header. */ #ifndef _TR1_LIMITS_H #define _TR1_LIMITS_H 1 #include #endif // class template tuple -*- C++ -*- // Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/tuple * This is a TR1 C++ Library header. */ // Chris Jefferson // Variadic Templates support by Douglas Gregor #ifndef _GLIBCXX_TR1_TUPLE #define _GLIBCXX_TR1_TUPLE 1 #pragma GCC system_header #include namespace std { namespace tr1 { // Adds a const reference to a non-reference type. template struct __add_c_ref { typedef const _Tp& type; }; template struct __add_c_ref<_Tp&> { typedef _Tp& type; }; // Adds a reference to a non-reference type. template struct __add_ref { typedef _Tp& type; }; template struct __add_ref<_Tp&> { typedef _Tp& type; }; /** * Contains the actual implementation of the @c tuple template, stored * as a recursive inheritance hierarchy from the first element (most * derived class) to the last (least derived class). The @c Idx * parameter gives the 0-based index of the element stored at this * point in the hierarchy; we use it to implement a constant-time * get() operation. */ template struct _Tuple_impl; /** * Zero-element tuple implementation. This is the basis case for the * inheritance recursion. */ template struct _Tuple_impl<_Idx> { }; /** * Recursive tuple implementation. Here we store the @c Head element * and derive from a @c Tuple_impl containing the remaining elements * (which contains the @c Tail). */ template struct _Tuple_impl<_Idx, _Head, _Tail...> : public _Tuple_impl<_Idx + 1, _Tail...> { typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited; _Head _M_head; _Inherited& _M_tail() { return *this; } const _Inherited& _M_tail() const { return *this; } _Tuple_impl() : _Inherited(), _M_head() { } explicit _Tuple_impl(typename __add_c_ref<_Head>::type __head, typename __add_c_ref<_Tail>::type... __tail) : _Inherited(__tail...), _M_head(__head) { } template _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in) : _Inherited(__in._M_tail()), _M_head(__in._M_head) { } _Tuple_impl(const _Tuple_impl& __in) : _Inherited(__in._M_tail()), _M_head(__in._M_head) { } template _Tuple_impl& operator=(const _Tuple_impl<_Idx, _UElements...>& __in) { _M_head = __in._M_head; _M_tail() = __in._M_tail(); return *this; } _Tuple_impl& operator=(const _Tuple_impl& __in) { _M_head = __in._M_head; _M_tail() = __in._M_tail(); return *this; } }; template class tuple : public _Tuple_impl<0, _Elements...> { typedef _Tuple_impl<0, _Elements...> _Inherited; public: tuple() : _Inherited() { } explicit tuple(typename __add_c_ref<_Elements>::type... __elements) : _Inherited(__elements...) { } template tuple(const tuple<_UElements...>& __in) : _Inherited(__in) { } tuple(const tuple& __in) : _Inherited(__in) { } template tuple& operator=(const tuple<_UElements...>& __in) { static_cast<_Inherited&>(*this) = __in; return *this; } tuple& operator=(const tuple& __in) { static_cast<_Inherited&>(*this) = __in; return *this; } }; template<> class tuple<> { }; // 2-element tuple, with construction and assignment from a pair. template class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2> { typedef _Tuple_impl<0, _T1, _T2> _Inherited; public: tuple() : _Inherited() { } explicit tuple(typename __add_c_ref<_T1>::type __a1, typename __add_c_ref<_T2>::type __a2) : _Inherited(__a1, __a2) { } template tuple(const tuple<_U1, _U2>& __in) : _Inherited(__in) { } tuple(const tuple& __in) : _Inherited(__in) { } template tuple(const pair<_U1, _U2>& __in) : _Inherited(_Tuple_impl<0, typename __add_c_ref<_U1>::type, typename __add_c_ref<_U2>::type>(__in.first, __in.second)) { } template tuple& operator=(const tuple<_U1, _U2>& __in) { static_cast<_Inherited&>(*this) = __in; return *this; } tuple& operator=(const tuple& __in) { static_cast<_Inherited&>(*this) = __in; return *this; } template tuple& operator=(const pair<_U1, _U2>& __in) { this->_M_head = __in.first; this->_M_tail()._M_head = __in.second; return *this; } }; /// Gives the type of the ith element of a given tuple type. template struct tuple_element; /** * Recursive case for tuple_element: strip off the first element in * the tuple and retrieve the (i-1)th element of the remaining tuple. */ template struct tuple_element<__i, tuple<_Head, _Tail...> > : tuple_element<__i - 1, tuple<_Tail...> > { }; /** * Basis case for tuple_element: The first element is the one we're seeking. */ template struct tuple_element<0, tuple<_Head, _Tail...> > { typedef _Head type; }; /// Finds the size of a given tuple type. template struct tuple_size; /// class tuple_size template struct tuple_size > { static const int value = sizeof...(_Elements); }; template const int tuple_size >::value; template inline typename __add_ref<_Head>::type __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) { return __t._M_head; } template inline typename __add_c_ref<_Head>::type __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) { return __t._M_head; } // Return a reference (const reference) to the ith element of a tuple. // Any const or non-const ref elements are returned with their original type. template inline typename __add_ref< typename tuple_element<__i, tuple<_Elements...> >::type >::type get(tuple<_Elements...>& __t) { return __get_helper<__i>(__t); } template inline typename __add_c_ref< typename tuple_element<__i, tuple<_Elements...> >::type >::type get(const tuple<_Elements...>& __t) { return __get_helper<__i>(__t); } // This class helps construct the various comparison operations on tuples template struct __tuple_compare; template struct __tuple_compare<0, __i, __j, _Tp, _Up> { static bool __eq(const _Tp& __t, const _Up& __u) { return (get<__i>(__t) == get<__i>(__u) && __tuple_compare<0, __i+1, __j, _Tp, _Up>::__eq(__t, __u)); } static bool __less(const _Tp& __t, const _Up& __u) { return ((get<__i>(__t) < get<__i>(__u)) || !(get<__i>(__u) < get<__i>(__t)) && __tuple_compare<0, __i+1, __j, _Tp, _Up>::__less(__t, __u)); } }; template struct __tuple_compare<0, __i, __i, _Tp, _Up> { static bool __eq(const _Tp&, const _Up&) { return true; } static bool __less(const _Tp&, const _Up&) { return false; } }; template bool operator==(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { typedef tuple<_TElements...> _Tp; typedef tuple<_UElements...> _Up; return (__tuple_compare::value - tuple_size<_Up>::value, 0, tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u)); } template bool operator<(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { typedef tuple<_TElements...> _Tp; typedef tuple<_UElements...> _Up; return (__tuple_compare::value - tuple_size<_Up>::value, 0, tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u)); } template inline bool operator!=(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return !(__t == __u); } template inline bool operator>(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return __u < __t; } template inline bool operator<=(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return !(__u < __t); } template inline bool operator>=(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u) { return !(__t < __u); } template class reference_wrapper; // Helper which adds a reference to a type when given a reference_wrapper template struct __strip_reference_wrapper { typedef _Tp __type; }; template struct __strip_reference_wrapper > { typedef _Tp& __type; }; template struct __strip_reference_wrapper > { typedef _Tp& __type; }; template inline tuple::__type...> make_tuple(_Elements... __args) { typedef tuple::__type...> __result_type; return __result_type(__args...); } template inline tuple<_Elements&...> tie(_Elements&... __args) { return tuple<_Elements&...>(__args...); } // A class (and instance) which can be used in 'tie' when an element // of a tuple is not required struct _Swallow_assign { template _Swallow_assign& operator=(const _Tp&) { return *this; } }; // TODO: Put this in some kind of shared file. na&-mespace { _Swallow_assign ignore; }; // anonymous namespace } } #endif // _GLIBCXX_TR1_TUPLE // random number generation -*- C++ -*- // Copyright (C) 2006, 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** * @file tr1/random * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_RANDOM #define _GLIBCXX_TR1_RANDOM 1 #pragma GCC system_header #if defined(_GLIBCXX_INCLUDE_AS_CXX0X) # error TR1 header cannot be included from C++0x header #endif #include #include #include #include #include #include #include #include #include #include #include #include #if defined(_GLIBCXX_INCLUDE_AS_TR1) # include #else # define _GLIBCXX_INCLUDE_AS_TR1 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { # define _GLIBCXX_END_NAMESPACE_TR1 } # define _GLIBCXX_TR1 tr1:: # include # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_TR1 #endif #endif // _GLIBCXX_TR1_RANDOM // TR1 cstdlib -*- C++ -*- // Copyright (C) 2006 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/cstdlib * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_CSTDLIB #define _GLIBCXX_TR1_CSTDLIB 1 #pragma GCC system_header #if defined(_GLIBCXX_INCLUDE_AS_CXX0X) # error TR1 header cannot be included from C++0x header #endif #include #if defined(_GLIBCXX_INCLUDE_AS_TR1) # include #else # define _GLIBCXX_INCLUDE_AS_TR1 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { # define _GLIBCXX_END_NAMESPACE_TR1 } # define _GLIBCXX_TR1 tr1:: # include # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_TR1 #endif #endif // _GLIBCXX_TR1_CSTDLIB // TR1 complex.h -*- C++ -*- // Copyright (C) 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/complex.h * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_COMPLEX_H #define _GLIBCXX_TR1_COMPLEX_H 1 #include #endif // _GLIBCXX_TR1_COMPLEX_H // TR1 unordered_set -*- C++ -*- // Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/unordered_set * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_UNORDERED_SET #define _GLIBCXX_TR1_UNORDERED_SET 1 #pragma GCC system_header #if defined(_GLIBCXX_INCLUDE_AS_CXX0X) # error TR1 header cannot be included from C++0x header #endif #include #include #include #include // equal_to, _Identity, _Select1st #include #include #include #include #if defined(_GLIBCXX_INCLUDE_AS_TR1) # include #else # define _GLIBCXX_INCLUDE_AS_TR1 # define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { # define _GLIBCXX_END_NAMESPACE_TR1 } # define _GLIBCXX_TR1 tr1:: # include # undef _GLIBCXX_TR1 # undef _GLIBCXX_END_NAMESPACE_TR1 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1 # undef _GLIBCXX_INCLUDE_AS_TR1 #endif #endif // _GLIBCXX_TR1_UNORDERED_SET // Special functions -*- C++ -*- // Copyright (C) 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/beta_function.tcc * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ // // ISO C++ 14882 TR1: 5.2 Special functions // // Written by Edward Smith-Rowland based on: // (1) Handbook of Mathematical Functions, // ed. Milton Abramowitz and Irene A. Stegun, // Dover Publications, // Section 6, pp. 253-266 // (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl // (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, // W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), // 2nd ed, pp. 213-216 // (4) Gamma, Exploring Euler's Constant, Julian Havil, // Princeton, 2003. #ifndef _GLIBCXX_TR1_BETA_FUNCTION_TCC #define _GLIBCXX_TR1_BETA_FUNCTION_TCC 1 namespace std { namespace tr1 { // [5.2] Special functions // Implementation-space details. namespace __detail { /** * @brief Return the beta function: \f$B(x,y)\f$. * * The beta function is defined by * @f[ * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} * @f] * * @param __x The first argument of the beta function. * @param __y The second argument of the beta function. * @return The beta function. */ template _Tp __beta_gamma(_Tp __x, _Tp __y) { _Tp __bet; #if _GLIBCXX_USE_C99_MATH_TR1 if (__x > __y) { __bet = std::tr1::tgamma(__x) / std::tr1::tgamma(__x + __y); __bet *= std::tr1::tgamma(__y); } else { __bet = std::tr1::tgamma(__y) / std::tr1::tgamma(__x + __y); __bet *= std::tr1::tgamma(__x); } #else if (__x > __y) { __bet = __gamma(__x) / __gamma(__x + __y); __bet *= __gamma(__y); } else { __bet = __gamma(__y) / __gamma(__x + __y); __bet *= __gamma(__x); } #endif return __bet; } /** * @brief Return the beta function \f$B(x,y)\f$ using * the log gamma functions. * * The beta function is defined by * @f[ * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} * @f] * * @param __x The first argument of the beta function. * @param __y The second argument of the beta function. * @return The beta function. */ template _Tp __beta_lgamma(_Tp __x, _Tp __y) { #if _GLIBCXX_USE_C99_MATH_TR1 _Tp __bet = std::tr1::lgamma(__x) + std::tr1::lgamma(__y) - std::tr1::lgamma(__x + __y); #else _Tp __bet = __log_gamma(__x) + __log_gamma(__y) - __log_gamma(__x + __y); #endif __bet = std::exp(__bet); return __bet; } /** * @brief Return the beta function \f$B(x,y)\f$ using * the product form. * * The beta function is defined by * @f[ * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} * @f] * * @param __x The first argument of the beta function. * @param __y The second argument of the beta function. * @return The beta function. */ template _Tp __beta_product(_Tp __x, _Tp __y) { _Tp __bet = (__x + __y) / (__x * __y); unsigned int __max_iter = 1000000; for (unsigned int __k = 1; __k < __max_iter; ++__k) { _Tp __term = (_Tp(1) + (__x + __y) / __k) / ((_Tp(1) + __x / __k) * (_Tp(1) + __y / __k)); __bet *= __term; } return __bet; } /** * @brief Return the beta function \f$ B(x,y) \f$. * * The beta function is defined by * @f[ * B(x,y) = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} * @f] * * @param __x The first argument of the beta function. * @param __y The second argument of the beta function. * @return The beta function. */ template inline _Tp __beta(_Tp __x, _Tp __y) { if (__isnan(__x) || __isnan(__y)) return std::numeric_limits<_Tp>::quiet_NaN(); else return __beta_lgamma(__x, __y); } } // namespace std::tr1::__detail } } #endif // __GLIBCXX_TR1_BETA_FUNCTION_TCC // TR1 ctime -*- C++ -*- // Copyright (C) 2006, 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/ctime * This is a TR1 C++ Library header. */ #ifndef _GLIBCXX_TR1_CTIME #define _GLIBCXX_TR1_CTIME 1 #include #endif // _GLIBCXX_TR1_CTIME // Special functions -*- C++ -*- // Copyright (C) 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1/exp_integral.tcc * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ // // ISO C++ 14882 TR1: 5.2 Special functions // // Written by Edward Smith-Rowland based on: // // (1) Handbook of Mathematical Functions, // Ed. by Milton Abramowitz and Irene A. Stegun, // Dover Publications, New-York, Section 5, pp. 228-251. // (2) The Gnu Scientific Library, http://www.gnu.org/software/gsl // (3) Numerical Recipes in C, by W. H. Press, S. A. Teukolsky, // W. T. Vetterling, B. P. Flannery, Cambridge University Press (1992), // 2nd ed, pp. 222-225. // #ifndef _GLIBCXX_TR1_EXP_INTEGRAL_TCC #define _GLIBCXX_TR1_EXP_INTEGRAL_TCC 1 #include "special_function_util.h" namespace std { namespace tr1 { // [5.2] Special functions // Implementation-space details. namespace __detail { /** * @brief Return the exponential integral @f$ E_1(x) @f$ * by series summation. This should be good * for @f$ x < 1 @f$. * * The exponential integral is given by * \f[ * E_1(x) = \int_{1}^{\infty} \frac{e^{-xt}}{t} dt * \f] * * @param __x The argument of the exponential integral function. * @return The exponential integral. */ template _Tp __expint_E1_series(const _Tp __x) { const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); _Tp __term = _Tp(1); _Tp __esum = _Tp(0); _Tp __osum = _Tp(0); const unsigned int __max_iter = 100; for (unsigned int __i = 1; __i < __max_iter; ++__i) { __term *= - __x / __i; if (std::abs(__term) < __eps) break; if (__term >= _Tp(0)) __esum += __term / __i; else __osum += __term / __i; } return - __esum - __osum - __numeric_constants<_Tp>::__gamma_e() - std::log(__x); } /** * @brief Return the exponential integral @f$ E_1(x) @f$ * by asymptotic expansion. * * The exponential integral is given by * \f[ * E_1(x) = \int_{1}^\infty \frac{e^{-xt}}{t} dt * \f] * * @param __x The argument of the exponential integral function. * @return The exponential integral. */ template _Tp __expint_E1_asymp(const _Tp __x) { _Tp __term = _Tp(1); _Tp __esum = _Tp(1); _Tp __osum = _Tp(0); const unsigned int __max_iter = 1000; for (unsigned int __i = 1; __i < __max_iter; ++__i) { _Tp __prev = __term; __term *= - __i / __x; if (std::abs(__term) > std::abs(__prev)) break; if (__term >= _Tp(0)) __esum += __term; else __osum += __term; } return std::exp(- __x) * (__esum + __osum) / __x; } /** * @brief Return the exponential integral @f$ E_n(x) @f$ * by series summation. * * The exponential integral is given by * \f[ * E_n(x) = \int_{1}^\infty \frac{e^{-xt}}{t^n} dt * \f] * * @param __n The order of the exponential integral function. * @param __x The argument of the exponential integral function. * @return The exponential integral. */ template _Tp __expint_En_series(const unsigned int __n, const _Tp __x) { const unsigned int __max_iter = 100; const _Tp __eps = std::numeric_limits<_Tp>::epsilon(); const int __nm1 = __n - 1; _Tp __ans = (__nm1 != 0 ? _Tp(1) / __nm1 : -std::log(__x) - __numeric_constants<_Tp>::__gamma_e()); _Tp __fact = _Tp(1); for (int __i = 1; __i <= __max_iter; ++__i) { __fact *= -__x / _Tp(__i); _Tp __del; if ( __i != __nm1 ) __del = -__fact / _Tp(__i - __nm1); else { _Tp __psi = -_TR1_GAMMA_TCC; for (int __ii = 1; __ii <= __nm1; ++__ii) __psi += _Tp(1) / _Tp(__ii); __del = __fact * (__psi - std::log(__x)); } __ans += __del; if (std::abs(__del) < __eps * std::abs(__ans)) return __ans; } std::__throw_runtime_error(__N("Series summation failed " "in __expint_En_series.")); } /** * @brief Return the exponential integral @f$ E_n(x) @f$ * by continued f