Is there a \ operator for Unitful?

FelixHeox
Tue, 27 Dec 2022 19:19:05 +0000
New to Julia

I was running into a problem using the \ (linear system solver) operator in Julia. I guess I wrongly assumed the \ operator was overloaded for matrices/vectors with entries of type <: Number (witch unitful types are). Is there any way to easily overload the \ operator to accept unitful types, or perhaps a different operator/function that works for all types that are subtypes of Number (since I plan on using Sym and Float/Integer types in my code as well)

Environment: Pluto on MacOS
Packages: Unitful, Sympy, Plots, PlutoUI
Code:

let
	a11 = 1u"m"
	a12 = 2u"ft"
	a21 = 5u"mm"
	a22 = 0u"inch"
	A = [a11 a12; a21 a22]
	b = [3u"inch"; 1u"mm"]
	x  = A \ b # This line throws error
end

Error:
MethodError: no method matching (Unitful.Quantity{Rational{Int64}})(::Rational{Int64})

7 posts - 4 participants