# [SciPy-dev] Generic polynomials class (was Re: Volunteer for Scipy Project)

Charles R Harris charlesr.harris@gmail....
Thu Oct 15 17:28:42 CDT 2009

```On Thu, Oct 15, 2009 at 2:54 PM, Anne Archibald
<peridot.faceted@gmail.com>wrote:

> 2009/10/15 Charles R Harris <charlesr.harris@gmail.com>:
>
> > I think it would be interesting to see an implementation restricted to
> > Lagrange basis only and as simple as you could make it.
>
> See the branch lagrangeonly in git. The simplification is not that
> great, since Lagrange polynomials really need a Basis object to keep
> the list of points they're defined on around. I'd also hope that there
> was some way to identify all polynomial objects, since (for example) a
> Lagrange polynomial can be multiplied with a polynomial in any
> representation to give another Lagrange polynomial...
>
>
OK. I've also attached a "both a dessert topping and a floor wax" version of
things that I tried out to see what it looked like. Like your earlier
proposal, the standalone functions are @staticmethods of a base class
(roughly equivalent to your Bases), and a new class that inherits from the
base class is then generated using a common template for the derived class.
The resulting class contains both the standalone functions, which can be
called from the class object itself, and the syntactic sugar for the class
instances, i.e.,

In [3]: from polycheb import *

In [4]: a = Chebyshev([1,2,3])

In [5]: a + a
Out[5]: Chebyshev(array([ 2.,  4.,  6.]), [-1, 1])

Out[6]: array([ 2.,  4.,  6.])

In [7]: type(a)
Out[7]: <class 'polycheb.Chebyshev'>

It's something of a curiosity and I don't claim it is bug free, it is the
result of a bit of quick and dirty editing.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20091015/48f8c478/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polytemplate.py
Type: application/x-python
Size: 11040 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-dev/attachments/20091015/48f8c478/attachment-0002.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polycheb.py
Type: application/x-python
Size: 29017 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-dev/attachments/20091015/48f8c478/attachment-0003.bin
```