]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
complex (proj): Change return type per DR 1137.
authorPaolo Carlini <paolo.carlini@oracle.com>
Sun, 21 Feb 2010 19:55:17 +0000 (19:55 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 21 Feb 2010 19:55:17 +0000 (19:55 +0000)
2010-02-21  Paolo Carlini  <paolo.carlini@oracle.com>

* include/std/complex (proj): Change return type per DR 1137.
(conj): Copy from tr1_impl, likewise adjust return type.
* include/tr1_impl/complex (conj): Remove.
* include/tr1/complex (conj): Add both overloads.
* testsuite/26_numerics/complex/dr781.cc: Rename to...
* testsuite/26_numerics/complex/dr781_dr1137.cc: ... this, and extend.

* include/tr1_impl/complex (arg): Optimize.

From-SVN: r156940

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/complex
libstdc++-v3/include/tr1/complex
libstdc++-v3/include/tr1_impl/complex
libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc [moved from libstdc++-v3/testsuite/26_numerics/complex/dr781.cc with 72% similarity]

index a9ccd8a1dfaf89cb241b73851d329dd5ba95d043..4a5f342bbb562d290950a6d945f81efefebdfca7 100644 (file)
@@ -1,3 +1,14 @@
+2010-02-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * include/std/complex (proj): Change return type per DR 1137.
+       (conj): Copy from tr1_impl, likewise adjust return type.
+       * include/tr1_impl/complex (conj): Remove.
+       * include/tr1/complex (conj): Add both overloads.
+       * testsuite/26_numerics/complex/dr781.cc: Rename to...
+       * testsuite/26_numerics/complex/dr781_dr1137.cc: ... this, and extend.
+
+       * include/tr1_impl/complex (arg): Optimize.
+
 2010-02-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * testsuite/20_util/is_trivial/requirements/typedefs.cc: New.
index 4c0d3fbe7db1c1aa74b26384322f115e60a92405..6d3097e0a1e340e2dfb4726ad39852f19ce41dc3 100644 (file)
@@ -1,7 +1,7 @@
 // The template and inlines for the -*- C++ -*- complex number classes.
 
 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007, 2008, 2009
+// 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -1572,13 +1572,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     { return __complex_proj(__z); }
 #endif
 
+  // DR 1137.
   template<typename _Tp>
-    inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type>
+    inline typename __gnu_cxx::__promote<_Tp>::__type
     proj(_Tp __x)
-    {
-      typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-      return std::proj(std::complex<__type>(__x));
-    }
+    { return __x; }
+
+  template<typename _Tp>
+    inline typename __gnu_cxx::__promote<_Tp>::__type
+    conj(_Tp __x)
+    { return __x; }
 
 _GLIBCXX_END_NAMESPACE
 
index 3ed1eb97f67f7df9ccab9cd86f133d22711ec3f0..063112b440b2ec03df4909eada4afdb7fc7b6412 100644 (file)
@@ -1,6 +1,6 @@
 // TR1 complex -*- C++ -*-
 
-// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2006, 2007, 2008, 2009, 2010 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
@@ -56,7 +56,17 @@ namespace std
 namespace tr1
 {
   using std::arg;
-  using std::conj;
+
+  template<typename _Tp>
+    inline std::complex<_Tp>
+    conj(const std::complex<_Tp>& __z)
+    { return std::conj(__z); }  
+
+  template<typename _Tp>
+    inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type>
+    conj(_Tp __x)
+    { return __x; }
+
   using std::imag;
   using std::norm;
   using std::polar;
index 615fe1886f88299d3f078b225c66a3e9c1c79b71..ac420bf199cb2905ae6ad94edf256e5e2ac0abe6 100644 (file)
@@ -1,6 +1,6 @@
 // TR1 complex -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010 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
@@ -311,14 +311,10 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
     arg(_Tp __x)
     {
       typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
-      return std::arg(std::complex<__type>(__x));
+      return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
+                              : __type();
     }
 
-  template<typename _Tp>
-    inline std::complex<typename __gnu_cxx::__promote<_Tp>::__type>
-    conj(_Tp __x)
-    { return __x; }
-
   template<typename _Tp>
     inline typename __gnu_cxx::__promote<_Tp>::__type
     imag(_Tp)
similarity index 72%
rename from libstdc++-v3/testsuite/26_numerics/complex/dr781.cc
rename to libstdc++-v3/testsuite/26_numerics/complex/dr781_dr1137.cc
index df7f1e05b3fe8e11e07eb7d70ce4de75d0aeb21c..145a4b04499867941df75eb5497e1c9cb9c10573 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2008-05-22  Paolo Carlini  <paolo.carlini@oracle.com>
 //
-// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010 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
@@ -23,6 +23,7 @@
 #include <testsuite_tr1.h>
 
 // DR 781. std::complex should add missing C99 functions.
+// DR 1137. Return type of conj and proj.
 void test01()
 {
   bool test __attribute__((unused)) = true;
@@ -45,12 +46,21 @@ void test01()
   check_ret_type<cmplx_d_type>(std::proj(c_d1));
   check_ret_type<cmplx_ld_type>(std::proj(c_ld1));
 
-  check_ret_type<cmplx_f_type>(std::proj(f1));
-  check_ret_type<cmplx_d_type>(std::proj(d1));
-  check_ret_type<cmplx_d_type>(std::proj(i1));
+  check_ret_type<float>(std::proj(f1));
+  check_ret_type<double>(std::proj(d1));
+  check_ret_type<double>(std::proj(i1));
   VERIFY( std::proj(i1) == std::proj(double(i1)) );
-  VERIFY( std::proj(i1) == std::proj(cmplx_d_type(double(i1))) );
-  check_ret_type<cmplx_ld_type>(std::proj(ld1));
+  check_ret_type<long double>(std::proj(ld1));
+
+  check_ret_type<cmplx_f_type>(std::conj(c_f1));
+  check_ret_type<cmplx_d_type>(std::conj(c_d1));
+  check_ret_type<cmplx_ld_type>(std::conj(c_ld1));
+
+  check_ret_type<float>(std::conj(f1));
+  check_ret_type<double>(std::conj(d1));
+  check_ret_type<double>(std::conj(i1));
+  VERIFY( std::conj(i1) == std::conj(double(i1)) );
+  check_ret_type<long double>(std::conj(ld1));
 }
 
 int main()