Ask Your Question

Revision history [back]

Matrix product simple case

Hi,

I am new to sage and I was trying to write a short program for matrix multiplication .

here is my program

def Produit(A,B): n=A.nrows() C=matrix(n,n) for i in [0..n-1]: for j in [0..n-1]: for k in [0..n-1]: C[i,j]=C[i,j]+A[i,k]*B[k,j] return C

When I try to ran it , I receive an error message

TypeError: no conversion of this rational to integer

Matrix product simple case

Hi,

I am new to sage and I was trying to write a short program for matrix multiplication .

here is my program

def Produit(A,B):
    n=A.nrows()
    C=matrix(n,n)
    for i in [0..n-1]:
        for j in [0..n-1]:
            for k in [0..n-1]:
                C[i,j]=C[i,j]+A[i,k]*B[k,j]
    return C

C

When I try to ran it , I receive an error message

TypeError: no conversion of this rational to integer