Skip to content

Comments

fix: finite differences for complex inputs#2199

Open
avik-pal wants to merge 1 commit intomainfrom
ap/fix_complex_fd
Open

fix: finite differences for complex inputs#2199
avik-pal wants to merge 1 commit intomainfrom
ap/fix_complex_fd

Conversation

@avik-pal
Copy link
Collaborator

No description provided.

@avik-pal avik-pal requested a review from wsmoses January 23, 2026 18:43
)
# For complex numbers, we need to perturb real and imaginary parts separately
if elT <: Complex
real_perturbation = complex.(perturbation, zero(perturbation))
Copy link
Member

Choose a reason for hiding this comment

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

so we need to be careful here because forward and reverse mode should have different conventions here. see : https://enzymead.github.io/Enzyme.jl/stable/faq/#Complex-numbers

I think this is equivalent to forward mode

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should we document this is only valid for holomorphic functions?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, or at least we should document the convention [which ofc for holomorphic is equivalent across all conventions]

Copy link
Member

Choose a reason for hiding this comment

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

actually I don't think that's the case, are you passing in the equivalent of 1+1im ? [except onehot]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

1 + 0i and 0 + 1i

Copy link
Member

Choose a reason for hiding this comment

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

ah, I guess I'm not understanding how we combine them then for the final answer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@avik-pal avik-pal force-pushed the ap/fix_complex_fd branch 2 times, most recently from 1a880a5 to 34179c5 Compare January 26, 2026 16:53
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