vtjnash / Polynomial.jl

Polynomial manipulations
Other
6 stars 10 forks source link

The poly function does not handle complex roots #22

Closed my-little-repository closed 10 years ago

my-little-repository commented 10 years ago

The poly function, that rebuilds a polynomial from its roots, does not handle complex roots.

julia> poly(roots(Poly([1,0,-1]))) # x^2-1 Poly(1.0x^2 + -1.0)

julia> poly(roots(Poly([1,0,1]))) # x^2+1 ERROR: no method isless(Complex{Float64}, Float64) in Poly at /home/yves/.julia/Polynomial/src/Polynomial.jl:21 in poly at /home/yves/.julia/Polynomial/src/Polynomial.jl:274

my-little-repository commented 10 years ago

In fact I get an error if I try to create a polynomial with complex coefficients using the Poly function. It used to work, but now I have upgraded to the head version and something seems broken.

I guess that's because in the definition of the immutable type Poly, there is a test eps(T) on the type T of the coefficients, but eps only handles floating-points types.

julia> Poly([1+0.0_im,0.0_im]) ERROR: no method isless(Complex{Float64}, Float64) in Poly at /home/yves/.julia/Polynomial/src/Polynomial.jl:21 in Poly at /home/yves/.julia/Polynomial/src/Polynomial.jl:30

vtjnash commented 10 years ago

will be fixed by #20