@@ -12,7 +12,8 @@ export degree, coeffs, variable
1212export polyval, polyint, polyder, roots, polyfit
1313export Pade, padeval
1414
15- import Base: length, endof, getindex, setindex!, copy, zero, one, convert, norm, gcd
15+ import Base: start, next, done, length, size, eltype
16+ import Base: endof, getindex, setindex!, copy, zero, one, convert, norm, gcd
1617import Base: show, print, * , / , // , - , + , == , isapprox, divrem, div, rem, eltype
1718import Base: promote_rule, truncate, chop, call, conj, transpose, dot, hash
1819import Base: isequal
@@ -110,15 +111,26 @@ convert{T, S<:Number}(::Type{Poly{T}}, x::AbstractArray{S}, var::SymbolLike=:x)
110111promote_rule {T, S} (:: Type{Poly{T}} , :: Type{Poly{S}} ) = Poly{promote_type (T, S)}
111112promote_rule {T, S<:Number} (:: Type{Poly{T}} , :: Type{S} ) = Poly{promote_type (T, S)}
112113eltype {T} (:: Poly{T} ) = T
113- eltype {T} (:: Type{Poly{T}} ) = T
114114
115115"""
116116
117- `legnth (p::Poly)`: return length of coefficient vector
117+ `length (p::Poly)`: return length of coefficient vector
118118
119119"""
120- length (p:: Poly ) = length (p. a)
121- endof (p:: Poly ) = length (p) - 1
120+ length (p:: Poly ) = length (coeffs (p))
121+ endof (p:: Poly ) = length (p) - 1
122+
123+ start (p:: Poly ) = start (coeffs (p)) - 1
124+ next (p:: Poly , state) = (temp = zeros (coeffs (p)); temp[state+ 1 ] = p[state]; (Poly (temp), state+ 1 ))
125+ done (p:: Poly , state) = state > degree (p)
126+ eltype {T} (:: Type{Poly{T}} ) = Poly{T}
127+ """
128+
129+ `size(p::Poly)`: return size of coefficient vector
130+
131+ """
132+ size (p:: Poly ) = size (p. a)
133+ size (p:: Poly , i:: Integer ) = size (p. a, i)
122134
123135"""
124136
0 commit comments