Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Before this PR
After this PR
Why add methods?
Base has the following
==(::Real, ::Complex)
and==(::Complex, ::Real)
definitions.https://github.com/JuliaLang/julia/blob/e7345b89fd4eb15e8f395395701e19be705d7b06/base/complex.jl#L247-L249
Quaternions.jl should have methods similar to these, instead of
==
by type promotions.How about compatibility with the
Complex
type?There were the following choices for the design:
==(::Complex, ::Quaternion)
always throws an error.==
do not throw an error (e.g."foo" == :foo
), so it would be consistent with Base if we avoid throwing errors for that.==(z::Complex, q::Quaternion)
returnstrue
ifc.re==q.s && c.im==q.v1 && q.v2==q.v3==0
, otherwise returnsfalse
.Complex
(Remove compatibility withComplex
#113).==(::Complex, ::Quaternion)
returnstrue
only if these are real and equal, otherwise throws an error.==(::Complex, ::Quaternion)
returnstrue
only if these are real and equal, otherwise returnsfalse
.