Skip to content

Commit 8d9f109

Browse files
committed
Added new convert functions
1 parent 3a01738 commit 8d9f109

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Polynomials.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ end
2323
Poly{T<:Number}(a::Vector{T}, var::Union(String,Symbol,Char)=:x) = Poly{T}(a, var)
2424

2525
convert{T}(::Type{Poly{T}}, p::Poly) = Poly(convert(Vector{T}, p.a), p.var)
26+
convert{T, S<:Number}(::Type{Poly{T}}, x::S) = Poly(promote_type(T, S)[x])
27+
convert{T, S<:Number,n}(::Type{Poly{T}}, x::Array{S,n}) = map(el->convert(Poly{promote_type(T,S)},el),x)
2628
promote_rule{T, S}(::Type{Poly{T}}, ::Type{Poly{S}}) = Poly{promote_type(T, S)}
2729
eltype{T}(::Poly{T}) = T
2830

0 commit comments

Comments
 (0)