[SciPy-user] Help with array functions
eric jones
eric at enthought.com
Tue May 4 10:39:45 CDT 2004
Yikes. Your right!
eric
Perry Greenfield wrote:
>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]) )
>>
>>
>>
>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 missing
>something.
>
>Perry
>
>
>
>_______________________________________________
>SciPy-user mailing list
>SciPy-user at scipy.net
>http://www.scipy.net/mailman/listinfo/scipy-user
>
>
More information about the SciPy-user
mailing list