-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add ability to define and query function inverses #1338
feat: add ability to define and query function inverses #1338
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1338 +/- ##
===========================================
+ Coverage 6.69% 77.77% +71.08%
===========================================
Files 47 49 +2
Lines 4618 4801 +183
===========================================
+ Hits 309 3734 +3425
+ Misses 4309 1067 -3242 ☔ View full report in Codecov by Sentry. |
""" | ||
$(TYPEDSIGNATURES) | ||
|
||
A simple utility function which returns the square of the input. Used to define | ||
the inverse of `sqrt`. | ||
""" | ||
square(x) = x ^ 2 | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
|
||
A simple utility function which returns the cube of the input. Used to define | ||
the inverse of `cbrt`. | ||
""" | ||
cube(x) = x ^ 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we should lowering sqrt to Pow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but why would that preclude defining the inverse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we wouldn't need to, since the function would not be in the representation.
`right_inverse` and `inverse` must not be defined and should error. `right_inverse(g)` | ||
should also be defined to return `f`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If f: X -> Y
is an injective function and g: Y -> X
is its left inverse, then I think it can be proven that g
is surjective and has f
as (one of) its right inverse(s) (and vice versa)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, never thought about that.
Close #1337
I'd like input on the NaNMath inverses. They violate the contract that
inverse(inverse(f)) == f
. We could leave it be, define wrapper functions, or add to the macro the ability to wrap the provided inverse function in an anonymous function. For example,would define