Skip to content

Preserve the imaginary zero sign in complex log1p - #1438

Closed
agourakis82 wants to merge 1 commit into
xtensor-stack:masterfrom
agourakis82:fix/complex-log1p-branch-cut-1432
Closed

agourakis82 wants to merge 1 commit into
xtensor-stack:masterfrom
agourakis82:fix/complex-log1p-branch-cut-1432

Conversation

@agourakis82

@agourakis82 agourakis82 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Complex log1p added 1 with a complex broadcast, which replaced a negative imaginary zero by a positive zero before the logarithm, so log1p(-2, -0) took the upper side of the branch cut. The translation now adds 1 to the real part only. An 8 by 8 grid compares the batch with std::log(1 + real, imag), including a point just below -1 and signed zeros, with and without fast-math. The point -1 itself stays out of the grid.

Part of #1432.

Written by me with AI assistance.

@DiamonDinoia DiamonDinoia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would casting 1 to

@agourakis82
agourakis82 force-pushed the fix/complex-log1p-branch-cut-1432 branch 3 times, most recently from 3e39c58 to eb742cb Compare November 8, 2026 19:09
Add 1 to the real part only, so a negative imaginary zero is not flushed before log.
@DiamonDinoia

Copy link
Copy Markdown
Contributor

Superseded by #1456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants