2006-01-10 19:15:34 +01:00
|
|
|
// TR1 complex -*- C++ -*-
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
2006-01-10 19:15:34 +01:00
|
|
|
//
|
|
|
|
// 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
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2006-01-10 19:15:34 +01:00
|
|
|
// 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.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2006-01-10 19:15:34 +01:00
|
|
|
|
2006-12-06 00:24:07 +01:00
|
|
|
/** @file tr1/complex
|
2006-01-10 19:15:34 +01:00
|
|
|
* This is a TR1 C++ Library header.
|
|
|
|
*/
|
|
|
|
|
2007-06-01 01:37:56 +02:00
|
|
|
#ifndef _GLIBCXX_TR1_COMPLEX
|
|
|
|
#define _GLIBCXX_TR1_COMPLEX 1
|
2006-01-10 19:15:34 +01:00
|
|
|
|
2007-06-01 01:37:56 +02:00
|
|
|
#pragma GCC system_header
|
2006-01-10 19:15:34 +01:00
|
|
|
|
2007-06-01 01:37:56 +02:00
|
|
|
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
|
|
|
|
# error TR1 header cannot be included from C++0x header
|
2006-01-10 19:15:34 +01:00
|
|
|
#endif
|
|
|
|
|
2007-06-01 01:37:56 +02:00
|
|
|
#include <complex>
|
2006-01-10 19:15:34 +01:00
|
|
|
|
2007-06-01 01:37:56 +02:00
|
|
|
#if defined(_GLIBCXX_INCLUDE_AS_TR1)
|
|
|
|
# include <tr1_impl/complex>
|
2006-01-10 19:15:34 +01:00
|
|
|
#else
|
2007-06-01 01:37:56 +02:00
|
|
|
# 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
|
2006-01-10 19:15:34 +01:00
|
|
|
#endif
|
|
|
|
|
2007-06-01 01:37:56 +02:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
namespace tr1
|
|
|
|
{
|
2006-03-10 14:24:57 +01:00
|
|
|
using std::arg;
|
|
|
|
using std::conj;
|
|
|
|
using std::imag;
|
|
|
|
using std::norm;
|
|
|
|
using std::polar;
|
2008-05-22 13:44:00 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Up>
|
|
|
|
inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
|
|
|
|
polar(const _Tp& __rho, const _Up& __theta)
|
|
|
|
{
|
|
|
|
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
|
|
|
|
return std::polar(__type(__rho), __type(__theta));
|
|
|
|
}
|
|
|
|
|
2006-03-10 14:24:57 +01:00
|
|
|
using std::real;
|
cmath (pow(float, int), [...]): Do not define in C++0x mode, per DR 550.
2008-05-26 Paolo Carlini <paolo.carlini@oracle.com>
* include/c_global/cmath (pow(float, int), pow(double, int),
pow(long double, int)): Do not define in C++0x mode, per DR 550.
* include/tr1_impl/cmath (pow): Do not bring in unconditionally
from namespace std.
* include/tr1/cmath (pow(double, double), pow(float, float),
pow(long double, long double), pow(_Tp, _Up)): Define.
* include/tr1/complex (pow): Do not bring in from namespace std.
(pow(const std::complex<_Tp>&, int), pow(const std::complex<_Tp>&,
const _Tp&), pow(const _Tp&, const std::complex<_Tp>&),
pow(const std::complex<_Tp>&, const std::complex<_Tp>&)): Define.
* include/tr1_impl/complex (pow(const std::complex<_Tp>&,
const _Up&), pow(const _Tp&, const std::complex<_Up>&),
pow(const std::complex<_Tp>&, const std::complex<_Up>&)): Always
define.
* doc/xml/manual/intro.xml: Add an entry for DR 550.
* testsuite/26_numerics/headers/cmath/dr550.cc: New.
* testsuite/tr1/8_c_compatibility/cmath/overloads.cc: Adjust.
From-SVN: r135955
2008-05-26 21:18:24 +02:00
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline std::complex<_Tp>
|
|
|
|
pow(const std::complex<_Tp>& __x, const _Tp& __y)
|
|
|
|
{ return std::pow(__x, __y); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline std::complex<_Tp>
|
|
|
|
pow(const _Tp& __x, const std::complex<_Tp>& __y)
|
|
|
|
{ return std::pow(__x, __y); }
|
|
|
|
|
|
|
|
template<typename _Tp>
|
|
|
|
inline std::complex<_Tp>
|
|
|
|
pow(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y)
|
|
|
|
{ return std::pow(__x, __y); }
|
2007-06-01 01:37:56 +02:00
|
|
|
}
|
2006-01-10 19:15:34 +01:00
|
|
|
}
|
|
|
|
|
2007-06-01 01:37:56 +02:00
|
|
|
#endif // _GLIBCXX_TR1_COMPLEX
|