标签:begin end color 科学计算 lightgrey 012 bmatrix NumPy red
一、定义数组
import numpy as np
A = np.array([[4,2,3],[1,3,1]])
B = np.array([[2,7],[-5,-7],[9,3]])
print("【矩阵A】\n",A)
print("【矩阵B】\n",B)
【矩阵A】
[[4 2 3]
[1 3 1]]
【矩阵B】
[[ 2 7]
[-5 -7]
[ 9 3]]
二、点乘np.dot(A,B)
1、矩阵A最后一维
= 矩阵B第一维
\[{\begin{bmatrix}
\color{red}{4}&\color{red}{2}&\color{red}{3}\\
{1}&{3}&{1}\\
\end{bmatrix}_{(\color{red}2,3)}}
{\cdot}
{\begin{bmatrix}
\color{red}{2}&{7}\\
\color{red}{-5}&{-7}\\
\color{red}{9}&{3}\\
\end{bmatrix}_{(3,\color{red}2)}}
=
{\begin{bmatrix}
\color{red}{8-10+27=25}&\color{lightgrey}{?}\\
\color{lightgrey}{?}&\color{lightgrey}{?}\\
\end{bmatrix}_{(\color{red}2,\color{red}2)}}
\]
\[{\begin{bmatrix}
\color{red}{4}&\color{red}{2}&\color{red}{3}\\
{1}&{3}&{1}\\
\end{bmatrix}_{(\color{red}2,3)}}
{\cdot}
{\begin{bmatrix}
{2}&\color{red}{7}\\
{-5}&\color{red}{-7}\\
{9}&\color{red}{3}\\
\end{bmatrix}_{(3,\color{red}2)}}
=
{\begin{bmatrix}
\color{lightgrey}{?}&\color{red}{28-14+9=23}\\
\color{lightgrey}{?}&\color{lightgrey}{?}\\
\end{bmatrix}_{(\color{red}2,\color{red}2)}}
\]
\[{\begin{bmatrix}
{4}&{2}&{3}\\
\color{red}{1}&\color{red}{3}&\color{red}{1}\\
\end{bmatrix}_{(\color{red}2,3)}}
{\cdot}
{\begin{bmatrix}
\color{red}{2}&{7}\\
\color{red}{-5}&{-7}\\
\color{red}{9}&{3}\\
\end{bmatrix}_{(3,\color{red}2)}}
=
{\begin{bmatrix}
\color{lightgrey}{?}&\color{red}{28-14+9=23}\\
\color{lightgrey}{?}&\color{lightgrey}{?}\\
\end{bmatrix}_{(\color{red}2,\color{red}2)}}
\]
\[{\begin{bmatrix}
{4}&{2}&{3}\\
\color{red}{1}&\color{red}{3}&\color{red}{1}\\
\end{bmatrix}_{(\color{red}2,3)}}
{\cdot}
{\begin{bmatrix}
{2}&\color{red}{7}\\
{-5}&\color{red}{-7}\\
{9}&\color{red}{3}\\
\end{bmatrix}_{(3,\color{red}2)}}
=
{\begin{bmatrix}
\color{lightgrey}{?}&\color{red}{28-14+9=23}\\
\color{lightgrey}{?}&\color{lightgrey}{?}\\
\end{bmatrix}_{(\color{red}2,\color{red}2)}}
\]
三、内积np.inner(A,B)
四、矩阵乘积预算A@B
五、矩阵的逆运算
标签:begin,
end,
color,
科学计算,
lightgrey,
012,
bmatrix,
NumPy,
red
From: https://www.cnblogs.com/cloucodeforfun/p/16709243.html