[SciPy-dev] Generic polynomials class (was Re: Volunteer for Scipy Project)
Thu Oct 8 14:06:12 CDT 2009
2009/10/8 Charles R Harris <email@example.com>:
> On Thu, Oct 8, 2009 at 10:29 AM, Charles R Harris
> <firstname.lastname@example.org> wrote:
>> Hi Anne,
>> On Thu, Oct 8, 2009 at 9:37 AM, Anne Archibald <email@example.com>
>>> 2009/10/7 David Goldsmith <firstname.lastname@example.org>:
>>> > Thanks for doing that, Anne!
>>> There is now a rough prototype on github:
>>> It certainly needs more tests and features, but it does support both
>>> the power basis and the Lagrange basis (polynomials represented by
>>> values at Chebyshev points).
>> Just took a quick look, which is probably all I'll get to for a few days
>> as I'm going out of town tomorrow. Anyway, the Chebyshev points there are
>> type II, which should probably be distinguished from type I (and III & IV).
>> I also had the impression that the base class could have a few more
>> functions and NotImplemented bits. The Polynomial class is implemented as a
>> wrapper, it might even make sense to use multiple inheritance (horrors) to
>> get specific polynomial types, but anyway it caught my attention and that
>> part of the design might be worth spending some time thinking about. It also
>> might be worth distinguishing series as a separate base because series do
>> admit the division operators //, %, and divmod. Scalar
>> multiplication/division (__truedivision__) should also be built in. I've
>> also been using "from __future__ import division" up at the top to be py3k
>> ready. For a series basis I was thinking of using what I've got for
>> Chebyshev but with a bunch of the __foo__ functions raising the
>> NotImplementedError. I've also got a single function for importing the
>> coefficient arrays and doing the type conversions/checking. It's worth doing
>> that one way for all the implementations as it makes it easier to fix/extend
>> I've attached the low->high version of the chebyshev.py file just for
>> further reference. The Chebyshev class is at the end.
> Oh, and one other thing. I'm thinking that there should be *no* true inplace
> functions. That is, every operation returns a new object. That way the
> various classes look like basic, immutable, types which makes life simpler
> and less error prone. No views with side effects to worry about, and the
> coefficient arrays are likely to be small enough that the overhead to make
> copies will be small.
I agree; both polynomials and bases should be apparently immutable. I
say apparently because a certain amount of caching/precalculation can
speed some things up; I've already got this in the LagrangeBasis
class, where it caches the Chebyshev points it uses.
More information about the Scipy-dev