Skip to content

Commit 0c6c54d

Browse files
[do-not-upstream] complex: Fix cacoshf() function for pure real inputs
Special handling for purely real inputs where `x >= 1` to use the real `acoshf()` function which is more accurate for these cases and use the complex formula for other cases Signed-off-by: Mostafa Salman <[email protected]>
1 parent fc623e3 commit 0c6c54d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

newlib/libm/complex/cacoshf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@
3333
*/
3434

3535
#include <complex.h>
36+
#include <math.h>
3637

3738
float complex
3839
cacoshf(float complex z)
3940
{
4041
float complex w;
42+
float x = crealf(z);
43+
float y = cimagf(z);
44+
45+
if (y == 0.0f && x >= 1.0f) {
46+
float w = acoshf(x);
47+
return CMPLXF(w, 0.0f);
48+
}
4149

4250
#if 0 /* does not give the principal value */
4351
w = I * cacosf(z);

0 commit comments

Comments
 (0)