SymbolicML / DynamicQuantities.jl

Efficient and type-stable physical quantities in Julia
https://symbolicml.org/DynamicQuantities.jl/dev/
Apache License 2.0
132 stars 17 forks source link

Exponential should work with dimensionless quantities #50

Open gaurav-arya opened 1 year ago

gaurav-arya commented 1 year ago

We should be able to exponentiate dimensionless quantitites. For a motivated example:

using DynamicQuantities.Constants: a_0

R10(r) = 2 / a_0^(3/2) * exp(-r/a_0)
R10(3 * a_0)

And a minimal case:

using DynamicQuantities
exp(1u"m" / 1u"m")

With error:

ERROR: MethodError: no method matching exp(::Quantity{Float64, Dimensions{DynamicQuantities.FixedRational{Int32, 25200}}})

Happy to put in a PR, although it may be a few days due to schoolwork.

MilesCranmer commented 1 year ago

Good point. I purposefully left it out due to the question of type stability, but I think as long as exp always returns the base scalar type rather than a dimensionless quantity, then it's fine.