Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unless I'm misunderstanding your question (which is a bit ambiguous what does mean "with entries a function of k" ?), this should do :

sage: def myfunc(k): return floor(k*random())
sage: def make_4xk_matrix(k):
....:     return matrix(ZZ,[[myfunc(k) for t in (1..k)] for l in (1..4)])
....: 
sage: make_4xk_matrix(6)
[1 5 3 3 4 3]
[5 2 3 3 2 3]
[2 3 1 3 3 3]
[0 2 3 2 1 5]

Note that the entries belong to $\mathbb{Z}$ : $\mathbb{N}$ is not a ring and Sage's matrix refuses it.