Skip to content

Commit fefdee4

Browse files
lrnvtansongchen
authored andcommitted
Adding convenient promotions
1 parent b145f17 commit fefdee4

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/primitive.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ end
113113
ex = :($ex; TaylorScalar($([Symbol('v', i) for i in 1:N]...)))
114114
return :(@inbounds $ex)
115115
end
116+
@inline *(a::TaylorScalar{T1, N}, b::TaylorScalar{T2, N}) where {T1,T2,N} = *(promote(a,b)...)
117+
@inline /(a::TaylorScalar{T1, N}, b::TaylorScalar{T2, N}) where {T1,T2,N} = *(promote(a,b)...)
116118

117119
for R in (Integer, Real)
118120
@eval @generated function ^(t::TaylorScalar{T, N}, n::S) where {S <: $R, T, N}

src/scalar.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ function promote_rule(::Type{TaylorScalar{T, N}},
8989
::Type{S}) where {T, S, N}
9090
TaylorScalar{promote_type(T, S), N}
9191
end
92+
function promote_rule(::Type{TaylorScalar{T1, N}}, ::Type{TaylorScalar{T2,N}}) where {T1, T2, N}
93+
TaylorScalar{promote_type(T1,T2), N}
94+
end
9295

9396
function (::Type{F})(x::TaylorScalar{T, N}) where {T, N, F <: AbstractFloat}
9497
F(primal(x))

0 commit comments

Comments
 (0)