[SciPy-user] Associated legendre functions

Gary Ruben gruben@bigpond.net...
Tue Oct 9 08:13:41 CDT 2007


There's probably a better way than this, but you can use vectorize by 
creating an object array thus:

--

In [25]: import scipy.special as sp

In [26]: v=vectorize(sp.lpmn,otypes='O')

In [27]: a=v(0,1,[0,1,2])

In [28]: a
Out[28]: (array([[[ 1.  0.]], [[ 1.  1.]], [[ 1.  2.]]], dtype=object),)

In [29]: a[0]
Out[29]: array([[[ 1.  0.]], [[ 1.  1.]], [[ 1.  2.]]], dtype=object)

In [30]: a[0][0]
Out[30]: array([[ 1.,  0.]])

--
Gary R.

Lars Friedrich wrote:
> Hello,
> 
> I would like to compute the values of associated lengendre functions. I 
> found scipy.special.lpmn which can be used for this purpose. However, it 
> is not possible to pass numpy-arrays for the function argument z. What 
> is the recommended way to deal with this? I could do a for loop, but I 
> guess this would be slow. Are there other implementations available?
> 
> Thanks,
> 
> Lars



More information about the SciPy-user mailing list