You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia>abs2(1Volt)
ERROR: MethodError: no method matching abs2(::SIUnits.SIQuantity{Int64,2,1,-3,-1,0,0,0,0,0})
Closest candidates are:abs2(::Bool) at bool.jl:38abs2(::Measurements.Measurement{T<:AbstractFloat}) at /Users/rawlik/.julia/v0.5/Measurements/src/math.jl:610abs2(::Real) at number.jl:41...
julia>abs(1Volt)^21 kg²m⁴s⁻⁶A⁻²
It would be very interesting if this would work, as then one can propagate units through linear fits:
julia> x = (1:10)Ampere
y =randn(10)Volt
[x ones(x)] \ y
ERROR: MethodError: no method matching abs2(::SIUnits.SIQuantity{Float64,0,0,0,1,0,0,0,0,0})
Closest candidates are:abs2(::Bool) at bool.jl:38abs2(::Measurements.Measurement{T<:AbstractFloat}) at /Users/rawlik/.julia/v0.5/Measurements/src/math.jl:610abs2(::Real) at number.jl:41
The text was updated successfully, but these errors were encountered:
It should be very easy to define a fallback as abs2(x::SIQuantity) = abs(x)^2, but a more efficient implementation is probably something like
function abs2{T,m,kg,s,A,K,mol,cd,rad,sr}(x::SIQuantity{T,m,kg,s,A,K,mol,cd,rad,sr})
val = abs2(x.val)
SIQuantity{typeof(val),2*m,2*kg,2*s,2*A,2*K,2*mol,2*cd,2*rad,2*sr}(val)
end
A PR with this (and a couple of tests) would most likely get merged in no time ;)
It would be very interesting if this would work, as then one can propagate units through linear fits:
The text was updated successfully, but these errors were encountered: