Skip to content

Commit 57f1458

Browse files
committed
Merge pull request #20 from pjabardo/copyvar
Bug when copying
2 parents 6b65f47 + 41c6d5c commit 57f1458

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Polynomials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function setindex!(p::Poly, v, i)
4141
v
4242
end
4343

44-
copy(p::Poly) = Poly(copy(p.a))
44+
copy(p::Poly) = Poly(copy(p.a), p.var)
4545

4646
zero{T}(p::Poly{T}) = zero(Poly{T})
4747
zero{T}(::Type{Poly{T}}) = Poly(T[])

test/tests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ pS3 = Poly([1, 2, 3, 4, 5], :s)
8787
@test_throws ErrorException pS1 / pX
8888
@test_throws ErrorException pS1 % pX
8989

90+
#Testing copying.
91+
pcpy1 = Poly([1,2,3,4,5], :y)
92+
pcpy2 = copy(pcpy1)
93+
@test pcpy1 == pcpy2
94+
9095
#Tests for Pade approximants
9196

9297
println("Test for the exponential function.")
@@ -112,4 +117,4 @@ d = Poly(convert(Vector{BigInt},(-1).^(0:60).*gamma(BigFloat("1.0"):BigFloat("61
112117
PQexpint = Pade(d,30,30)
113118
println("The approximate sum of the divergent series is: ",float64(padeval(PQexpint,1.0)))
114119
println("The approximate sum of the convergent series is: ",exp(1)*(-γ-sum([(-1).^k/k./gamma(k+1) for k=1:20])))
115-
@test isapprox(padeval(PQexpint,1.0) , 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])))

0 commit comments

Comments
 (0)