File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ quad_absolute(const Sleef_quad *op)
3737 return Sleef_fabsq1 (*op);
3838}
3939
40+ static inline Sleef_quad
41+ quad_conjugate (const Sleef_quad *op)
42+ {
43+ // For real numbers, conjugate is the identity function (no-op)
44+ return *op;
45+ }
46+
4047static inline Sleef_quad
4148quad_rint (const Sleef_quad *op)
4249{
@@ -257,6 +264,13 @@ ld_absolute(const long double *op)
257264 return fabsl (*op);
258265}
259266
267+ static inline long double
268+ ld_conjugate (const long double *op)
269+ {
270+ // For real numbers, conjugate is the identity function (no-op)
271+ return *op;
272+ }
273+
260274static inline long double
261275ld_sign (const long double *op)
262276{
Original file line number Diff line number Diff line change @@ -161,6 +161,11 @@ init_quad_unary_ops(PyObject *numpy)
161161 if (create_quad_unary_ufunc<quad_absolute, ld_absolute>(numpy, " fabs" ) < 0 ) {
162162 return -1 ;
163163 }
164+ // conjugate is a no-op for real numbers (returns the value unchanged)
165+ if (create_quad_unary_ufunc<quad_conjugate, ld_conjugate>(numpy, " conjugate" ) < 0 ) {
166+ return -1 ;
167+ }
168+ // conj is an alias for conjugate, no need to register
164169 if (create_quad_unary_ufunc<quad_sign, ld_sign>(numpy, " sign" ) < 0 ) {
165170 return -1 ;
166171 }
Original file line number Diff line number Diff line change 2727| rint | ✅ | ✅ |
2828| sign | ✅ | ✅ |
2929| heaviside | ✅ | ✅ |
30+ | conj | ✅ | ✅ |
31+ | conjugate | ✅ | ✅ |
32+ | heaviside | ✅ | ✅ |
3033| conj | | |
3134| conjugate | | |
3235| exp | ✅ | ✅ |
4043| square | ✅ | ✅ |
4144| cbrt | ✅ | ✅ |
4245| reciprocal | ✅ | ✅ |
43- | gcd | | |
44- | lcm | | |
4546| sin | ✅ | ❌ _ Need: basic tests + edge cases (NaN/inf/0/π multiples/2π range)_ |
4647| cos | ✅ | ❌ _ Need: basic tests + edge cases (NaN/inf/0/π multiples/2π range)_ |
4748| tan | ✅ | ❌ _ Need: basic tests + edge cases (NaN/inf/0/π/2 asymptotes)_ |
Original file line number Diff line number Diff line change @@ -1837,3 +1837,25 @@ def test_heaviside_broadcast():
18371837 assert result .dtype .name == "QuadPrecDType128"
18381838 np .testing .assert_array_equal (result .astype (float ), expected )
18391839
1840+
1841+ @pytest .mark .parametrize ("func" , [np .conj , np .conjugate ])
1842+ @pytest .mark .parametrize ("value" , [
1843+ 0.0 ,
1844+ - 0.0 ,
1845+ 1.5 ,
1846+ - 1.5 ,
1847+ np .inf ,
1848+ - np .inf ,
1849+ np .nan ,
1850+ ])
1851+ def test_conj_conjugate_identity (func , value ):
1852+ """Test that conj and conjugate are identity (no-op) for real quad precision numbers"""
1853+ x = QuadPrecision (value )
1854+ result = func (x )
1855+
1856+ # For NaN, use special comparison
1857+ if np .isnan (value ):
1858+ assert np .isnan (float (result ))
1859+ else :
1860+ assert result == x
1861+
You can’t perform that action at this time.
0 commit comments