Matrix multiplication

351 days ago by alavem13

#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 10 08:44:18 2019 @author: AndreaTram """ import numpy as np A=np.array([[1, 4],[6,7]]) B=np.array([[8],[3]]) [ra,ca]=A.shape [rb,cb]=B.shape C=np.zeros((ra,cb)) for ii in range(0,ra): for jj in range(0,cb): for kk in range(0,ca): C[ii,jj]=C[ii,jj]+ A[ii,kk]*B[kk,jj] print('C matrix is='+str(C)) print(A @ B) 
Traceback (click to the left of this block for traceback)
SyntaxError: invalid syntax
Traceback (most recent call last):    """
  File "", line 1, in <module>
  File "/usr/local/sage-6.9/local/lib/python2.7/site-packages/sagenb-0.11.4-py2.7.egg/sagenb/misc/", line 438, in syseval
    return system.eval(cmd, sage_globals, locals = sage_globals)
  File "/usr/local/sage-6.9/local/lib/python2.7/site-packages/sage/misc/", line 60, in eval
    eval(compile(s, '', 'exec'), globals, globals)
  File "", line 30
    print(A @ B)
SyntaxError: invalid syntax