summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/tr1/complex
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-31 23:37:56 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-05-31 23:37:56 +0000
commitc17b0a1c1233bfdedba163adff05feb0e2ffb357 (patch)
tree324bd2dd4033459fbf3d757935139d54703da05b /libstdc++-v3/include/tr1/complex
parent29e62146123eee0248b91ada23a0aa518093b604 (diff)
downloadgcc-c17b0a1c1233bfdedba163adff05feb0e2ffb357.tar.gz
2007-05-31 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/31426 * include/bits/c++config: Remove namespace association bits from tr1 to std. * include/ext/type_traits.h (__promote, __promote2, __promote3, __promote4): Add. * include/bits/hashtable.h: New. * include/bits/functional_hash.h: Likewise. * include/tr1/hashtable.h: Likewise. * include/tr1_impl/random: New. * include/tr1_impl/cinttypes: Likewise. * include/tr1_impl/cstdlib: Likewise. * include/tr1_impl/unordered_map: Likewise. * include/tr1_impl/cstdio: Likewise. * include/tr1_impl/boost_shared_ptr.h: Likewise. * include/tr1_impl/cctype: Likewise. * include/tr1_impl/random.tcc: Likewise. * include/tr1_impl/tuple: Likewise. * include/tr1_impl/functional_hash.h: Likewise. * include/tr1_impl/hashtable: Likewise. * include/tr1_impl/cmath: Likewise. * include/tr1_impl/type_traitsfwd.h: Likewise. * include/tr1_impl/hashtable_policy.h: Likewise. * include/tr1_impl/cfenv: Likewise. * include/tr1_impl/unordered_set: Likewise. * include/tr1_impl/functional: Likewise. * include/tr1_impl/utility: Likewise. * include/tr1_impl/complex: Likewise. * include/tr1_impl/type_traits: Likewise. * include/tr1_impl/cwchar: Likewise. * include/tr1_impl/cstdint: Likewise. * include/tr1_impl/regex: Likewise. * include/tr1_impl/array: Likewise. * include/tr1_impl/cwctype: Likewise. * include/tr1/type_traitsfwd.h: Remove. * include/tr1/boost_shared_ptr.h: Likewise. * include/tr1/common.h: Likewise. * include/tr1/hashtable: Likewise. * include/tr1/hashtable_policy.h: Likewise. * include/tr1/random.tcc: Likewise. * include/c_global/cinttypes: Include tr1_impl/cinttypes. * include/c_global/cstdlib: Likewise for cstdlib. * include/c_global/cstdio: Likewise for cstdio. * include/c_global/cctype: Likewise for cctype. * include/c_global/cmath: Likewise for cmath. * include/c_global/cfenv: Likewise for cfenv. * include/c_global/cwchar: Likewise for cwchar. * include/c_global/cstdint: Likewise for cstdint. * include/c_global/cwctype: Likewise for cwctype. * include/tr1/cinttypes: Likewise for cinttypes. * include/tr1/cstdlib: Likewise for cstdlib. * include/tr1/cstdio: Likewise for cstdio. * include/tr1/cctype: Likewise for cctype. * include/tr1/cmath: Likewise for cmath. * include/tr1/cfenv: Likewise for cfenv. * include/tr1/cwchar: Likewise for cwchar. * include/tr1/cstdint: Likewise for cstdint. * include/tr1/cwctype: Likewise for cwctype. * include/tr1/functional_hash.h: Likewise for functional_hash. * include/std/tuple: Include tr1_impl/tuple. * include/std/utility: Likewise for utility. * include/std/type_traits: Likewise for type_traits. (is_pod): Just forward to __is_pod. (has_trivial_default_constructor): Just forward to __has_trivial_constructor. (has_trivial_copy_constructor): Just forward to __has_trivial_copy. (has_trivial_assign): Just forward to __has_trivial_assign. (has_trivial_destructor): Just forward to __has_trivial_destructor. (has_nothrow_default_constructor): Just forward to __has_nothrow_constructor. (has_nothrow_copy_constructor): Just forward to __has_nothrow_copy. (has_nothrow_assign): Just forward to __has_nothrow_assign. (is_base_of): Just forward to __is_base_of. (is_signed, is_unsigned): Implement according to the C++0x specifications. * include/std/memory: Likewise for memory. * include/std/regex: Likewise for regex. * include/std/random: Likewise for random. * include/std/unordered_map: Likewise for unordered_map. * include/std/unordered_set: Likewise for unordered_set. * include/std/functional: Likewise for functional. * include/std/complex: Likewise for complex. * include/std/array: Likewise for array. * include/tr1/tuple: Likewise for tuple. * include/tr1/utility: Likewise for utility. * include/tr1/type_traits: Likewise for type_traits * include/tr1/memory: Likewise for memory. * include/tr1/regex: Likewise for regex. * include/tr1/random: Likewise for random. * include/tr1/unordered_map: Likewise for unordered_map. * include/tr1/unordered_set: Likewise for unordered_set. * include/tr1/functional: Likewise for functional. * include/tr1/complex: Likewise for complex. * include/tr1/array: Likewise for array. * include/c_global/ctgmath: Tweak. * include/c_global/cstdarg: Likewise. * include/c_global/ctime: Likewise. * include/c_global/climits: Likewise. * include/c_global/cfloat: Likewise. * include/c_global/ccomplex: Likewise. * include/c_global/cstdbool: Likewise. * include/tr1/poly_laguerre.tcc: Tweak, don't use _GLIBCXX_TR1. * include/tr1/riemann_zeta.tcc: Likewise. * include/tr1/beta_function.tcc: Likewise. * include/tr1/exp_integral.tcc: Likewise. * include/tr1/hypergeometric.tcc: Likewise. * include/tr1/modified_bessel_func.tcc: Likewise. * include/tr1/legendre_function.tcc: Likewise. * include/tr1/special_function_util.h: Likewise. * include/tr1/bessel_function.tcc: Likewise. * include/tr1/poly_hermite.tcc: Likewise. * include/tr1/ell_integral.tcc: Likewise. * include/tr1/gamma.tcc: Likewise. * include/tr1/stdlib.h: Likewise. * include/tr1/math.h: Likewise. * include/tr1/complex.h: Minor tweaks. * include/tr1/wctype.h: Likewise. * include/tr1/wchar.h: Likewise. * include/tr1/inttypes.h: Likewise. * include/tr1/tgmath.h: Likewise. * include/tr1/cstdbool: Likewise. * include/tr1/cfloat: Likewise. * include/tr1/ccomplex: Likewise. * include/tr1/ctime: Likewise. * include/tr1/climits: Likewise. * include/tr1/ctgmath: Likewise. * include/tr1/cstdarg: Likewise. * testsuite/tr1/headers.cc: Move... * testsuite/tr1/headers/all.cc: ... here. * testsuite/tr1/using_namespace_std_tr1.cc: Move... * testsuite/tr1/headers/c++200x/using_namespace_std_tr1.cc: ... here. * testsuite/tr1/headers/using_namespace_std_tr1.cc ... here. * testsuite/tr1/headers/c++200x/using_namespace_std_tr1.cc: New. * testsuite/20_util/tuple/requirements/explicit_instantiation.cc: Adjust namespace. * testsuite/20_util/has_nothrow_copy_constructor/value.cc: Adjust to the C++0x requirements. * testsuite/20_util/has_nothrow_default_constructor/value.cc: Likewise. * testsuite/20_util/has_trivial_copy_constructor/value.cc: Likewise. * testsuite/20_util/has_trivial_default_constructor/value.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust dg-error lines. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Un-xfail. * testsuite/20_util/is_signed/value.cc: New. * testsuite/20_util/is_signed/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_signed/requirements/explicit_instantiation.cc: Likewise. * testsuite/20_util/is_unsigned/value.cc: Likewise.. * testsuite/20_util/is_unsigned/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc: Likewise. * include/Makefile.am: Adjust. * include/Makefile.in: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125244 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/tr1/complex')
-rw-r--r--libstdc++-v3/include/tr1/complex385
1 files changed, 26 insertions, 359 deletions
diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex
index 666cae9e81d..ef21129ba4f 100644
--- a/libstdc++-v3/include/tr1/complex
+++ b/libstdc++-v3/include/tr1/complex
@@ -31,379 +31,46 @@
* This is a TR1 C++ Library header.
*/
-#ifndef _TR1_COMPLEX
-#define _TR1_COMPLEX 1
+#ifndef _GLIBCXX_TR1_COMPLEX
+#define _GLIBCXX_TR1_COMPLEX 1
-#include <complex>
-#include <tr1/common.h>
-
-// namespace std::tr1
-namespace std
-{
-_GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
-
- // Forward declarations.
- template<typename _Tp> std::complex<_Tp> acos(const std::complex<_Tp>&);
- template<typename _Tp> std::complex<_Tp> asin(const std::complex<_Tp>&);
- template<typename _Tp> std::complex<_Tp> atan(const std::complex<_Tp>&);
-
- template<typename _Tp> std::complex<_Tp> acosh(const std::complex<_Tp>&);
- template<typename _Tp> std::complex<_Tp> asinh(const std::complex<_Tp>&);
- template<typename _Tp> std::complex<_Tp> atanh(const std::complex<_Tp>&);
- template<typename _Tp> std::complex<_Tp> fabs(const std::complex<_Tp>&);
-
- /// @brief acos(__z) [8.1.2].
- // Effects: Behaves the same as C99 function cacos, defined
- // in subclause 7.3.5.1.
- template<typename _Tp>
- inline std::complex<_Tp>
- __complex_acos(const std::complex<_Tp>& __z)
- {
- const std::complex<_Tp> __t = std::_GLIBCXX_TR1::asin(__z);
- const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
- return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag());
- }
-
-#if _GLIBCXX_USE_C99_COMPLEX_TR1
- inline __complex__ float
- __complex_acos(__complex__ float __z)
- { return __builtin_cacosf(__z); }
-
- inline __complex__ double
- __complex_acos(__complex__ double __z)
- { return __builtin_cacos(__z); }
-
- inline __complex__ long double
- __complex_acos(const __complex__ long double& __z)
- { return __builtin_cacosl(__z); }
-
- template<typename _Tp>
- inline std::complex<_Tp>
- acos(const std::complex<_Tp>& __z)
- { return __complex_acos(__z.__rep()); }
-#else
- template<typename _Tp>
- inline std::complex<_Tp>
- acos(const std::complex<_Tp>& __z)
- { return __complex_acos(__z); }
-#endif
-
- /// @brief asin(__z) [8.1.3].
- // Effects: Behaves the same as C99 function casin, defined
- // in subclause 7.3.5.2.
- template<typename _Tp>
- inline std::complex<_Tp>
- __complex_asin(const std::complex<_Tp>& __z)
- {
- std::complex<_Tp> __t(-__z.imag(), __z.real());
- __t = std::_GLIBCXX_TR1::asinh(__t);
- return std::complex<_Tp>(__t.imag(), -__t.real());
- }
-
-#if _GLIBCXX_USE_C99_COMPLEX_TR1
- inline __complex__ float
- __complex_asin(__complex__ float __z)
- { return __builtin_casinf(__z); }
-
- inline __complex__ double
- __complex_asin(__complex__ double __z)
- { return __builtin_casin(__z); }
-
- inline __complex__ long double
- __complex_asin(const __complex__ long double& __z)
- { return __builtin_casinl(__z); }
-
- template<typename _Tp>
- inline std::complex<_Tp>
- asin(const std::complex<_Tp>& __z)
- { return __complex_asin(__z.__rep()); }
-#else
- template<typename _Tp>
- inline std::complex<_Tp>
- asin(const std::complex<_Tp>& __z)
- { return __complex_asin(__z); }
-#endif
-
- /// @brief atan(__z) [8.1.4].
- // Effects: Behaves the same as C99 function catan, defined
- // in subclause 7.3.5.3.
- template<typename _Tp>
- std::complex<_Tp>
- __complex_atan(const std::complex<_Tp>& __z)
- {
- const _Tp __r2 = __z.real() * __z.real();
- const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
-
- _Tp __num = __z.imag() + _Tp(1.0);
- _Tp __den = __z.imag() - _Tp(1.0);
-
- __num = __r2 + __num * __num;
- __den = __r2 + __den * __den;
-
- return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x),
- _Tp(0.25) * log(__num / __den));
- }
-
-#if _GLIBCXX_USE_C99_COMPLEX_TR1
- inline __complex__ float
- __complex_atan(__complex__ float __z)
- { return __builtin_catanf(__z); }
-
- inline __complex__ double
- __complex_atan(__complex__ double __z)
- { return __builtin_catan(__z); }
-
- inline __complex__ long double
- __complex_atan(const __complex__ long double& __z)
- { return __builtin_catanl(__z); }
-
- template<typename _Tp>
- inline std::complex<_Tp>
- atan(const std::complex<_Tp>& __z)
- { return __complex_atan(__z.__rep()); }
-#else
- template<typename _Tp>
- inline std::complex<_Tp>
- atan(const std::complex<_Tp>& __z)
- { return __complex_atan(__z); }
-#endif
-
- /// @brief acosh(__z) [8.1.5].
- // Effects: Behaves the same as C99 function cacosh, defined
- // in subclause 7.3.6.1.
- template<typename _Tp>
- std::complex<_Tp>
- __complex_acosh(const std::complex<_Tp>& __z)
- {
- std::complex<_Tp> __t((__z.real() - __z.imag())
- * (__z.real() + __z.imag()) - _Tp(1.0),
- _Tp(2.0) * __z.real() * __z.imag());
- __t = std::sqrt(__t);
-
- return std::log(__t + __z);
- }
-
-#if _GLIBCXX_USE_C99_COMPLEX_TR1
- inline __complex__ float
- __complex_acosh(__complex__ float __z)
- { return __builtin_cacoshf(__z); }
-
- inline __complex__ double
- __complex_acosh(__complex__ double __z)
- { return __builtin_cacosh(__z); }
-
- inline __complex__ long double
- __complex_acosh(const __complex__ long double& __z)
- { return __builtin_cacoshl(__z); }
-
- template<typename _Tp>
- inline std::complex<_Tp>
- acosh(const std::complex<_Tp>& __z)
- { return __complex_acosh(__z.__rep()); }
-#else
- template<typename _Tp>
- inline std::complex<_Tp>
- acosh(const std::complex<_Tp>& __z)
- { return __complex_acosh(__z); }
-#endif
-
- /// @brief asinh(__z) [8.1.6].
- // Effects: Behaves the same as C99 function casin, defined
- // in subclause 7.3.6.2.
- template<typename _Tp>
- std::complex<_Tp>
- __complex_asinh(const std::complex<_Tp>& __z)
- {
- std::complex<_Tp> __t((__z.real() - __z.imag())
- * (__z.real() + __z.imag()) + _Tp(1.0),
- _Tp(2.0) * __z.real() * __z.imag());
- __t = std::sqrt(__t);
+#pragma GCC system_header
- return std::log(__t + __z);
- }
-
-#if _GLIBCXX_USE_C99_COMPLEX_TR1
- inline __complex__ float
- __complex_asinh(__complex__ float __z)
- { return __builtin_casinhf(__z); }
-
- inline __complex__ double
- __complex_asinh(__complex__ double __z)
- { return __builtin_casinh(__z); }
-
- inline __complex__ long double
- __complex_asinh(const __complex__ long double& __z)
- { return __builtin_casinhl(__z); }
-
- template<typename _Tp>
- inline std::complex<_Tp>
- asinh(const std::complex<_Tp>& __z)
- { return __complex_asinh(__z.__rep()); }
-#else
- template<typename _Tp>
- inline std::complex<_Tp>
- asinh(const std::complex<_Tp>& __z)
- { return __complex_asinh(__z); }
+#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
+# error TR1 header cannot be included from C++0x header
#endif
- /// @brief atanh(__z) [8.1.7].
- // Effects: Behaves the same as C99 function catanh, defined
- // in subclause 7.3.6.3.
- template<typename _Tp>
- std::complex<_Tp>
- __complex_atanh(const std::complex<_Tp>& __z)
- {
- const _Tp __i2 = __z.imag() * __z.imag();
- const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
-
- _Tp __num = _Tp(1.0) + __z.real();
- _Tp __den = _Tp(1.0) - __z.real();
-
- __num = __i2 + __num * __num;
- __den = __i2 + __den * __den;
-
- return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)),
- _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
- }
-
-#if _GLIBCXX_USE_C99_COMPLEX_TR1
- inline __complex__ float
- __complex_atanh(__complex__ float __z)
- { return __builtin_catanhf(__z); }
-
- inline __complex__ double
- __complex_atanh(__complex__ double __z)
- { return __builtin_catanh(__z); }
-
- inline __complex__ long double
- __complex_atanh(const __complex__ long double& __z)
- { return __builtin_catanhl(__z); }
+#include <complex>
+#include <ext/type_traits.h>
+#include <tr1/type_traits>
- template<typename _Tp>
- inline std::complex<_Tp>
- atanh(const std::complex<_Tp>& __z)
- { return __complex_atanh(__z.__rep()); }
+#if defined(_GLIBCXX_INCLUDE_AS_TR1)
+# include <tr1_impl/complex>
#else
- template<typename _Tp>
- inline std::complex<_Tp>
- atanh(const std::complex<_Tp>& __z)
- { return __complex_atanh(__z); }
+# define _GLIBCXX_INCLUDE_AS_TR1
+# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
+# define _GLIBCXX_END_NAMESPACE_TR1 }
+# define _GLIBCXX_TR1 tr1::
+# include <tr1_impl/complex>
+# undef _GLIBCXX_TR1
+# undef _GLIBCXX_END_NAMESPACE_TR1
+# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
+# undef _GLIBCXX_INCLUDE_AS_TR1
#endif
- /// @brief fabs(__z) [8.1.8].
- // Effects: Behaves the same as C99 function cabs, defined
- // in subclause 7.3.8.1.
- template<typename _Tp>
- inline std::complex<_Tp>
- fabs(const std::complex<_Tp>& __z)
- { return std::abs(__z); }
-
-
- /// @brief Additional overloads [8.1.9].
- //
-
- // See common.h for the primary template.
- template<typename _Tp, typename _Up>
- struct __promote_2<std::complex<_Tp>, _Up>
- {
- public:
- typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
- };
-
- template<typename _Tp, typename _Up>
- struct __promote_2<_Tp, std::complex<_Up> >
- {
- public:
- typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
- };
-
- template<typename _Tp, typename _Up>
- struct __promote_2<std::complex<_Tp>, std::complex<_Up> >
- {
- public:
- typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
- };
-
-
+namespace std
+{
+namespace tr1
+{
using std::arg;
-
- template<typename _Tp>
- inline typename __promote<_Tp>::__type
- arg(_Tp __x)
- {
- typedef typename __promote<_Tp>::__type __type;
- return std::arg(std::complex<__type>(__x));
- }
-
using std::conj;
-
- template<typename _Tp>
- inline std::complex<typename __promote<_Tp>::__type>
- conj(_Tp __x)
- { return __x; }
-
using std::imag;
-
- template<typename _Tp>
- inline typename __promote<_Tp>::__type
- imag(_Tp)
- { return _Tp(); }
-
using std::norm;
-
- template<typename _Tp>
- inline typename __promote<_Tp>::__type
- norm(_Tp __x)
- {
- typedef typename __promote<_Tp>::__type __type;
- return __type(__x) * __type(__x);
- }
-
using std::polar;
-
- template<typename _Tp, typename _Up>
- inline std::complex<typename __promote_2<_Tp, _Up>::__type>
- polar(const _Tp& __rho, const _Up& __theta)
- {
- typedef typename __promote_2<_Tp, _Up>::__type __type;
- return std::polar(__type(__rho), __type(__theta));
- }
-
using std::pow;
-
- template<typename _Tp, typename _Up>
- inline std::complex<typename __promote_2<_Tp, _Up>::__type>
- pow(const std::complex<_Tp>& __x, const _Up& __y)
- {
- typedef typename __promote_2<_Tp, _Up>::__type __type;
- return std::pow(std::complex<__type>(__x), __type(__y));
- }
-
- template<typename _Tp, typename _Up>
- inline std::complex<typename __promote_2<_Tp, _Up>::__type>
- pow(const _Tp& __x, const std::complex<_Up>& __y)
- {
- typedef typename __promote_2<_Tp, _Up>::__type __type;
- return std::pow(__type(__x), std::complex<__type>(__y));
- }
-
- template<typename _Tp, typename _Up>
- inline std::complex<typename __promote_2<_Tp, _Up>::__type>
- pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y)
- {
- typedef typename __promote_2<_Tp, _Up>::__type __type;
- return std::pow(std::complex<__type>(__x),
- std::complex<__type>(__y));
- }
-
using std::real;
-
- template<typename _Tp>
- inline typename __promote<_Tp>::__type
- real(_Tp __x)
- { return __x; }
-
-_GLIBCXX_END_NAMESPACE
+}
}
-#endif
+#endif // _GLIBCXX_TR1_COMPLEX
+