Is it possible to make an entry in Q[i,j] equal to a entry in U[i,j]?
I have to have the two functions separately for each matrix though
just like my code above
i.e.

def U(N,M):
...
...
...
return U
def Q(N,M)
...
...
...
    Q[i,j]=U(N,M)
return Q

Kind Regards
Chappman



On Dec 3, 4:26 am, "D. S. McNeil" <dsm...@gmail.com> wrote:
> > 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 sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to