Skip to content

Commit 93a450e

Browse files
DiamonDinoiaserge-sans-paille
authored andcommitted
fix: avoid atan branch cut in complex trigonometric test
The atan_input generator sampled (Re=0, Im=1.5) at i=N/2, which lies on the branch cut of complex atan at Re=0, |Im|>=1. C99 7.3.4.1 leaves the sign of Re(catan(+/-0 + i*y)) for |y|>1 implementation-defined: glibc returns +pi/2, musl returns -pi/2. xsimd matches glibc, so the test fails on musl-based CI (e.g. void-linux x86_64-musl) with two mismatches (one per complex<float>/complex<double> batch type). Shift the real start from -10 to -9.5 so Re=0 occurs at i=19000, where |Im|~0.975<1 - analytic territory where atan is uniquely defined and all libcs agree. Negative/positive real coverage is preserved; only the singular point on a region of unspecified behavior is dropped.
1 parent 80c2362 commit 93a450e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/test_complex_trigonometric.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ struct complex_trigonometric_test
4343
real_value_type(0.1) + i * real_value_type(56.) / nb_input);
4444
ainput[i] = value_type(real_value_type(-1.) + real_value_type(2.) * i / nb_input,
4545
real_value_type(-1.1) + real_value_type(2.1) * i / nb_input);
46-
atan_input[i] = value_type(real_value_type(-10.) + i * real_value_type(20.) / nb_input,
46+
// Avoid sampling the branch cut of complex atan at (Re=0, |Im|>=1):
47+
// the sign of Re(catan(+/-0 + i*y)) for |y|>1 is implementation-defined
48+
// (C99 7.3.4.1), and glibc and musl disagree there. Starting Re at -9.5
49+
// makes Re=0 occur at i=19/40 of the range, where |Im|<1 (analytic).
50+
atan_input[i] = value_type(real_value_type(-9.5) + i * real_value_type(20.) / nb_input,
4751
real_value_type(-9.) + i * real_value_type(21.) / nb_input);
4852
}
4953
expected.resize(nb_input);

0 commit comments

Comments
 (0)