@@ -12,7 +12,8 @@ export degree, coeffs, variable
12
12
export polyval, polyint, polyder, roots, polyfit
13
13
export Pade, padeval
14
14
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
16
17
import Base: show, print, * , / , // , - , + , == , isapprox, divrem, div, rem, eltype
17
18
import Base: promote_rule, truncate, chop, call, conj, transpose, dot, hash
18
19
import Base: isequal
@@ -110,15 +111,26 @@ convert{T, S<:Number}(::Type{Poly{T}}, x::AbstractArray{S}, var::SymbolLike=:x)
110
111
promote_rule {T, S} (:: Type{Poly{T}} , :: Type{Poly{S}} ) = Poly{promote_type (T, S)}
111
112
promote_rule {T, S<:Number} (:: Type{Poly{T}} , :: Type{S} ) = Poly{promote_type (T, S)}
112
113
eltype {T} (:: Poly{T} ) = T
113
- eltype {T} (:: Type{Poly{T}} ) = T
114
114
115
115
"""
116
116
117
- `legnth (p::Poly)`: return length of coefficient vector
117
+ `length (p::Poly)`: return length of coefficient vector
118
118
119
119
"""
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)
122
134
123
135
"""
124
136
0 commit comments