Skip to content

Commit 210474a

Browse files
author
Arda Aytekin
committed
Implement eltype for Poly **types**
Implemented `eltype` for `Poly` **types** and added tests. Fixes #67.
1 parent 9b2c873 commit 210474a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Polynomials.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ convert{T, S<:Number,n}(::Type{Poly{T}}, x::Array{S,n}) = map(el->convert(Poly{p
115115
promote_rule{T, S}(::Type{Poly{T}}, ::Type{Poly{S}}) = Poly{promote_type(T, S)}
116116
promote_rule{T, S<:Number}(::Type{Poly{T}}, ::Type{S}) = Poly{promote_type(T, S)}
117117
eltype{T}(::Poly{T}) = T
118+
eltype{T}(::Type{Poly{T}}) = T
118119

119120
"""
120121

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,9 @@ p1 = Poly([1,2])
196196
p2 = convert(Poly{Int64}, p1)
197197
p2[3] = 3
198198
@test p1[3] == 3
199+
200+
## eltype of a Poly type
201+
types = [Int, UInt8, Float64]
202+
for t in types
203+
@test t == eltype(Poly{t})
204+
end

0 commit comments

Comments
 (0)