Keno / SIUnits.jl

Efficient unit-checked computation
Other
70 stars 26 forks source link

Respecting complex units #106

Open fbruetting opened 7 years ago

fbruetting commented 7 years ago

• Would be great if complex power could be named by VA, while real power stays W and imaginary power gets Var. • As far as I understand Julia, complex numbers aren't separated in real and imaginary parts, but this would be really useful for e.g. axis labeling, if the real or imaginary part of a complex number is zero or the Type Real is used somehow. At least W should be substituted by VA if SIUnits.jl is used in conjunction with Type Complex.

Depends on: #54 / #76 / #104.

tomasaschan commented 7 years ago

As far as I understand Julia, complex numbers aren't separated in real and imaginary parts

That's incorrect (see the source code). However, Julia's complex numbers are typed as Complex{T<:Real} and since unitful quantities don't subtype Real they can't be used independently for the built-in variables.

Instead, we usually do SIQuantity{Complex{T}, ...}, in which case we don't separate units over the real and imaginary parts.

fbruetting commented 7 years ago

Not sure if I understand your answer correct, but am I right, that at least a switch from Wto VA is possible when complex numbers are used in conjunction with SIUnits?