[SciPy-user] Help with array functions

Bob.Cowdery at CGI-Europe.com Bob.Cowdery at CGI-Europe.com
Tue May 4 10:36:16 CDT 2004

Eric Jones wrote:
> Bob.Cowdery at CGI-Europe.com wrote:
> The general ideas of uisng Numeric in Python is to avoid loops, even 
> at
> the expense of sometimes doing extra computations.  In this case, the 
> signal processing calculations can be done for every entry in the array 
> (except the first).  The conditions checked for in the "if" statements 
> can then be filtered out in subsequent array processing steps.
> Here is some (totally untested) code that should give you some ideas:
>     gain = self.m_procGain
>     abs_complexout = abs(self.m_complexout)
>     # Do singal processing calculation for all elements in array
>     gain[1:] = ( (gain[:-1] * (1 - attack)) +
>                  ((attack * peak) / abs_complexout[:-1]) )

Perry Greenfield wrote: 
> Does this do what is needed? I think the point he was making was that
gain[i] depends on gain[i-1] which in turn depends on gain[i-2] 
> and so on. The expression above doesn't capture that since from his code
he doesn't show any initial value for gain (implicitly the 
> gain[0] must exist). So using an array expression which uses a shifted
gain array in its input won't work. 

> This is the sort of problem that doesn't fit the array model very well
unless there are some primitive array operations that happen to > do the
iterative thing needed (sometimes the accumulate or convolve functions can
be used for this thing, but I can't see any obvious 
> existing function. Seems like a candidate for a C extension but maybe I'm
> something.

That is correct, my basic problem was how to use the same array in input and
output which I guess I should have mentioned. The gain array is initialised
to zeros.

SciPy-user mailing list
SciPy-user at scipy.net http://www.scipy.net/mailman/listinfo/scipy-user

*** Confidentiality Notice *** Proprietary/Confidential
Information belonging to CGI Group Inc. and its affiliates
may be contained in this message. If you are not a recipient
indicated or intended in this message (or responsible for
delivery of this message to such person), or you think for
any reason that this message may have been addressed to you
in error, you may not use or copy or deliver this message
to anyone else.  In such case, you should destroy this
message and are asked to notify the sender by reply email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.scipy.net/pipermail/scipy-user/attachments/20040504/da287b2f/attachment.htm

More information about the SciPy-user mailing list