Skip to content

Conversation

SwayamInSync
Copy link
Member

Copilot Summary

This pull request adds support for logical operations (logical_and, logical_or, logical_xor, and logical_not) for the QuadPrecision data type, ensuring their behavior matches NumPy's semantics. The implementation covers both Sleef quad and long double backends, integrates these operations into the ufunc system, and provides comprehensive tests to verify correctness and compatibility.

Logical operations implementation:

  • Added helper functions and logical operation implementations for both Sleef_quad and long double backends in ops.hpp, including truthiness checks and all four logical operations (and, or, xor, not).

Ufunc integration:

  • Registered new binary logical ufuncs (logical_and, logical_or, logical_xor) in umath/comparison_ops.cpp.
  • Implemented and registered the unary logical not ufunc with correct output type resolution and strided loop handling in umath/unary_ops.cpp. [1] [2]

Testing and documentation:

  • Added thorough tests for all logical operations, including edge cases (zero, negative zero, NaN, inf), in test_quaddtype.py, comparing QuadPrecision results against NumPy's float64 behavior.
  • Updated release_tracker.md to mark logical operations as implemented and tested.

@juntyr
Copy link
Contributor

juntyr commented Oct 18, 2025

Why do we need the extra -0.0 and +0.0 comparison for SLEEF? They should already compare equal (if not, do we already special-case handle them in the other comparison functions)?

@SwayamInSync
Copy link
Member Author

Why do we need the extra -0.0 and +0.0 comparison for SLEEF? They should already compare equal (if not, do we already special-case handle them in the other comparison functions)?

Nope sorry I was thinking something else, it can compare correctly

Copy link
Contributor

@juntyr juntyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with the one comment addressed

@SwayamInSync
Copy link
Member Author

Merging this in!

@SwayamInSync SwayamInSync merged commit ed7458a into numpy:main Oct 18, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants