Skip to content
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

make +One() add the multiplicative identity #60

Closed
wants to merge 3 commits into from
Closed

Conversation

oxinabox
Copy link
Member

This is what was suggested in
#56 (comment)

What do we think?

make +One() add the multiplicative identity
strong_one(primal::AbstractMatrix) = LinearAlgebra.I
strong_one(primal) = one(primal)

Base.:+(a::One, b::One) = extern(a) + extern(b) # This is not well-defined.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like this comment to be more informative, if possible (i.e "so why do we have this?!")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not changed by this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really should be discussed somewhere else,
Maybe #56

Descibing why this is a problem in the code,
is splitting information that belongs in issues.
Maybe i should just revert the change to this line.

Suggested change
Base.:+(a::One, b::One) = extern(a) + extern(b) # This is not well-defined.
Base.:+(a::One, b::One) = extern(a) + extern(b)

oxinabox and others added 2 commits October 31, 2019 13:03
Co-Authored-By: Nick Robinson <npr251@gmail.com>
Co-Authored-By: Nick Robinson <npr251@gmail.com>
strong_one(primal::Number) = true
strong_one(primal::AbstractMatrix) = I
strong_one(primal) = one(primal)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me

@oxinabox
Copy link
Member Author

@willtebbutt is going to just delete One

@nickrobinson251 nickrobinson251 mentioned this pull request Jan 5, 2020
@@ -67,11 +67,15 @@ for T in (:One, :AbstractThunk, :Any)
end


Base.:+(a::One, b::One) = extern(a) + extern(b)
strong_one(primal::Number) = true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been pointed out by @simeonschaub that if we do
strong_one(primal::Number) = I
this work out well.
Which solves a bunch of problems of not knowing what the right strong(1) is, and kinda removes the need for a strong_one function in the first place?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not really. Strong one probably shouldn't change the number type.

julia> I * 1.5
UniformScaling{Float64}
1.5*I

@mzgubic mzgubic closed this Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants