From a5d033e56fc563d6d50a26b50967053ccc8152e1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 17 Oct 2025 14:52:55 +0530 Subject: [PATCH 1/3] conj & conjugate impl --- quaddtype/numpy_quaddtype/src/ops.hpp | 14 ++++++++++++++ quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp | 5 +++++ quaddtype/release_tracker.md | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/quaddtype/numpy_quaddtype/src/ops.hpp b/quaddtype/numpy_quaddtype/src/ops.hpp index dd385d92..08618126 100644 --- a/quaddtype/numpy_quaddtype/src/ops.hpp +++ b/quaddtype/numpy_quaddtype/src/ops.hpp @@ -37,6 +37,13 @@ quad_absolute(const Sleef_quad *op) return Sleef_fabsq1(*op); } +static inline Sleef_quad +quad_conjugate(const Sleef_quad *op) +{ + // For real numbers, conjugate is the identity function (no-op) + return *op; +} + static inline Sleef_quad quad_rint(const Sleef_quad *op) { @@ -217,6 +224,13 @@ ld_absolute(const long double *op) return fabsl(*op); } +static inline long double +ld_conjugate(const long double *op) +{ + // For real numbers, conjugate is the identity function (no-op) + return *op; +} + static inline long double ld_sign(const long double *op) { diff --git a/quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp b/quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp index b8a82aee..3c343fef 100644 --- a/quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp +++ b/quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp @@ -161,6 +161,11 @@ init_quad_unary_ops(PyObject *numpy) if (create_quad_unary_ufunc(numpy, "fabs") < 0) { return -1; } + // conjugate is a no-op for real numbers (returns the value unchanged) + if (create_quad_unary_ufunc(numpy, "conjugate") < 0) { + return -1; + } + // conj is an alias for conjugate, no need to register if (create_quad_unary_ufunc(numpy, "sign") < 0) { return -1; } diff --git a/quaddtype/release_tracker.md b/quaddtype/release_tracker.md index cb61ecbe..a4314ed3 100644 --- a/quaddtype/release_tracker.md +++ b/quaddtype/release_tracker.md @@ -27,8 +27,8 @@ | rint | ✅ | ✅ | | sign | ✅ | ✅ | | heaviside | | | -| conj | | | -| conjugate | | | +| conj | ✅ | ✅ | +| conjugate | ✅ | ✅ | | exp | ✅ | ✅ | | exp2 | ✅ | ✅ | | log | ✅ | ✅ | From 5857a7d4403cda2259dfc636a1d42637f94f540d Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 17 Oct 2025 17:55:12 +0530 Subject: [PATCH 2/3] remove gcd, lcm as they only defined for integers --- quaddtype/release_tracker.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/quaddtype/release_tracker.md b/quaddtype/release_tracker.md index 960d2e2f..6a845a34 100644 --- a/quaddtype/release_tracker.md +++ b/quaddtype/release_tracker.md @@ -43,8 +43,6 @@ | square | ✅ | ✅ | | cbrt | | | | reciprocal | ✅ | ✅ | -| gcd | | | -| lcm | | | | sin | ✅ | ❌ _Need: basic tests + edge cases (NaN/inf/0/π multiples/2π range)_ | | cos | ✅ | ❌ _Need: basic tests + edge cases (NaN/inf/0/π multiples/2π range)_ | | tan | ✅ | ❌ _Need: basic tests + edge cases (NaN/inf/0/π/2 asymptotes)_ | From ee98269f1c11a91d0ad3d7f605780bde0825b229 Mon Sep 17 00:00:00 2001 From: SwayamInSync Date: Fri, 17 Oct 2025 14:10:47 +0000 Subject: [PATCH 3/3] testS --- quaddtype/tests/test_quaddtype.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/quaddtype/tests/test_quaddtype.py b/quaddtype/tests/test_quaddtype.py index b1fbb0bc..e27ea8dc 100644 --- a/quaddtype/tests/test_quaddtype.py +++ b/quaddtype/tests/test_quaddtype.py @@ -1693,3 +1693,25 @@ def test_heaviside_broadcast(): assert result.dtype.name == "QuadPrecDType128" np.testing.assert_array_equal(result.astype(float), expected) + +@pytest.mark.parametrize("func", [np.conj, np.conjugate]) +@pytest.mark.parametrize("value", [ + 0.0, + -0.0, + 1.5, + -1.5, + np.inf, + -np.inf, + np.nan, +]) +def test_conj_conjugate_identity(func, value): + """Test that conj and conjugate are identity (no-op) for real quad precision numbers""" + x = QuadPrecision(value) + result = func(x) + + # For NaN, use special comparison + if np.isnan(value): + assert np.isnan(float(result)) + else: + assert result == x +