• + 0 comments
    A = [[1,2],[2,3]]
    B = [[4,5],[7,8]]
    
    ROWS_A, COLS_A = len(A), len(A[0])
    ROWS_B, COLS_B = len(B), len(B[0])
    assert COLS_A == ROWS_B
    COMMON_D = ROWS_B
    
    # zeros for Rows-A x Cols-B
    M_TIMES = []
    for r in range(ROWS_A):
        M_TIMES.append( [0] * COLS_B )
    
    # Loop over Rows-A, then Cols-B, then the common dimension
    for rA in range(ROWS_A):
        for cB in range(COLS_B):
            for t in range(COMMON_D):
                M_TIMES[rA][cB] += A[rA][t]*B[t][cB]
            print(M_TIMES[rA][cB])