Files
Book4_Power-of-Matrix/Book4_Ch04_Python_Codes/Bk4_Ch4_03.py
2022-07-15 06:07:14 -04:00

25 lines
472 B
Python

###############
# Authored by Weisheng Jiang
# Book 4 | From Basic Arithmetic to Machine Learning
# Published and copyrighted by Tsinghua University Press
# Beijing, China, 2022
###############
# Bk4_Ch4_03.py
import numpy as np
# define matrix
A = np.matrix([[1, 2], [3, 4]])
B = np.matrix([[2, 6], [4, 8]])
# matrix addition
A_plus_B = np.add(A,B)
A_plus_B_2 = A + B
# matrix subtraction
A_minus_B = np.subtract(A,B)
A_minus_B_2 = A - B