[Matrix-SIG] array_map?

Zaur Nart zaur.mail@usa.net
18 Apr 99 19:12:35 MSD


Using Numeric very often I need function like map which return array as result
(not list).

Now I must to write something like:

def array_map(func, A):
    shape = A.shape
    return reshape( array(map(func, reshape(A, (-1,)))), shape )

or use <for>. But this is a slow way :-(
Note: func is not builtin or trivial (simple).

It will be very nice to modify function map or write clone (in C or C++),
for example <array_map>
     array_map( func, array1, array2, ..., arrayn ),
which 
- detect the shape S of arrays 
  (let suppose, that arrays have the same shape);
- create array of shape S for result;
- organize the internal loop to apply user function to elements
of input arrays and put the value in result array.

Supposed, that we have user function:
     def func( a1, a2, ..., an ):
         .................

Zaur




 

____________________________________________________________________
Get free e-mail and a permanent address at http://www.netaddress.com/?N=1