mirror of
https://github.com/Visualize-ML/Book4_Power-of-Matrix.git
synced 2026-02-03 02:24:03 +08:00
25 lines
472 B
Python
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
|