1 【数理知识】向量数乘,内积,外积,matlab代码实现
2 【数理知识】矩阵普通乘积,哈达玛积,克罗内克积,点乘,点积,叉乘,matlab代码实现

文章目录

  • 1. 矩阵基本形式
  • 2. 矩阵基本运算 - 普通乘积,matmul product
  • 3. 矩阵基本运算 - 哈达玛积 Hadamard product
  • 4. 矩阵基本运算 - 克罗内克积,Kronecker product
  • 5. Matlab矩阵运算 - 普通乘积 *
  • 6. Matlab矩阵运算 - 点乘 .*
  • 7. Matlab矩阵运算 - 点积 dot()
  • 8. Matlab矩阵运算 - 叉乘 cross()
  • Ref

首先介绍矩阵

1. 矩阵基本形式

在数学中,矩阵是一个按照长方阵列排列的复数或实数集合。由 m×nm \times nm×n个数 aija_{ij}aij​ 排成的 mmm 行 nnn 列的数表称为 mmm 行 nnn 列的矩阵,简称 m×nm \times nm×n 矩阵。记作:

A=[a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amn]A = \left[\begin{matrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \\ \end{matrix}\right]A=​a11​a21​⋮am1​​a12​a22​⋮am2​​⋯⋯⋱⋯​a1n​a2n​⋮amn​​​

2. 矩阵基本运算 - 普通乘积,matmul product

矩阵相乘最重要的方法是一般矩阵乘积。它只有在第一个矩阵的列数(column)和第二个矩阵的行数(row)相同时才有意义。即线性代数学学的,左行乘以右列。

  • 左边矩阵的列数必须与右边矩阵的行数相等
  • 不满足交换律,即 AB≠BA(BA存在)AB \ne BA (BA 存在)AB=BA(BA存在)

A=[a11a12a13a21a22a23]2×3,B=[b11b12b13b14b21b22b23b24b31b32b33b34]3×4A = \left[\begin{matrix} \red{a_{11}} & \red{a_{12}} & \red{a_{13}} \\ a_{21} & a_{22} & a_{23} \\ \end{matrix}\right]_{\green{2 \times 3}}, \quad B = \left[\begin{matrix} \blue{b_{11}} & b_{12} & b_{13} & b_{14} \\ \blue{b_{21}} & b_{22} & b_{23} & b_{24} \\ \blue{b_{31}} & b_{32} & b_{33} & b_{34} \\ \end{matrix}\right]_{\green{3 \times 4}}A=[a11​a21​​a12​a22​​a13​a23​​]2×3​,B=​b11​b21​b31​​b12​b22​b32​​b13​b23​b33​​b14​b24​b34​​​3×4​

C=A2×3B3×4=C2×4=[a11b11+a12b21+a13b31a11b12+a12b22+a13b32a11b13+a12b23+a13b33a11b14+a12b24+a13b34a21b11+a22b21+a23b31a21b12+a22b22+a23b32a21b13+a22b23+a23b33a21b14+a22b24+a23b34]2×4\begin{aligned} C &= A_{\green{2 \times 3}} B_{\green{3 \times 4}} = C_{\green{2 \times 4}} \\ &=\left[\begin{matrix} \red{a_{11}} \blue{b_{11}} + \red{a_{12}} \blue{b_{21}} + \red{a_{13}} \blue{b_{31}} & \red{a_{11}} b_{12} + \red{a_{12}} b_{22} + \red{a_{13}} b_{32} & \red{a_{11}} b_{13} + \red{a_{12}} b_{23} + \red{a_{13}} b_{33} & \red{a_{11}} b_{14} + \red{a_{12}} b_{24} + \red{a_{13}} b_{34} \\ a_{21} \blue{b_{11}} + a_{22} \blue{b_{21}} + a_{23} \blue{b_{31}} & a_{21} b_{12} + a_{22} b_{22} + a_{23} b_{32} & a_{21} b_{13} + a_{22} b_{23} + a_{23} b_{33} & a_{21} b_{14} + a_{22} b_{24} + a_{23} b_{34} \\ \end{matrix}\right]_{\green{2 \times 4}} \end{aligned}C​=A2×3​B3×4​=C2×4​=[a11​b11​+a12​b21​+a13​b31​a21​b11​+a22​b21​+a23​b31​​a11​b12​+a12​b22​+a13​b32​a21​b12​+a22​b22​+a23​b32​​a11​b13​+a12​b23​+a13​b33​a21​b13​+a22​b23​+a23​b33​​a11​b14​+a12​b24​+a13​b34​a21​b14​+a22​b24​+a23​b34​​]2×4​​

A = [1  2  3; 4  5  6];
B = [1  2  3  4; 5  6  7  8; 9 10 11 12];

Matlab语法:C = A * B

>> C = A * B
ans =38    44    50    5683    98   113   128>> A.*B
对于此运算,数组的大小不兼容。>> dot(A, B)
错误使用 dot
A 和 B 的大小必须相同。>> cross(A, B)
错误使用 cross
A 和 B 的大小必须相同。

3. 矩阵基本运算 - 哈达玛积 Hadamard product

当矩阵 AAA 和矩阵 BBB 的维度相同时,矩阵点乘即为哈达玛积(Hadamard Product/Point-wise Product/Element-wise Product/Element-wise Multiplication)

  • 哈达玛积其元素定义为两个矩阵对应元素的乘积
  • 矩阵各个对应元素相乘, 这个时候要求两个矩阵必须同样大小

A=[a11a12a13a21a22a23a31a32a33]3×3,B=[b11b12b13b21b22b23b31b32b33]3×3A = \left[\begin{matrix} \red{a_{11}} & \red{a_{12}} & \red{a_{13}} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \\ \end{matrix}\right]_{\green{3 \times 3}}, \quad B = \left[\begin{matrix} \blue{b_{11}} & b_{12} & b_{13} \\ \blue{b_{21}} & b_{22} & b_{23} \\ \blue{b_{31}} & b_{32} & b_{33} \\ \end{matrix}\right]_{\green{3 \times 3}}A=​a11​a21​a31​​a12​a22​a32​​a13​a23​a33​​​3×3​,B=​b11​b21​b31​​b12​b22​b32​​b13​b23​b33​​​3×3​

C=A3×3B3×3=C3×3=[a11b11a12b12a13b13a21b21a22b22a23b23a31b31a32b32a33b33]3×3\begin{aligned} C &= A_{\green{3 \times 3}} B_{\green{3 \times 3}} = C_{\green{3 \times 3}} \\ &=\left[\begin{matrix} \red{a_{11}} \blue{b_{11}} & \red{a_{12}} b_{12} & \red{a_{13}} b_{13} \\ a_{21} \blue{b_{21}} & a_{22} b_{22} & a_{23} b_{23} \\ a_{31} \blue{b_{31}} & a_{32} b_{32} & a_{33} b_{33} \\ \end{matrix}\right]_{\green{3 \times 3}} \end{aligned}C​=A3×3​B3×3​=C3×3​=​a11​b11​a21​b21​a31​b31​​a12​b12​a22​b22​a32​b32​​a13​b13​a23​b23​a33​b33​​​3×3​​

A = [1  2  3; 4  5  6;7  8  9];
B = [1  2  3; 4  5  6;7  8  9];

Matlab语法:C = A .* B

>> C = A .* B
C =1     4     916    25    3649    64    81>> C = A * B
C =30    36    4266    81    96102   126   150>> C = dot(A, B)
C =66    93   126>> C = cross(A, B)
C =0     0     00     0     00     0     0

4. 矩阵基本运算 - 克罗内克积,Kronecker product

A=[a11a12a13a21a22a23]2×3,B=[b11b12b21b22b31b32]3×2A = \left[\begin{matrix} \red{a_{11}} & \red{a_{12}} & \red{a_{13}} \\ a_{21} & a_{22} & a_{23} \\ \end{matrix}\right]_{\green{2 \times 3}}, \quad B = \left[\begin{matrix} \blue{b_{11}} & b_{12} \\ \blue{b_{21}} & b_{22} \\ \blue{b_{31}} & b_{32} \\ \end{matrix}\right]_{\green{3 \times 2}}A=[a11​a21​​a12​a22​​a13​a23​​]2×3​,B=​b11​b21​b31​​b12​b22​b32​​​3×2​

C=A2×3B3×2=C6×6=[a11b11a11b12a12b11a12b12a13b11a13b12a11b21a11b22a12b21a12b22a13b21a13b22a11b31a11b32a12b31a12b32a13b31a13b32a21b11a21b12a22b11a22b12a23b11a23b12a21b21a21b22a22b21a22b22a23b21a23b22a21b31a21b32a22b31a22b32a23b31a23b32]6×6\begin{aligned} C &= A_{\green{2 \times 3}} B_{\green{3 \times 2}} = C_{\green{6 \times 6}} \\ &=\left[\begin{matrix} \red{a_{11}} \blue{b_{11}} & \red{a_{11}} b_{12} & \red{a_{12}} \blue{b_{11}} & \red{a_{12}} b_{12} & \red{a_{13}} \blue{b_{11}} & \red{a_{13}} b_{12} \\ \red{a_{11}} \blue{b_{21}} & \red{a_{11}} b_{22} & \red{a_{12}} \blue{b_{21}} & \red{a_{12}} b_{22} & \red{a_{13}} \blue{b_{21}} & \red{a_{13}} b_{22} \\ \red{a_{11}} \blue{b_{31}} & \red{a_{11}} b_{32} & \red{a_{12}} \blue{b_{31}} & \red{a_{12}} b_{32} & \red{a_{13}} \blue{b_{31}} & \red{a_{13}} b_{32} \\ a_{21} \blue{b_{11}} & a_{21} b_{12} & a_{22} \blue{b_{11}} & a_{22} b_{12} & a_{23} \blue{b_{11}} & a_{23} b_{12} \\ a_{21} \blue{b_{21}} & a_{21} b_{22} & a_{22} \blue{b_{21}} & a_{22} b_{22} & a_{23} \blue{b_{21}} & a_{23} b_{22} \\ a_{21} \blue{b_{31}} & a_{21} b_{32} & a_{22} \blue{b_{31}} & a_{22} b_{32} & a_{23} \blue{b_{31}} & a_{23} b_{32} \\ \end{matrix}\right]_{\green{6 \times 6}} \end{aligned}C​=A2×3​B3×2​=C6×6​=​a11​b11​a11​b21​a11​b31​a21​b11​a21​b21​a21​b31​​a11​b12​a11​b22​a11​b32​a21​b12​a21​b22​a21​b32​​a12​b11​a12​b21​a12​b31​a22​b11​a22​b21​a22​b31​​a12​b12​a12​b22​a12​b32​a22​b12​a22​b22​a22​b32​​a13​b11​a13​b21​a13​b31​a23​b11​a23​b21​a23​b31​​a13​b12​a13​b22​a13​b32​a23​b12​a23​b22​a23​b32​​​6×6​​

A = [1  2  3; 4  5  6];
B = [1  2; 3  4;5  6];

Matlab语法:C = kron(A, B)

>> C = kron(A, B)
C =1     2     2     4     3     63     4     6     8     9    125     6    10    12    15    184     8     5    10     6    1212    16    15    20    18    2420    24    25    30    30    36>> C = A * B
C =22    2849    64>> C = dot(A, B)
错误使用 dot
A 和 B 的大小必须相同。>> C = cross(A, B)
错误使用 cross
A 和 B 的大小必须相同。

5. Matlab矩阵运算 - 普通乘积 *

这个比较简单,不再过多解释。


6. Matlab矩阵运算 - 点乘 .*

A=[a11a12a21a22a31a32a41a42]4×2,B=[b11b21b31b41]4×1A = \left[\begin{matrix} \red{a_{11}} & \red{a_{12}} \\ a_{21} & a_{22} \\ a_{31} & a_{32} \\ a_{41} & a_{42} \\ \end{matrix}\right]_{\green{4 \times 2}}, \quad B = \left[\begin{matrix} \blue{b_{11}} \\ \blue{b_{21}} \\ \blue{b_{31}} \\ \blue{b_{41}} \\ \end{matrix}\right]_{\green{4 \times 1}}A=​a11​a21​a31​a41​​a12​a22​a32​a42​​​4×2​,B=​b11​b21​b31​b41​​​4×1​

C=A4×2⊙B4×1=C4×2=[a11b11a12b11a21b21a22b21a31b31a32b31a41b41a42b41]4×2\begin{aligned} C &= A_{\green{4 \times 2}} \odot B_{\green{4 \times 1}} = C_{\green{4 \times 2}} \\ &=\left[\begin{matrix} \red{a_{11}} \blue{b_{11}} & \red{a_{12}} \blue{b_{11}} \\ a_{21} \blue{b_{21}} & a_{22} \blue{b_{21}} \\ a_{31} \blue{b_{31}} & a_{32} \blue{b_{31}} \\ a_{41} \blue{b_{41}} & a_{42} \blue{b_{41}} \\ \end{matrix}\right]_{\green{4 \times 2}} \end{aligned}C​=A4×2​⊙B4×1​=C4×2​=​a11​b11​a21​b21​a31​b31​a41​b41​​a12​b11​a22​b21​a32​b31​a42​b41​​​4×2​​

A = [1  2; 3  4;5  6;7  8];
B = [1; 2;3;4];
>> C = A .* B
C =1     26     815    1828    32

A=[a11a21]2×1,B=[b11b12b13]1×3A = \left[\begin{matrix} \red{a_{11}} \\ a_{21} \\ \end{matrix}\right]_{\green{2 \times 1}}, \quad B = \left[\begin{matrix} \blue{b_{11}} & b_{12} & b_{13} \\ \end{matrix}\right]_{\green{1 \times 3}}A=[a11​a21​​]2×1​,B=[b11​​b12​​b13​​]1×3​

C=A2×1⊙B1×3=C2×3=[a11b11a11b12a11b13a21b11a21b12a21b13]2×3\begin{aligned} C &= A_{\green{2 \times 1}} \odot B_{\green{1 \times 3}} = C_{\green{2 \times 3}} \\ &=\left[\begin{matrix} \red{a_{11}} \blue{b_{11}} & \red{a_{11}} \blue{b_{12}} & \red{a_{11}} \blue{b_{13}} \\ a_{21} \blue{b_{11}} & a_{21} b_{12} & a_{21} b_{13} \\ \end{matrix}\right]_{\green{2 \times 3}} \end{aligned}C​=A2×1​⊙B1×3​=C2×3​=[a11​b11​a21​b11​​a11​b12​a21​b12​​a11​b13​a21​b13​​]2×3​​

A = [1;2];
B = [1  2  3];
>> C = A .* B
C =1     2     32     4     6

A=[a11a21]2×1,B=[b11b12b13b21b22b23]2×3A = \left[\begin{matrix} \red{a_{11}} \\ a_{21} \\ \end{matrix}\right]_{\green{2 \times 1}}, \quad B = \left[\begin{matrix} \blue{b_{11}} & b_{12} & b_{13} \\ \blue{b_{21}} & b_{22} & b_{23} \\ \end{matrix}\right]_{\green{2 \times 3}}A=[a11​a21​​]2×1​,B=[b11​b21​​b12​b22​​b13​b23​​]2×3​

C=A2×1⊙B2×3=C2×3=[a11b11a11b12a11b13a21b12a21b22a21b23]2×3\begin{aligned} C &= A_{\green{2 \times 1}} \odot B_{\green{2 \times 3}} = C_{\green{2 \times 3}} \\ &=\left[\begin{matrix} \red{a_{11}} \blue{b_{11}} & \red{a_{11}} \blue{b_{12}} & \red{a_{11}} \blue{b_{13}} \\ a_{21} \blue{b_{12}} & a_{21} b_{22} & a_{21} b_{23} \\ \end{matrix}\right]_{\green{2 \times 3}} \end{aligned}C​=A2×1​⊙B2×3​=C2×3​=[a11​b11​a21​b12​​a11​b12​a21​b22​​a11​b13​a21​b23​​]2×3​​

A = [1;2];
B = [1  2  3;4  5  6];
>> C = A .* B
C =1     2     38    10    12

7. Matlab矩阵运算 - 点积 dot()

C = dot(A,B) returns the scalar dot product of A and B.

  • If A and B are vectors, then they must have the same length.
  • If A and B are matrices or multidimensional arrays, then they must have the same size. In this case, the dot function treats A and B as collections of vectors. The function calculates the dot product of corresponding vectors along the first array dimension whose size does not equal 1.

C = dot(A,B,dim) evaluates the dot product of A and B along dimension, dim. The dim input is a positive integer scalar.


8. Matlab矩阵运算 - 叉乘 cross()

C = cross(A,B) returns the cross product of A and B.

  • If A and B are vectors, then they must have a length of 3.
  • If A and B are matrices or multidimensional arrays, then they must have the same size. In this case, the cross function treats A and B as collections of three-element vectors. The function calculates the cross product of corresponding vectors along the first array dimension whose size equals 3.

C = cross(A,B,dim) evaluates the cross product of arrays A and B along dimension, dim. A and B must have the same size, and both size(A,dim) and size(B,dim) must be 3. The dim input is a positive integer scalar.


Ref

  1. 矩阵和向量的点乘与叉乘
  2. 几种矩阵乘法总结
  3. 矩阵乘法,还可以这样算?
  4. 向量和矩阵的点乘和叉乘

【数理知识】矩阵普通乘积,哈达玛积,克罗内克积,点乘,点积,叉乘,matlab代码实现相关推荐

  1. 矩阵条件数的定义、理解以及matlab代码

    目录 1.矩阵条件数的定义 1.1 矩阵范数的定义 1.2 矩阵范数举例 2 矩阵条件数的意义 3.矩阵条件数matlab代码 1.矩阵条件数的定义 cond ⁡ ( A ) = ∥ A ∥ ∙ ∥ ...

  2. 矩阵标准化处理(内附MATLAB代码)

    矩阵指标标准化处理 文章目录 矩阵指标标准化处理 1.原理 2.代码实现 2.1正向指标标准化 2.2负向指标标准化 3.运行结果 3.1 工作区变量 3.2 矩阵R标准化结果 4.总结 1.原理 2 ...

  3. 【数理知识】《矩阵论》方保镕老师-第7章-几类特殊矩阵与特殊积

    上一章 回到目录 下一章 第7章-几类特殊矩阵与特殊积 7.1 非负矩阵 7.1.1 非负矩阵与正矩阵 定理 7.1.3 (谱半径的单调性) 定理 7.1.4 (佩龙 (Perron) 定理) 7.1 ...

  4. 【数理知识】《矩阵论》方保镕老师-第3章-矩阵的分解

    上一章 回到目录 下一章 第3章 矩阵的分解 3.1 矩阵的三角分解 3.1.1 消元过程的矩阵描述 3.1.2 矩阵的三角分解 3.1.3 常用的三角分解公式 3.2 矩阵的 QR(正交三角) 分解 ...

  5. Pytorch--动手学深度学习--线性代数(乘积+点积+矩阵向量乘积+矩阵乘积+累加+降维+范数求解)

    乘积 x=torch.tensor([1,2,3]) y=torch.tensor([1,2,3]) Hadamard乘积:x*y 即元素对应相乘 点积:torch.dot(x,y) 相当于 torc ...

  6. 【数理知识】向量数乘,内积,外积,matlab代码实现

    1 [数理知识]向量数乘,内积,外积,matlab代码实现 2 [数理知识]矩阵普通乘积,哈达玛积,克罗内克积,点乘,点积,叉乘,matlab代码实现 文章目录 1. 向量基本形式 2. 向量的数乘 ...

  7. 【数理知识】kronecker 克罗内克积

    Matlab 克罗尼克乘积 Kron(A,B) 目录 定理1 定理2 定理3 转置 定理4 逆 定理5 秩 定理6 迹 定理7 线性无关 定理10 特征值 定理11 相似 定理12 复系数多项式 推论 ...

  8. 矩阵内积、外积(克罗内克积)和Hadamard积

    一.矩阵的内积:两个矩阵A.B对应分量乘积之和,结果为一个标量,记作<A,B>(与向量的内积/点积/数量积的定义相似).所以A.B的行数列数都应相同,且有结论<A,B>=tr( ...

  9. 【数理知识】特征值、特征向量、左特征向量

    特征值.特征向量.左特征向量 左特征向量.右特征向量 右特征向量 xix_ixi​ 如下,也是默认常用向量形式: Axi=λixiAx_i = \lambda_i x_iAxi​=λi​xi​ 左特征 ...

最新文章

  1. 我为什么晚上写代码?
  2. 设计模式(三) | 为别人做嫁衣---代理模式
  3. 工业机器人九龙坡区职教中心_山西省襄汾县职教中心“智能工业机器人订单班”学生集体观看直播“2020一带一路暨金砖国家技能发展与技术创新大赛”...
  4. oracle rac fail,Oracle RAC Load Balance , Fail Over测试
  5. mysql CASE WHEN的基础和多种用法
  6. 如何制作行政区划矢量图(shp格式)
  7. WebGIS 瓦片地图引擎实现之——地图瓦片计算
  8. windows 安装h2o_H2O-安装
  9. mysql 时间 本周 本月_MySQL日期查询:本周、本月、本季、本年
  10. 京东前端:三级列表页持续架构优化
  11. 微信读书vscode插件_推荐 10 款有趣的 VSCode 插件
  12. 两查一信热战正酣、可信百科低调入局,企业征信是虚火吗?
  13. 今日凌晨周杰伦生日首发《等你下课》,感动哭了!
  14. 疲劳驾驶数据集_Lyft开源L5自动驾驶数据集:55000个人工标注的3D注释框架,还有高清空间语义地图...
  15. \Zane\Utils\Ary 开源代码阅读示例
  16. python图像分割算法_用python实现随机森林图像分割
  17. 苹果手机防盗软件_苹果手机更好用的笔记软件是哪款?
  18. uwp跟随系统主题颜色
  19. java小型超市系统_Java小型超市收银系统
  20. mybatis配置mybatis.configuration.map-underscore-to-camel-case=true

热门文章

  1. 虚拟机工具VMware安装教程
  2. 实习、校招面试的一点经验
  3. echart 世界地图发光_Echarts世界地图中国分区显示
  4. Matlab实现图像压缩
  5. 交换机的工作原理及作用
  6. 滴滴十大技术方向开源项目出炉
  7. 基于ARCGIS计算RUSLE中LS因子值
  8. 可变形的四旋翼飞行器——无人机
  9. 用什么软件可以把歌曲截取一部分
  10. 不小心格式化交换机Flash后的挽救