[PYTHON MATRIX-SIG] Applying a general function to an array
Konrad HINSEN
hinsenk@ere.umontreal.ca
Thu, 22 Feb 1996 13:24:27 -0500
Is it possible to apply a general python function (that takes one
input and produces one output to an array? For example, I'd like to
have a python function (implemented in C), "y = f(x)" and then be able
to say Y = f(X) and get Y set to an array where each element in Y is f
applied to the corresponding element in X.
There is no real support for this right now. It has to be added, and I
am trying to make such things part of my function set proposal
(progressingly slowly due to lots of other work). If your function f
is written in terms of functions from umath, then it should work
automatically, but in the case of a C function or a more complicated
Python function (with tests, loops, etc.), you have no other way than
to write explicit for-loops or some messy map() application.
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal | Fax: +1-514-343-7586
C.P. 6128, succ. Centre-Ville | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7 | Francais (phase experimentale)
-------------------------------------------------------------------------------
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================