CN


In [19]:
import numpy as np

np.version
A = np.matrix([[1, 2, 3], [3, 4, 5]])
B = np.matrix([[3, 2, 1], [5, 4, 3]])

print('A:\n', A)
print('B:\n', B)

print('\nProperties:')
print('A - dimensions: ', A.shape)
print('A - no elements: ', np.prod(A.shape)) # same as A.size

print('\nOperations:')
print('A+B:\n', A+B)
print('A-B:\n', A-B)
B = np.matrix([[3, 2, 1, 0], [5, 4, 3, 0], [5, 4, 3, 0]])
print('A*B:\n', A.dot(B)) # (2, 3) * (3, 4) = (2, 4)


A:
 [[1 2 3]
 [3 4 5]]
B:
 [[3 2 1]
 [5 4 3]]

Properties:
A - dimensions:  (2, 3)
A - no elements:  6

Operations:
A+B:
 [[4 4 4]
 [8 8 8]]
A-B:
 [[-2  0  2]
 [-2  0  2]]
A*B:
 [[28 22 16  0]
 [54 42 30  0]]

In [ ]: