-
Notifications
You must be signed in to change notification settings - Fork 25
Add many other numeric methods #78
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
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
FYI the errors seem to be coming from this issue: JuliaPhysics/Measurements.jl#162 so not related to this PR at all. |
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.
Looks good to me! Only thing I wondered is whether something like exp(x)
should return an instance of the base type or a dimensionless quantity. This goes back to the one
debate too (ugh), e.g. f(q) = iszero(q) ? one(q) : exp(q)
wouldn't be type stable currently. But I don't see an obvious answer here (nor do I think it has to be resolved in this PR). It is indeed nice to go back to the simpler scalars when we can, which is a big plus of the current behaviour.
I think it's okay because |
I guess the downside is that if someone did stuff like x = 0.9u"km/s"
y = [x, x / x, exp(x / x * 0.3)] it would be So maybe you are right and we should just always keep to the original quantity type... to absolutely guarantee type stability. |
I think I am 50/50 on this... So I'd welcome any opinions one way or the other. |
I guess we could also fix this by simply defining a promotion rule for all the primitive numeric types in https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/. (Recalling that the reason I avoided a generic |
I do feel like |
My overall opinion is that the scalar-output approach for |
Okay we could rebase this on #84 if you are on board with that change |
Sounds good! |
9d1155b
to
08c0398
Compare
e342794
to
c10d874
Compare
c10d874
to
06fe0af
Compare
This adds methods for the following functions. Most of these will throw an error if the quantity has nonzero dimensions. However some of the functions allow nonzero dimensions, and simply return an output with the same dimensions.
div
sin
cos
tan
sinh
cosh
tanh
asin
acos
asinh
acosh
atanh
sec
csc
cot
asec
acsc
acot
sech
csch
coth
asech
acsch
acoth
sinc
cosc
cosd
cotd
cscd
secd
sinpi
cospi
sind
tand
acosd
acotd
acscd
asecd
asind
log
log2
log10
log1p
exp
exp2
exp10
expm1
frexp
exponent
atan
atand
adjoint
unsigned
identity
transpose
copysign
flipsign
mod
ldexp
round
floor
trunc
ceil
significand
modf
signbit
(inutils.jl
)It also moves methods over to
math.jl
for:real
imag
conj
nextfloat
prevfloat
TODO: