You can always use list comprehension

sage: matrix(5,5,[1000*i+j for i in range(5) for j in range(5)])
[   0    1    2    3    4]
[1000 1001 1002 1003 1004]
[2000 2001 2002 2003 2004]
[3000 3001 3002 3003 3004]
[4000 4001 4002 4003 4004]


On Feb 13, 2007, at 10:11 PM, Kyle Schalm wrote:

> 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)
>
> i'd do it myself, but i don't have a development environment set up,
> and don't wanna do that right now.
>
> cheers,
> kyle
>
>
> 

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
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