Skip to content

Commit d84bb6a

Browse files
committed
Reduce unnecessary methods
1 parent 814fa7e commit d84bb6a

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

src/disambiguities.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ for type in (Signed, Float64, Float32, Rational), op in (:flipsign, :copysign)
5252
return $(op)(x, ustrip(y))
5353
end
5454
end
55+
function Base.:*(l::Complex, r::AbstractRealQuantity)
56+
new_quantity(typeof(r), l * ustrip(r), dimension(r))
57+
end
58+
function Base.:*(l::AbstractRealQuantity, r::Complex)
59+
new_quantity(typeof(l), ustrip(l) * r, dimension(l))
60+
end
61+
function Base.:/(l::Complex, r::AbstractRealQuantity)
62+
new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
63+
end
64+
function Base.:/(l::AbstractRealQuantity, r::Complex)
65+
new_quantity(typeof(l), ustrip(l) / r, dimension(l))
66+
end
5567
function Base.:*(l::Complex{Bool}, r::AbstractRealQuantity)
5668
return new_quantity(typeof(r), l * ustrip(r), dimension(r))
5769
end

src/math.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,6 @@ for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
5151
end
5252
end
5353

54-
# Complex multiplication
55-
for (type, _, _) in ABSTRACT_QUANTITY_TYPES
56-
@eval begin
57-
function Base.:*(l::Complex, r::$type)
58-
new_quantity(typeof(r), l * ustrip(r), dimension(r))
59-
end
60-
function Base.:*(l::$type, r::Complex)
61-
new_quantity(typeof(l), ustrip(l) * r, dimension(l))
62-
end
63-
function Base.:/(l::Complex, r::$type)
64-
new_quantity(typeof(r), l / ustrip(r), inv(dimension(r)))
65-
end
66-
function Base.:/(l::$type, r::Complex)
67-
new_quantity(typeof(l), ustrip(l) / r, dimension(l))
68-
end
69-
end
70-
end
71-
7254
Base.:*(l::AbstractDimensions, r::AbstractDimensions) = map_dimensions(+, l, r)
7355
Base.:/(l::AbstractDimensions, r::AbstractDimensions) = map_dimensions(-, l, r)
7456

0 commit comments

Comments
 (0)