Skip to content

Commit 6b56fa2

Browse files
committed
Merge branch 'master' of git://github.com/Keno/Polynomials.jl
2 parents 046c6e6 + 6903171 commit 6b56fa2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Polynomials.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Poly type manipulations
22

3-
__precompile__()
3+
isdefined(Base, :__precompile__) && __precompile__()
44

55
module Polynomials
66
#todo: sparse polynomials?
@@ -108,6 +108,7 @@ poly(A::Matrix, var::Char) = poly(eig(A)[1], @compat Symbol(var))
108108

109109
include("show.jl") # display polynomials.
110110

111+
convert{T}(::Type{Poly{T}}, p::Poly{T}) = p
111112
convert{T}(::Type{Poly{T}}, p::Poly) = Poly(convert(Vector{T}, p.a), p.var)
112113
convert{T, S<:Number}(::Type{Poly{T}}, x::S) = Poly(promote_type(T, S)[x])
113114
convert{T, S<:Number,n}(::Type{Poly{T}}, x::Array{S,n}) = map(el->convert(Poly{promote_type(T,S)},el),x)

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,9 @@ as = [im, 1, 2]
190190
bs = [1, 1, 2]
191191
@test conj(Poly(as)) == Poly(conj(as))
192192
@test conj(Poly(bs)) == Poly(conj(bs))
193+
194+
## unnecessary copy in convert #65
195+
p1 = Poly([1,2])
196+
p2 = convert(Poly{Int64}, p1)
197+
p2[3] = 3
198+
@test p1[3] == 3

0 commit comments

Comments
 (0)