-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* More arithmetic * Fix format * Fixes * Fix format * up
- Loading branch information
Showing
7 changed files
with
61 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const _APL = MP.AbstractPolynomialLike | ||
# We don't define it for all `AlgebraElement` as this would be type piracy | ||
const _AE = SA.AlgebraElement{<:Algebra} | ||
|
||
Base.:(+)(p::_APL, q::_AE) = +(p, MP.polynomial(q)) | ||
Base.:(+)(p::_AE, q::_APL) = +(MP.polynomial(p), q) | ||
Base.:(-)(p::_APL, q::_AE) = -(p, MP.polynomial(q)) | ||
Base.:(-)(p::_AE, q::_APL) = -(MP.polynomial(p), q) | ||
|
||
Base.:(+)(p, q::_AE) = +(constant_algebra_element(typeof(SA.basis(q)), p), q) | ||
function Base.:(+)(p::_AE, q) | ||
return +(MP.polynomial(p), constant_algebra_element(typeof(SA.basis(p)), q)) | ||
end | ||
function Base.:(-)(p, q::_AE) | ||
return -(constant_algebra_element(typeof(SA.basis(q)), p), MP.polynomial(q)) | ||
end | ||
function Base.:(-)(p::_AE, q) | ||
return -(MP.polynomial(p), constant_algebra_element(typeof(SA.basis(p)), q)) | ||
end | ||
|
||
function Base.:(+)(p::_AE, q::_AE) | ||
return MA.operate_to!(SA._preallocate_output(+, p, q), +, p, q) | ||
end | ||
|
||
function Base.:(-)(p::_AE, q::_AE) | ||
return MA.operate_to!(SA._preallocate_output(-, p, q), -, p, q) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters