[PYTHON MATRIX-SIG] Speed...cg...and more!
Mon, 13 Nov 1995 15:40:36 +0100
Sorry for the typos in my last message. Here are some other things I forgot
1) What about a Matrix constructor which can use constant values and
functions for initailising.
from math import *
from Matrix import *
f=lambda i, j: sin(i)*cos(j)
a=Matrix(1000,1000, func=f) #square 1000x1000 matrix
b=a=Matrix_d(10,10,10, func=lambda i, j, k: sin(i)*cos(j)*exp(k)
If we do that in the standard way it will not be fast enough. I nearly
have this problem when using some procedure which need functions as input.
I C-code it's no problem at all and after introducing it in python it's
just to slow (e.g. minimize a function...). Imagine that the function is
evaluated 100000 times! What to do. If we could compile simple functions
on the fly this would be just fine. Not a general Python Compiler, but
just a tiny one for certain things.
Other possibility: Dynamic loading (not really acceptable for such things
(interactivity is lost a little bit)
Or write some new module for that type of work (Some Parser thigs!)
The above example would go as
or Matrix(1000,1000, "i,j->sin(i)*cos(j)")
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org