logo       

RE: Using sum() within a function: msg#00041

python.numeric.general

Subject: RE: Using sum() within a function

Jim Cser wrote:
>
> Instead, I'm trying to do something like--
> def f3(x,y,z):
> for t in range(numT):
> tempval = f1(x,y,z,t) * f2(y,z,t)
>
> outval = sum(tempval,axis = 3)
> return outval
>
Perhaps I'm confused but it seems to me the for loop is wrong.

Don't you want something like:

def f3(x,y,z):
tempval = 0.*x
for t in range(numT):
tempval += f1(x,y,z,t) * f2(y,z,t)
return tempval

Instead?

Not that I've tried this, but so long as the function will
work given 3-d arrays for x,y,z, it should. (though the dependence
on numT as a global is a bit worrisome)

Perry GReenfield



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise