vtjnash / Polynomial.jl

Polynomial manipulations
Other
6 stars 10 forks source link

User zero instead of convert? #26

Closed andrewcooke closed 10 years ago

andrewcooke commented 10 years ago

Hi, In your definition of eps() for non-floats, could you use zero(T) instead of convert(T,0)? I'd like to use your module, but am not sure I want to support arbitrary conversions from integers - I do, however, have zero instances. Thanks.

andrewcooke commented 10 years ago

If not I guess I can define my own eps, so it's no biggie.

vtjnash commented 10 years ago

Defining your own Polynomial.eps function is also an option, if you don't like the default option of zero.

andrewcooke commented 10 years ago

thanks!

vtjnash commented 10 years ago

thanks for the bug report. i had a little trouble with this too, but couldn't think of the right solution (yours) at the time

andrewcooke commented 10 years ago

I ended up supporting conversion (because otherwise x^2 +1 doesn't work - I am trying to simplify expression of polynomials as you described in julia-users). But I think that if you wanted to be completely consistent then you'd also need to modify the literal integers in show() (ie replace 1 with one() etc) and even change the "2" in 2*eps(...) to be two = one(T) + one(T).

But I'm starting to think that any practical Number subtype is going to have to include convert() so I doubt this is important.