This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[libstdc++-v3] Typo in std_complex.h (sqrt), patch included
- To: libstdc++ at gcc dot gnu dot org
- Subject: [libstdc++-v3] Typo in std_complex.h (sqrt), patch included
- From: Peter Schmid <schmid at snake dot iap dot physik dot tu-darmstadt dot de>
- Date: Wed, 10 Jan 2001 21:17:20 +0100 (CET)
- cc: gcc-patches at gcc dot gnu dot org
I believe there is a typo in line 467 of std_complex.h in function
template<typename _Tp> complex<_Tp> sqrt(const complex<_Tp>& __z).
The factor two should multiply the modulus of the complex number
\emph{and} of the real part of that number. Otherwise incorrect results
are obtained. For example without the patch the square root of 1 + i
yields (0.978318,0.511081) instead of the correct result (1.09868,0.45509).
The following simple patch fixes the problem.
Peter Schmid
*** /home/peter/egcs/gcc/libstdc++-v3/ChangeLog~ Tue Jan 9 18:03:40 2001
--- /home/peter/egcs/gcc/libstdc++-v3/ChangeLog Tue Jan 9 18:03:47 2001
***************
*** 1,3 ****
--- 1,6 ----
+ 2001-01-10 Peter Schmid<schmid@snake.iap.physik.tu-darmstadt.de>
+ * include/bits/std_complex.h: Fix a typo.
+
2001-01-05 Benjamin Kosnik <bkoz@redhat.com>
Fix 27_io/filebuf_members.cc
*** /home/peter/egcs/gcc/libstdc++-v3/include/bits/std_complex.h~ Wed Jan 10 20:57:38 2001
--- /home/peter/egcs/gcc/libstdc++-v3/include/bits/std_complex.h Wed Jan 10 20:59:34 2001
*************** namespace std
*** 464,470 ****
}
else
{
! _Tp __t = sqrt( 2 * abs(__z) + abs(__x));
_Tp __u = __t / 2;
return __x > _Tp()
? complex<_Tp>(__u, __y / __t)
--- 464,470 ----
}
else
{
! _Tp __t = sqrt( 2 * (abs(__z) + abs(__x)) );
_Tp __u = __t / 2;
return __x > _Tp()
? complex<_Tp>(__u, __y / __t)