On Thu, Nov 26, 2015 at 09:02:17PM +0500, Alexandr Shadchin wrote: > From http://en.cppreference.com/w/c/numeric/complex/csqrt : > > csqrt(conj(z)) == conj(csqrt(z)) > > Before patch > csqrt(-4.0 + -0.0i) = 0.0 + 2.0j > but should be > csqrt(-4.0 + -0.0i) = 0.0 - 2.0j
This, too, looks right to me. FWIW: ok tb@ > > -- > Alexandr Shadchin > > Index: lib/libm/src/s_csqrt.c > =================================================================== > RCS file: /cvs/src/lib/libm/src/s_csqrt.c,v > retrieving revision 1.6 > diff -u -p -r1.6 s_csqrt.c > --- lib/libm/src/s_csqrt.c 3 Jul 2013 04:46:36 -0000 1.6 > +++ lib/libm/src/s_csqrt.c 24 Nov 2015 08:45:25 -0000 > @@ -79,7 +79,7 @@ csqrt(double complex z) > r = fabs (x); > r = sqrt (r); > if (x < 0.0) { > - w = 0.0 + r * I; > + w = 0.0 + copysign(r, y) * I; > } > else { > w = r + y * I; > Index: lib/libm/src/s_csqrtf.c > =================================================================== > RCS file: /cvs/src/lib/libm/src/s_csqrtf.c,v > retrieving revision 1.2 > diff -u -p -r1.2 s_csqrtf.c > --- lib/libm/src/s_csqrtf.c 18 Jul 2010 18:42:26 -0000 1.2 > +++ lib/libm/src/s_csqrtf.c 24 Nov 2015 08:45:25 -0000 > @@ -72,7 +72,7 @@ csqrtf(float complex z) > > if(y == 0.0f) { > if (x < 0.0f) { > - w = 0.0f + sqrtf(-x) * I; > + w = 0.0f + copysign(sqrtf(-x), y) * I; > return (w); > } > else if (x == 0.0f) { > Index: lib/libm/src/s_csqrtl.c > =================================================================== > RCS file: /cvs/src/lib/libm/src/s_csqrtl.c,v > retrieving revision 1.2 > diff -u -p -r1.2 s_csqrtl.c > --- lib/libm/src/s_csqrtl.c 20 Jul 2011 19:28:33 -0000 1.2 > +++ lib/libm/src/s_csqrtl.c 24 Nov 2015 08:45:25 -0000 > @@ -72,7 +72,7 @@ csqrtl(long double complex z) > > if (y == 0.0L) { > if (x < 0.0L) { > - w = 0.0L + sqrtl(-x) * I; > + w = 0.0L + copysign(sqrtl(-x), y) * I; > return (w); > } > else { >