Skip to content

Commit

Permalink
Add specific cases depending on the power to pow!
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Benet committed Aug 24, 2017
1 parent 937ae12 commit f97223f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ coefficient of `a`.
"""
@inline function pow!{S<:Real}(c::Taylor1, a::Taylor1, r::S, k::Int, l0::Int=0)
if r == 0
return one!(c, a, k)
elseif r == 1
return identity!(c, a, k)
elseif r == 2
return sqr!(c, a, k)
elseif r == 0.5
return sqrt!(c, a, k)
end

if k == l0
@inbounds c[1] = ( a[l0+1] )^r
return nothing
Expand All @@ -147,6 +157,16 @@ coefficient of `a`.
end

@inline function pow!{S<:Real}(c::TaylorN, a::TaylorN, r::S, k::Int)
if r == 0
return one!(c, a, k)
elseif r == 1
return identity!(c, a, k)
elseif r == 2
return sqr!(c, a, k)
elseif r == 0.5
return sqrt!(c, a, k)
end

if k == 0
@inbounds c[1] = ( constant_term(a) )^r
return nothing
Expand Down

0 comments on commit f97223f

Please sign in to comment.