|
1 | 1 | # assert file to test polynomial implementation
|
| 2 | +using Compat |
2 | 3 | using Base.Test
|
3 | 4 | using Polynomials
|
4 | 5 |
|
@@ -32,7 +33,7 @@ sprint(show, pNULL)
|
32 | 33 | @test pNULL^3 == pNULL
|
33 | 34 | @test pNULL*pNULL == pNULL
|
34 | 35 |
|
35 |
| -@test map(Polynomials.degree, [pNULL,p0,p1,p2,p3,p4,p5,pN,pR,p1000]) == [0,0,0,1,2,3,4,4,2,999] |
| 36 | +@test map(Polynomials.degree, [pNULL,p0,p1,p2,p3,p4,p5,pN,pR,p1000]) == [0,0,0,1,2,3,4,4,2,999] |
36 | 37 |
|
37 | 38 | @test polyval(pN, -.125) == 276.9609375
|
38 | 39 | @test polyval(pNULL, 10) == 0
|
@@ -95,26 +96,27 @@ pcpy2 = copy(pcpy1)
|
95 | 96 | #Tests for Pade approximants
|
96 | 97 |
|
97 | 98 | println("Test for the exponential function.")
|
98 |
| -a = Poly(1.//convert(Vector{Int},gamma(1:17)),"x") |
| 99 | +a = Poly(1.//convert(Vector{BigInt},gamma(BigFloat(1):BigFloat(17))),"x") |
99 | 100 | PQexp = Pade(a,8,8)
|
100 |
| -@test padeval(PQexp,1.0) == exp(1.0) |
101 |
| -@test padeval(PQexp,-1.0) == exp(-1.0) |
| 101 | +@test isapprox(convert(Float64, padeval(PQexp,1.0)), exp(1.0)) |
| 102 | +@test isapprox(convert(Float64, padeval(PQexp,-1.0)), exp(-1.0)) |
102 | 103 |
|
103 | 104 | println("Test for the sine function.")
|
104 |
| -b = Poly(convert(Vector{BigInt},sinpi((0:16)/2)).//convert(Vector{BigInt},gamma(BigFloat("1.0"):BigFloat("17.0"))),"x") |
| 105 | +b = Poly(convert(Vector{BigInt},sinpi((0:16)/2)).//convert(Vector{BigInt},gamma(BigFloat(1):BigFloat(17))),"x") |
105 | 106 | PQsin = Pade(b,8,7)
|
106 |
| -@test isapprox(padeval(PQsin,1.0),sin(1.0)) |
107 |
| -@test isapprox(padeval(PQsin,-1.0),sin(-1.0)) |
| 107 | +@test isapprox(convert(Float64, padeval(PQsin,1.0)), sin(1.0)) |
| 108 | +@test isapprox(convert(Float64, padeval(PQsin,-1.0)),sin(-1.0)) |
108 | 109 |
|
109 | 110 | println("Test for the cosine function.")
|
110 |
| -c = Poly(convert(Vector{BigInt},sinpi((1:17)/2)).//convert(Vector{BigInt},gamma(BigFloat("1.0"):BigFloat("17.0"))),"x") |
| 111 | +c = Poly(convert(Vector{BigInt},sinpi((1:17)/2)).//convert(Vector{BigInt},gamma(BigFloat(1):BigFloat(17))),"x") |
111 | 112 | PQcos = Pade(c,8,8)
|
112 |
| -@test isapprox(padeval(PQcos,1.0),cos(1.0)) |
113 |
| -@test isapprox(padeval(PQcos,-1.0),cos(-1.0)) |
| 113 | +@test isapprox(convert(Float64, padeval(PQcos,1.0)), cos(1.0)) |
| 114 | +@test isapprox(convert(Float64, padeval(PQcos,-1.0)), cos(-1.0)) |
114 | 115 |
|
115 | 116 | println("Test for the summation of a factorially divergent series.")
|
116 |
| -d = Poly(convert(Vector{BigInt},(-1).^(0:60).*gamma(BigFloat("1.0"):BigFloat("61.0"))).//1,"x") |
| 117 | +d = Poly(convert(Vector{BigInt},(-1).^(0:60).*gamma(BigFloat(1):BigFloat(61.0))).//1,"x") |
117 | 118 | PQexpint = Pade(d,30,30)
|
118 |
| -println("The approximate sum of the divergent series is: ",float64(padeval(PQexpint,1.0))) |
| 119 | +@compat println("The approximate sum of the divergent series is: ", Float64(padeval(PQexpint,1.0))) |
119 | 120 | println("The approximate sum of the convergent series is: ",exp(1)*(-γ-sum([(-1).^k/k./gamma(k+1) for k=1:20])))
|
120 |
| -@test isapprox(padeval(PQexpint,1.0) , exp(1)*(-γ-sum([(-1).^k/k./gamma(k+1) for k=1:20]))) |
| 121 | +@test isapprox(convert(Float64, padeval(PQexpint,1.0)), |
| 122 | + exp(1)*(-γ-sum([(-1).^k/k./gamma(k+1) for k=1:20]))) |
0 commit comments