----- Original Message ----- 
From: "Kyle Schalm" <[EMAIL PROTECTED]>
>
> here is a matrix constructor i would like to see:
>
> Matrix(M, N, f):
>   for i in range(1,M+1):
>     for j in range(1,N+1):
>       self[i][j] = f(i,j)   # or whatever the syntax is
>
>
> i might use it like this:
>
> A = Matrix(3, 3, lambda i,j: i+j)

In numpy, there is a similar construction for arrays (starting from 0),

fromfunction(f, (m,n))

It works rather slow for large arrays though (because f is evaluated in 
Python).

Alec 



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to