> def U(N,M):
>    U=matrix(ZZ,N*M)
>    for i in range(N*M):
>        for j in range(N*M):
>            U[i,j]=1
>    return U
> def Q(N,M):
>    Q=matrix(ZZ,N*M)
>    for i in range(N*M):
>        for j in range(N*M):
>            Q[i,j]=U(N,M)
>    return Q

U(N,M) is a function which returns a matrix.  The line Q[i,j]=U(N,M)
attempts to set the (i,j)-th entry of the Q matrix, defined over ZZ,
to an NxM matrix, which isn't going to work.  (Hence the "cannot
coerce a matrix to an integer" error message -- it's trying to fit
U(N,M) into an entry of Q, and it can't figure out how to do it.)

BTW, you might also be interested in the command ones_matrix:

sage: ones_matrix(ZZ,3,4)
[1 1 1 1]
[1 1 1 1]
[1 1 1 1]


Doug

-- 
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-support
URL: http://www.sagemath.org

Reply via email to