-
Notifications
You must be signed in to change notification settings - Fork 8
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
Partial Inverses #39
Partial Inverses #39
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||
# default methods for when an inverse exists | ||||||
export r_inv, l_inv, retraction, coretraction | ||||||
|
||||||
""" | ||||||
r_inv(function) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should use a more descriptive name and also be consistent with
Suggested change
|
||||||
retraction(function) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need an alias? I prefer a simple API and would suggest defining only
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, |
||||||
|
||||||
Return the left inverse of a function, i.e. a function that "undoes" `f`. Formally, | ||||||
``\\text{retraction}(f)(f(x)) = x`` | ||||||
""" | ||||||
r_inv(args...; kwargs...) = inverse(args...; kwargs...) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
""" | ||||||
l_inv(function) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same hee, I think we should use only the name
Suggested change
|
||||||
coretraction(function) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Return the right inverse of a function, i.e. a function that can be "undone" by applying | ||||||
`f`. Formally, | ||||||
``f(\\text{coretraction}(f)(x)) = x`` | ||||||
""" | ||||||
l_inv(args...; kwargs...) = inverse(args...; kwargs...) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
# synonyms common in category theory | ||||||
# coretractions are often called "section"s, but name is likely too generic | ||||||
retraction = r_inv | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(BTW aliases should be defined with |
||||||
coretraction = l_inv | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
# Generate trig and htrig inverses | ||||||
let trigfuns = ("sin", "cos", "tan", "sec", "csc", "cot") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it's simpler to loop over these functions:
Suggested change
|
||||||
# regular, degrees, hyperbolic | ||||||
funcs = (trigfuns..., (trigfuns .* "d")..., (trigfuns .* "h")...) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for broadcasting and splatting, just loop over them:
Suggested change
|
||||||
invfuncs = "a" .* funcs | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
funcs, invfuncs = Symbol.(funcs), Symbol.(invfuncs) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
for (func, invfunc) in zip(funcs, invfuncs) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
@eval l_inv(::typeof($func)) = $invfunc | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
@eval r_inv(::typeof($invfunc)) = $func | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
end | ||||||
end |
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.
This should not be removed. Can you revert this?