Skip to content

Commit

Permalink
Merge c180a37 into 3d1b48a
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenet committed Feb 14, 2020
2 parents 3d1b48a + c180a37 commit ca15e1d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Expand Up @@ -13,15 +13,13 @@ julia:
notifications:
email: false

matrix:
allow_failures:
- julia: nightly

env:
global:
- DOCUMENTER_DEBUG=true

jobs:
matrix:
allow_failures:
- julia: nightly
include:
- stage: "Documentation"
julia: 1.1
Expand Down
13 changes: 10 additions & 3 deletions src/evaluate.jl
Expand Up @@ -22,7 +22,7 @@ function evaluate(a::Taylor1{T}, dx::T) where {T<:Number}
suma
end
function evaluate(a::Taylor1{T}, dx::S) where {T<:Number, S<:Number}
suma = promote(a[end], dx)[1]
suma = a[end]*one(dx)
@inbounds for k in a.order-1:-1:0
suma = suma*dx + a[k]
end
Expand Down Expand Up @@ -83,15 +83,22 @@ function evaluate(a::Taylor1{T}, x::Taylor1{T}) where {T<:Number}
if a.order != x.order
a, x = fixorder(a, x)
end
@inbounds suma = a[end]
@inbounds suma = a[end]*one(x)
@inbounds for k = a.order-1:-1:0
suma = suma*x + a[k]
end
suma
end

function evaluate(a::Taylor1{Taylor1{T}}, x::Taylor1{T}) where {T<:Number}
@inbounds suma = a[end]
@inbounds suma = a[end]*one(x)
@inbounds for k = a.order-1:-1:0
suma = suma*x + a[k]
end
suma
end
function evaluate(a::Taylor1{T}, x::Taylor1{Taylor1{T}}) where {T<:Number}
@inbounds suma = a[end]*one(x)
@inbounds for k = a.order-1:-1:0
suma = suma*x + a[k]
end
Expand Down
4 changes: 4 additions & 0 deletions test/mixtures.jl
Expand Up @@ -288,4 +288,8 @@ end
@test ti * to == Taylor1([zero(ti), ti], 10)
@test ti^2-to^2 == (ti+to)*(ti-to)
@test sin(to) Taylor1(one(ti) .* sin(Taylor1(10)).coeffs, 10)
@test to(1 + ti) == 1 + ti
@test to(1 + ti) isa Taylor1{Float64}
@test ti(1 + to) == 1 + to
@test ti(1 + to) isa Taylor1{Taylor1{Float64}}
end
15 changes: 11 additions & 4 deletions test/onevariable.jl
Expand Up @@ -229,6 +229,8 @@ eeuler = Base.MathConstants.e
@test evaluate(exp(Taylor1([0,1],17)),1.0) == 1.0*eeuler
@test evaluate(exp(Taylor1([0,1],1))) == 1.0
@test evaluate(exp(t),t^2) == exp(t^2)
@test evaluate(exp(Taylor1(BigFloat, 15)), t^2) == exp(Taylor1(BigFloat, 15)^2)
@test evaluate(exp(Taylor1(BigFloat, 15)), t^2) isa Taylor1{BigFloat}
#Test function-like behavior for Taylor1s
t17 = Taylor1([0,1],17)
myexpfun = exp(t17)
Expand Down Expand Up @@ -257,14 +259,15 @@ eeuler = Base.MathConstants.e
@test a.() == evaluate.([p, q])
@test a.() == [p(), q()]
@test a.() == a()
@test view(a, 1:1)() == [a[1]()]
vr = rand(2)
@test p.(vr) == evaluate.([p], vr)
Mr = rand(3,3,3)
@test p.(Mr) == evaluate.([p], Mr)
mytaylor1 = Taylor1(rand(20))
vr = rand(5)
@test p(vr) == p.(vr)
@test p(vr) == evaluate.([p],vr)
@test view(a, 1:1)(vr) == evaluate.([p],vr)
@test p(Mr) == p.(Mr)
@test p(Mr) == evaluate.([p], Mr)
taylor_a = Taylor1(Int,10)
Expand Down Expand Up @@ -374,6 +377,10 @@ eeuler = Base.MathConstants.e
vv = Vector{Float64}(undef, 2)
@test evaluate!(v, zero(Int), vv) == nothing
@test vv == [0.0,1.0]
@test evaluate!(v, 0.0, vv) == nothing
@test vv == [0.0,1.0]
@test evaluate!(v, 0.0, view(vv, 1:2)) == nothing
@test vv == [0.0,1.0]
@test evaluate(v) == vv
@test evaluate(v, complex(0.0,0.2)) ==
[complex(0.0,sinh(0.2)),complex(cos(0.2),sin(-0.2))]
Expand Down Expand Up @@ -479,9 +486,9 @@ eeuler = Base.MathConstants.e
@test t t+sqrt(eps())
@test isapprox(p, q, atol=eps())

t = Taylor1(35)
@test Taylor1([180.0, rad2deg(1.0)], 35) == rad2deg(pi+t)
@test sin(pi/2+deg2rad(1.0)t) == sin(deg2rad(90+t))
tf = Taylor1(35)
@test Taylor1([180.0, rad2deg(1.0)], 35) == rad2deg(pi+tf)
@test sin(pi/2+deg2rad(1.0)tf) == sin(deg2rad(90+tf))
a = Taylor1(rand(10))
b = Taylor1(rand(10))
c = deepcopy(a)
Expand Down

0 comments on commit ca15e1d

Please sign in to comment.