ggebbie / UnitfulLinearAlgebra.jl

Low-cost linear algebra functions for matrices with units
MIT License
6 stars 3 forks source link

77 diag for a permil matrix multiplies in the permils and returns a unitless quantity #80

Closed ggebbie closed 1 year ago

ggebbie commented 1 year ago

diag updated to distinguish between unitless and dimensionless

may be worthwhile to use permil = Unitful.FixedUnits(u"permille") so that K*permil doesn't get promoted/reduced to K

julia> using Unitful, UnitfulLinearAlgebra, LinearAlgebra

julia> permil = Unitful.FixedUnits(u"permille")
‰

julia> K = u"K"
K

julia> mat = UnitfulMatrix(ones(2,2)*permil*K)
2×2 UnitfulMatrix{Float64,2}
 1.0 K ‰  1.0 K ‰
 1.0 K ‰  1.0 K ‰

julia> diag(mat)
2-element Vector{Quantity}:
 1.0 K ‰
 1.0 K ‰