Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed Jun 8 11:00:09 CDT 2005

```Nils Wagner wrote:

> Hi all,
>
> Is it possible to use integrate.quadrature with respect to a function
> that
> returns a two-dimensional array ?
>
> from scipy import *
>
> l=0.1
>
> def h(zeta):
> #
> #  Shape functions
> #
>   tmp = zeros(4,Float)
>   tmp[0] = 1-3*zeta**2+2*zeta**3
>   tmp[1] = (-zeta+2*zeta**2-zeta**3)*l
>   tmp[2] = 3*zeta**2-2*zeta**3
>   tmp[3] = (zeta**2-zeta**3)*l
>   return tmp
>
> def hd(zeta):
>   tmp = zeros(4,Float)
>   tmp[0] = -6*zeta+6*zeta**2
>   tmp[1] = (-1+4*zeta-3*zeta**2)*l
>   tmp[2] = 6*zeta-6*zeta**2
>   tmp[3] = (2*zeta-3*zeta**2)*l
>   return tmp
>
> def hdd(zeta):
>   tmp = zeros(4,Float)
>   tmp[0] = -6+12*zeta
>   tmp[1] = (4-6*zeta)*l
>   tmp[2] = 6-12*zeta
>   tmp[3] = (2-6*zeta)*l
>   return tmp
>
> def func(zeta):
> #   print outerproduct(h(zeta),h(zeta))
>   return outerproduct(h(zeta),h(zeta))
>
> #
> # This version doesn't work
> #
>
>
> Nils
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user

The version below works fine, but I am quite sure that it can be improved.

Any pointer would be appreciated. :-)

Nils

def h(zeta):
#
#  Shape functions
#
tmp = zeros(4,Float)
tmp[0] = 1-3*zeta**2+2*zeta**3
tmp[1] = (-zeta+2*zeta**2-zeta**3)*l
tmp[2] = 3*zeta**2-2*zeta**3
tmp[3] = (zeta**2-zeta**3)*l
return tmp

def func(zeta,i,j):
h0 = h(zeta)
return h0[i]*h0[j]

for i in arange(0,4):
for j in arange(0,4):