-
Notifications
You must be signed in to change notification settings - Fork 63
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
Correct mutating op fallbacks #1823
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 |
---|---|---|
|
@@ -328,11 +328,16 @@ | |
inv!(z, a) | ||
inv!(a) | ||
|
||
Return `inv(a)`, possibly modifying the object `z` in the process. | ||
Return `AbstractAlgebra.inv(a)`, possibly modifying the object `z` in the process. | ||
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. It can be very surprising (esp. for a Julia beginner) that Should the same be done for 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. Ah I see you wrote that as a question. So yeah, I think |
||
Aliasing is permitted. | ||
The unary version is a shorthand for `inv!(a, a)`. | ||
|
||
!!! note | ||
`AbstractAlgebra.inv` and `Base.inv` differ only in their behavior on julia | ||
types like `Integer` and `Rational{Int}`. The former makes it adhere to the | ||
Ring interface. | ||
""" | ||
inv!(z, a) = inv(a) | ||
inv!(z, a) = AbstractAlgebra.inv(a) | ||
inv!(a) = inv!(a, a) | ||
|
||
for (name, op) in ((:add!, :+), (:sub!, :-), (:mul!, :*)) | ||
|
@@ -378,7 +383,7 @@ | |
|
||
function divexact end | ||
|
||
for name in (:divexact, :div, :rem, :mod, :gcd, :lcm) | ||
for name in (:divexact, :rem, :mod, :gcd, :lcm) | ||
name_bang = Symbol(name, "!") | ||
@eval begin | ||
@doc """ | ||
|
@@ -394,6 +399,22 @@ | |
end | ||
end | ||
|
||
@doc """ | ||
div!(z, a, b) | ||
div!(a, b) | ||
|
||
Return `div(a, b)`, possibly modifying the object `z` in the process. | ||
Aliasing is permitted. | ||
The two argument version is a shorthand for `div(a, a, b)`. | ||
|
||
!!! note | ||
`AbstractAlgebra.div` and `Base.div` differ only in their behavior on julia | ||
types like `Integer` and `Rational{Int}`. The former makes it adhere to the | ||
Ring interface. | ||
""" | ||
div!(z, a, b) = AbstractAlgebra.div(a, b) | ||
div!(a, b) = div!(a, a, b) | ||
|
||
@doc raw""" | ||
canonical_injection(D, i) | ||
|
||
|
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.
redundant due to
AbstractAlgebra.jl/src/algorithms/GenericFunctions.jl
Lines 77 to 79 in c70d3b6