矩阵运算与常用矩阵 agile Posted on Oct 2 2021 优秀博文 > 本文由 [简悦 SimpRead](http://ksria.com/simpread/) 转码, 原文地址 [zhuanlan.zhihu.com](https://zhuanlan.zhihu.com/p/362082020) 概念 -- 由 m*n 个数排成的 m 行 n 列的数表称为 m 行 n 列的矩阵,简称 m*n 矩阵。记作: ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%3D%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%26+a_%7B12%7D+%26+...+%26a_%7B1n%7D+%5C%5C+a_%7B21%7D+%26+a_%7B22%7D+%26+...+%26a_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%26+a_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%5Cend%7Bbmatrix%7D) 这 m*n 个数称为矩阵的元素,简称为元,数 ![](https://www.zhihu.com/equation?tex=a_%7Bij%7D) 位于矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 的第 i 行第 j 列,称为矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 的 (i, j) 元。 元素是实数的矩阵称为**实矩阵**,元素是复数的矩阵称为**复矩阵**。 若多个矩阵的行数和列数相同,我们称它们为**同型矩阵**。 行数与列数都等于 n 的矩阵称为 **n 阶矩阵或 n 阶方阵**。若多个方阵的行数(行数 = 列数)相同,我们称它们为**同阶矩阵**。 基本运算 ---- 矩阵的加减法和矩阵的数乘合称矩阵的线性运算 ### 加法 只有同型矩阵之间才可以进行加法运算,将两个矩阵相同位置的元相加即可,m 行 n 列的两个矩阵相加后得到一个新的 m 行 n 列矩阵,例如: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%26+a_%7B12%7D+%26+...+%26a_%7B1n%7D+%5C%5C+a_%7B21%7D+%26+a_%7B22%7D+%26+...+%26a_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%26+a_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%5Cend%7Bbmatrix%7D+%2B+%5Cbegin%7Bbmatrix%7D+b_%7B11%7D+%26+b_%7B12%7D+%26+...+%26b_%7B1n%7D+%5C%5C+b_%7B21%7D+%26+b_%7B22%7D+%26+...+%26b_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+b_%7Bm1%7D+%26+b_%7Bm2%7D+%26+...+%26b_%7Bmn%7D+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%2B+b_%7B11%7D+%26+a_%7B12%7D+%2B+b_%7B12%7D+%26+...+%26a_%7B1n%7D+%2B+b_%7B1n%7D+%5C%5C+a_%7B21%7D+%2B+b_%7B21%7D+%26+a_%7B22%7D+%2B+b_%7B22%7D+%26+...+%26a_%7B2n%7D+%2B+b_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%2B+b_%7Bm1%7D+%26+a_%7Bm2%7D+%2B+b_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%2B+b_%7Bmn%7D+%5Cend%7Bbmatrix%7D) ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+1+%26+3+%26+5+%26+7+%5C%5C+2+%26+4+%26+6+%26+8+%5Cend%7Bbmatrix%7D+%2B+%5Cbegin%7Bbmatrix%7D+4+%26+3+%26+1+%26+4+%5C%5C+5+%26+3+%26+1+%26+6+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+5+%26+6+%26+6+%26+11+%5C%5C+7+%26+7+%26+7+%26+14+%5Cend%7Bbmatrix%7D) **运算律**: 交换律: ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D+%2B+%5Cmathbf%7BB%7D+%3D+%5Cmathbf%7BB%7D+%2B+%5Cmathbf%7BA%7D) 结合律: ![](https://www.zhihu.com/equation?tex=%5Cleft+%28+%5Cmathbf%7BA%7D+%2B+%5Cmathbf%7BB%7D%5Cright+%29+%2B+%5Cmathbf%7BC%7D+%3D+%5Cmathbf%7BA%7D+%2B+%5Cleft+%28+%5Cmathbf%7BB%7D+%2B+%5Cmathbf%7BC%7D+%5Cright+%29) ### 减法 与加法类似,如下: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%26+a_%7B12%7D+%26+...+%26a_%7B1n%7D+%5C%5C+a_%7B21%7D+%26+a_%7B22%7D+%26+...+%26a_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%26+a_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%5Cend%7Bbmatrix%7D+-+%5Cbegin%7Bbmatrix%7D+b_%7B11%7D+%26+b_%7B12%7D+%26+...+%26b_%7B1n%7D+%5C%5C+b_%7B21%7D+%26+b_%7B22%7D+%26+...+%26b_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+b_%7Bm1%7D+%26+b_%7Bm2%7D+%26+...+%26b_%7Bmn%7D+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+-+b_%7B11%7D+%26+a_%7B12%7D+-+b_%7B12%7D+%26+...+%26a_%7B1n%7D+-+b_%7B1n%7D+%5C%5C+a_%7B21%7D+-+b_%7B21%7D+%26+a_%7B22%7D+-+b_%7B22%7D+%26+...+%26a_%7B2n%7D+-+b_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+-+b_%7Bm1%7D+%26+a_%7Bm2%7D+-+b_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+-+b_%7Bmn%7D+%5Cend%7Bbmatrix%7D) ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+1+%26+3+%26+5+%26+7+%5C%5C+2+%26+4+%26+6+%26+8+%5Cend%7Bbmatrix%7D+-+%5Cbegin%7Bbmatrix%7D+4+%26+3+%26+1+%26+4+%5C%5C+5+%26+3+%26+1+%26+6+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+-3+%26+0+%26+4+%26+3+%5C%5C+-3+%26+1+%26+5+%26+2+%5Cend%7Bbmatrix%7D) ### 数乘 数乘即将矩阵乘以一个常量,矩阵中的每个元都与这个常量相乘,例如: ![](https://www.zhihu.com/equation?tex=k+%2A+%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%26+a_%7B12%7D+%26+...+%26a_%7B1n%7D+%5C%5C+a_%7B21%7D+%26+a_%7B22%7D+%26+...+%26a_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%26+a_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+k+%2A+a_%7B11%7D+%26+k+%2A+a_%7B12%7D+%26+...+%26k+%2A+a_%7B1n%7D+%5C%5Ck+%2A+a_%7B21%7D+%26+k+%2A+a_%7B22%7D+%26+...+%26k+%2A+a_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+k+%2A+a_%7Bm1%7D+%26+k+%2A+a_%7Bm2%7D+%26+...+%26k+%2A+a_%7Bmn%7D+%5Cend%7Bbmatrix%7D) ![](https://www.zhihu.com/equation?tex=5%2A%5Cbegin%7Bbmatrix%7D+4+%26+3+%26+-1+%26+4+%5C%5C+5+%26+-3+%26+1+%26+6+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+20+%26+15+%26+-5+%26+20+%5C%5C+25+%26+-15+%26+5+%26+30+%5Cend%7Bbmatrix%7D) **运算律**: ![](https://www.zhihu.com/equation?tex=k%28v%5Cmathbf%7BA%7D%29+%3D+v%28k%5Cmathbf%7BA%7D%29) ![](https://www.zhihu.com/equation?tex=k%28v%5Cmathbf%7BA%7D%29+%3D+%28vk%29%5Cmathbf%7BA%7D) ![](https://www.zhihu.com/equation?tex=%28k%2Bv%29%5Cmathbf%7BA%7D+%3D+v%5Cmathbf%7BA%7D+%2B+k%5Cmathbf%7BA%7D) ![](https://www.zhihu.com/equation?tex=k%28%5Cmathbf%7BA%7D+%2B+%5Cmathbf%7BB%7D%29+%3D+k%5Cmathbf%7BA%7D+%2B+k%5Cmathbf%7BB%7D) ### 转置 把矩阵 ![](https://www.zhihu.com/equation?tex=A) 的行和列互相交换所产生的矩阵称为 A 的转置矩阵(标记为 ![](https://www.zhihu.com/equation?tex=A%5ET) ),这一过程称为矩阵的转置。 ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%26+a_%7B12%7D+%26+...+%26a_%7B1n%7D+%5C%5C+a_%7B21%7D+%26+a_%7B22%7D+%26+...+%26a_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%26+a_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%5Cend%7Bbmatrix%7D%5E%7BT%7D+%3D+%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%26+a_%7B21%7D+%26+...+%26a_%7Bm1%7D+%5C%5C+a_%7B12%7D+%26+a_%7B22%7D+%26+...+%26a_%7Bm2%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7B1n%7D+%26+a_%7B2n%7D+%26+...+%26a_%7Bmn%7D+%5Cend%7Bbmatrix%7D) ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+1+%26+3+%26+5+%26+7+%5C%5C+2+%26+4+%26+6+%26+8+%5Cend%7Bbmatrix%7D%5E%7BT%7D+%3D+%5Cbegin%7Bbmatrix%7D+1+%26+2+%5C%5C+3+%26+4%5C%5C+5+%26+6%5C%5C+7+%26+8+%5Cend%7Bbmatrix%7D) **运算律**: ![](https://www.zhihu.com/equation?tex=%28%5Cmathbf%7BA%7D%5E%7BT%7D%29%5E%7BT%7D%3D%5Cmathbf%7BA%7D) ![](https://www.zhihu.com/equation?tex=%28k%5Cmathbf%7BA%7D%29%5E%7BT%7D%3Dk%5Cmathbf%7BA%7D%5E%7BT%7D) ![](https://www.zhihu.com/equation?tex=%28%5Cmathbf%7BA%7D%5Cmathbf%7BB%7D%29%5E%7BT%7D%3D%5Cmathbf%7BB%7D%5E%7BT%7D%5Cmathbf%7BA%7D%5E%7BT%7D) ### 共轭 对于一个复数矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) ,我们对其做实部不变,虚部取负的操作即为共轭操作,记作 ![](https://www.zhihu.com/equation?tex=%5Cbar%7B%5Cmathbf%7BA%7D%7D) 。例如 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%3D%5Cbegin%7Bbmatrix%7D+3%2Bi+%26+5%5C%5C+2-2i+%26+i+%5Cend%7Bbmatrix%7D) 则 ![](https://www.zhihu.com/equation?tex=%5Cbar%7B%5Cmathbf%7BA%7D%7D%3D%5Cbegin%7Bbmatrix%7D+3-i+%26+5%5C%5C+2%2B2i+%26+-i+%5Cend%7Bbmatrix%7D) ### 乘法 两个矩阵的乘法仅当第一个矩阵的**列数**和另一个矩阵的**行数**相等时才能定义,_m_×_n_ 矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 和 _n_×_p_ 矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BB%7D) 相乘,会得到一个 _m_×_p_ 矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D) ,记为 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D+%3D+%5Cmathbf%7BA%7D%5Cmathbf%7BB%7D) 。 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D) 中第 i 行 j 列的元即为: ![](https://www.zhihu.com/equation?tex=c_%7Bij%7D+%3D+a_%7Bi1%7Db_%7B1j%7D%2Ba_%7Bi2%7Db_%7B2j%7D%2B%5Ccdot+%5Ccdot+%5Ccdot+%2Ba_%7Bin%7Db_%7Bnj%7D%3D%5Csum_%7Br%3D1%7D%5E%7Bn%7Da_%7Bir%7Db_%7Brj%7D) 式子看着很复杂,其实很简单, ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D) **中第 i 行第 j 列的元素的值为:** ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) **中第 i 行所有元素 与** ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BB%7D) **中第 j 列的所有元素一一对应相乘,然后将相乘后的所有值相加**。 例如: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+1+%26+3+%26+5+%5C%5C+2+%26+4+%26+6+%5Cend%7Bbmatrix%7D+%2A+%5Cbegin%7Bbmatrix%7D+7+%26+9+%5C%5C+8+%26+0+%5C%5C+-1+%26+1+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+1%2A7%2B3%2A8%2B5%2A-1+%26+1%2A9%2B3%2A0%2B5%2A1+%5C%5C+2%2A7%2B4%2A8%2B6%2A-1+%26+2%2A9%2B4%2A0%2B6%2A1+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+26+%26+14+%5C%5C+40+%26+24+%5Cend%7Bbmatrix%7D) 我们看结果中的第一行第二列 1*9+3*0+5*1,不就是前者的第一行 1,3,5 和后者的第二列 9,0,1 互相相乘然后相加。 **运算律**: ![](https://www.zhihu.com/equation?tex=%28%5Cmathbf%7BA%7D%5Cmathbf%7BB%7D%29%5Cmathbf%7BC%7D+%3D+%5Cmathbf%7BA%7D%28%5Cmathbf%7BB%7D%5Cmathbf%7BC%7D%29) ![](https://www.zhihu.com/equation?tex=%28%5Cmathbf%7BA%7D%2B%5Cmathbf%7BB%7D%29%5Cmathbf%7BC%7D+%3D+%5Cmathbf%7BA%7D%5Cmathbf%7BC%7D%2B%5Cmathbf%7BB%7D%5Cmathbf%7BC%7D) ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D%28%5Cmathbf%7BA%7D%2B%5Cmathbf%7BB%7D%29+%3D+%5Cmathbf%7BC%7D%5Cmathbf%7BA%7D+%2B+%5Cmathbf%7BC%7D%5Cmathbf%7BB%7D) 不满足交换律,即 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5Cmathbf%7BB%7D+%5Cneq+%5Cmathbf%7BB%7D%5Cmathbf%7BA%7D) 例如 1*3 的矩阵乘以 3*1 的矩阵得到的是 1*1 的矩阵(每 n 行乘以每 n 列,左边只有一行,右边只有一列,**向量的点乘**就属于这种情况): ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+1+%26+3+%26+5++%5Cend%7Bbmatrix%7D+%2A+%5Cbegin%7Bbmatrix%7D+2%5C%5C4%5C%5C6+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+1%2A2%2B3%2A4%2B5%2A6+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+44+%5Cend%7Bbmatrix%7D) 而把它们反过来,即 3*1 的矩阵乘以 1*3 的矩阵,就变成了 3*3 的矩阵: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+2%5C%5C4%5C%5C6+%5Cend%7Bbmatrix%7D+%2A%5Cbegin%7Bbmatrix%7D+1+%26+3+%26+5++%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+2%2A1%262%2A3%262%2A5%5C%5C4%2A1%264%2A3%264%2A5%5C%5C6%2A1%266%2A3%266%2A5+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+2%266%2610%5C%5C4%2612%2620%5C%5C6%2618%2630+%5Cend%7Bbmatrix%7D) ### 矩阵与向量相乘 向量用矩阵表示的话,是属于一个 n*1 的矩阵,例如二维向量为 ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+x%5C%5C+y+%5Cend%7Bbmatrix%7D) ,三维向量为 ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+x%5C%5C+y%5C%5C+z+%5Cend%7Bbmatrix%7D) 因此一个 m * 2 的矩阵可以乘以一个二维向量,m * 3 的矩阵可以乘以一个三维向量。 这点对于**向量的变换运算**非常的重要,例如我们想要将向量 (x, y) 做一个 y 轴的对称操作,即变为 (-x, y) ,只需要用下面的矩阵乘以这个向量即可: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+-1+%26+0+%5C%5C+0+%26+1+%5Cend%7Bbmatrix%7D+%2A+%5Cbegin%7Bbmatrix%7D+x+%5C%5C+y+%5Cend%7Bbmatrix%7D+%3D%5Cbegin%7Bbmatrix%7D+-x+%5C%5C+y+%5Cend%7Bbmatrix%7D) ### 矩阵表示向量的点积 ![](https://www.zhihu.com/equation?tex=%5Cvec%7Ba%7D+%5Ccdot+%5Cvec%7Bb%7D+%3D+%5Cvec%7Ba%7D%5E%7BT%7D+%5Cvec%7Bb%7D+%3D+%5Cbegin%7Bbmatrix%7D+x_%7Ba%7D+%26+y_%7Ba%7D+%26+z_%7Ba%7D+%5Cend%7Bbmatrix%7D+%2A+%5Cbegin%7Bbmatrix%7D+x_%7Bb%7D+%5C%5C+y_%7Bb%7D+%5C%5C+z_%7Bb%7D+%5Cend%7Bbmatrix%7D%3D+%5Cbegin%7Bbmatrix%7D+x_%7Ba%7Dx_%7Bb%7D%2By_%7Ba%7Dy_%7Bb%7D%2Bz_%7Ba%7Dz_%7Bb%7D+%5Cend%7Bbmatrix%7D) ### 矩阵表示向量的叉积 ![](https://www.zhihu.com/equation?tex=%5Cvec%7Ba%7D+%5Ctimes+%5Cvec%7Bb%7D+%3D+%5Cbegin%7Bbmatrix%7D+0+%26+-z_%7Ba%7D+%26+y_%7Ba%7D%5C%5Cz_%7Ba%7D+%26+0+%26+-x_%7Ba%7D%5C%5C-y_%7Ba%7D+%26+x_%7Ba%7D+%260+%5Cend%7Bbmatrix%7D+%2A+%5Cbegin%7Bbmatrix%7D+x_%7Bb%7D+%5C%5C+y_%7Bb%7D+%5C%5C+z_%7Bb%7D+%5Cend%7Bbmatrix%7D%3D+%5Cbegin%7Bbmatrix%7D+0%2Ax_%7Bb%7D-z_%7Ba%7Dy_%7Bb%7D%2By_%7Ba%7Dz_%7Bb%7D%5C%5Cz_%7Ba%7Dx_%7Bb%7D%2B0%2Ay_%7Bb%7D-x_%7Ba%7Dz_%7Bb%7D%5C%5C-y_%7Ba%7Dx_%7Bb%7D%2Bx_%7Ba%7Dy_%7Bb%7D%2B0%2Az_%7Bb%7D+%5Cend%7Bbmatrix%7D) 至于左边这个矩阵怎么来的?可以看后续的三维旋转推导。 ### 哈达玛积 (Hadamard product) 矩阵还有一种运算叫作哈达玛积或者基本积,该运算类似于矩阵的加减法,将两个 m*n 的同阶矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 、 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BB%7D) 的对应位置相乘得到一个 m*n 的新矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D) ,常记作 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D%3D%5Cmathbf%7BA%7D%5Cast%5Cmathbf%7BB%7D) 或 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BC%7D%3D%5Cmathbf%7BA%7D%5Ccirc%5Cmathbf%7BB%7D) 。 例如: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%26+a_%7B12%7D+%26+...+%26a_%7B1n%7D+%5C%5C+a_%7B21%7D+%26+a_%7B22%7D+%26+...+%26a_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%26+a_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%5Cend%7Bbmatrix%7D+%5Ccirc+%5Cbegin%7Bbmatrix%7D+b_%7B11%7D+%26+b_%7B12%7D+%26+...+%26b_%7B1n%7D+%5C%5C+b_%7B21%7D+%26+b_%7B22%7D+%26+...+%26b_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+b_%7Bm1%7D+%26+b_%7Bm2%7D+%26+...+%26b_%7Bmn%7D+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+a_%7B11%7D+%2A+b_%7B11%7D+%26+a_%7B12%7D+%2A+b_%7B12%7D+%26+...+%26a_%7B1n%7D+%2A+b_%7B1n%7D+%5C%5C+a_%7B21%7D+%2A+b_%7B21%7D+%26+a_%7B22%7D+%2A+b_%7B22%7D+%26+...+%26a_%7B2n%7D+%2A+b_%7B2n%7D+%5C%5C+...+%26+...+%26+...+%26...+%5C%5C+a_%7Bm1%7D+%2A+b_%7Bm1%7D+%26+a_%7Bm2%7D+%2A+b_%7Bm2%7D+%26+...+%26a_%7Bmn%7D+%2A+b_%7Bmn%7D+%5Cend%7Bbmatrix%7D) ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+1+%26+3+%26+5+%26+7+%5C%5C+2+%26+4+%26+6+%26+8+%5Cend%7Bbmatrix%7D+%5Ccirc+%5Cbegin%7Bbmatrix%7D+4+%26+3+%26+1+%26+4+%5C%5C+5+%26+3+%26+1+%26+6+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+4+%26+9+%26+5+%26+28+%5C%5C+10+%26+12+%26+6+%26+48+%5Cend%7Bbmatrix%7D) **运算律**: ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D+%5Ccirc+0+%3D+0) ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D+%5Ccirc+%5Cmathbf%7BB%7D+%3D+%5Cmathbf%7BB%7D+%5Ccirc+%5Cmathbf%7BA%7D) ![](https://www.zhihu.com/equation?tex=%28+%5Cmathbf%7BA%7D+%2B+%5Cmathbf%7BB%7D%29+%5Ccirc+%5Cmathbf%7BC%7D+%3D+%28%5Cmathbf%7BA%7D+%5Ccirc%5Cmathbf%7BC%7D%29%2B+%28+%5Cmathbf%7BB%7D+%5Ccirc+%5Cmathbf%7BC%7D+%29) \ 常用的特殊的矩阵 -------- ### 单位矩阵 单位矩阵是个方阵,从左上角到右下角的对角线(称为主对角线)上的元素均为 1,除此以外全都为 0,即 ![](https://www.zhihu.com/equation?tex=%5Cleft%5C%7B%5Cbegin%7Bmatrix%7D+a_%7Bij%7D%3D1+%26%28i%3Dj%29%5C%5C++a_%7Bij%7D%3D0+%26%28i%5Cne+j%29+%5Cend%7Bmatrix%7D%5Cright.) 单位矩阵记为 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BI%7D_%7Bn%7D) 或者 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BE%7D_%7Bn%7D) ,通常用 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BI%7D) 或 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BE%7D) 表示,例如: ![](https://www.zhihu.com/equation?tex=I_%7B2%7D+%3D+%5Cbegin%7Bbmatrix%7D+1+%26+0+%5C%5C+0+%26+1+%5Cend%7Bbmatrix%7D) ![](https://www.zhihu.com/equation?tex=I_%7B3%7D+%3D+%5Cbegin%7Bbmatrix%7D+1+%26+0+%26+0+%5C%5C+0+%26+1+%26+0+%5C%5C+0+%26+0+%26+1+%5Cend%7Bbmatrix%7D) **重要性质**:任何矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 乘以单位矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BI%7D) ,或者单位矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BI%7D) 乘以任何矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 的结果都为 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 。记作: ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5Cmathbf%7BI%7D+%3D+%5Cmathbf%7BA%7D) 或 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BI%7D%5Cmathbf%7BA%7D+%3D+%5Cmathbf%7BA%7D) ### 逆矩阵 设 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 是一个 n 阶矩阵,若存在另一个 n 阶矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BB%7D) ,使得: ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5Cmathbf%7BB%7D+%3D+%5Cmathbf%7BB%7D%5Cmathbf%7BA%7D+%3D+%5Cmathbf%7BI%7D) ( ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BI%7D) 为单位矩阵),则称方阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 可逆,并称方阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BB%7D) 是 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 的逆矩阵。 若矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 可逆,则其的逆矩阵是唯一的,记为 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7B-1%7D) ,则 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5Cmathbf%7BA%7D%5E%7B-1%7D+%3D+%5Cmathbf%7BI%7D) 或 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7B-1%7D%5Cmathbf%7BA%7D+%3D+%5Cmathbf%7BI%7D) 。 一些性质: 若 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 可逆,则 ![](https://www.zhihu.com/equation?tex=%28%5Cmathbf%7BA%7D%5E%7B-1%7D%29%5E%7B-1%7D+%3D+%5Cmathbf%7BA%7D) 若 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 可逆,则其转置矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7BT%7D) 也可逆,且 ![](https://www.zhihu.com/equation?tex=%28%5Cmathbf%7BA%7D%5E%7BT%7D%29%5E%7B-1%7D+%3D+%28%5Cmathbf%7BA%7D%5E%7B-1%7D%29%5E%7BT%7D) 若 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) , ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BB%7D) 都可逆,则 ![](https://www.zhihu.com/equation?tex=%28%5Cmathbf%7BA%7D%5Cmathbf%7BB%7D%29%5E%7B-1%7D+%3D+%5Cmathbf%7BB%7D%5E%7B-1%7D%5Cmathbf%7BA%7D%5E%7B-1%7D) ### 对角矩阵 当一个方阵上所有非对角线上的元素均为 0 时,即 ![](https://www.zhihu.com/equation?tex=i+%5Cneq+j) 时 ![](https://www.zhihu.com/equation?tex=a_%7Bij%7D+%3D+0) ,该矩阵即为对角矩阵。例如: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+1+%26+0+%26+0+%5C%5C+0+%26+5+%26+0+%5C%5C+0+%26+0+%26+2+%5Cend%7Bbmatrix%7D) 它可用于缩放变换,假如我们要将 (x, y) 分别缩放 m 倍和 n 倍,变为 (mx, ny) 那么就可以用下面矩阵来表达: ![](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D+m+%26+0%5C%5C+0+%26+n+%5Cend%7Bbmatrix%7D+%2A+%5Cbegin%7Bbmatrix%7D+x%5C%5C+y+%5Cend%7Bbmatrix%7D+%3D%5Cbegin%7Bbmatrix%7D+m%2A+x%5C%5C+n+%2A+y+%5Cend%7Bbmatrix%7D) 该对角矩阵也可称为**缩放矩阵**。 ### 正交矩阵 如果有个 n 阶实矩阵 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) ,它满足 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D+%5Cmathbf%7BA%7D%5E%7BT%7D+%3D+%5Cmathbf%7BI%7D) 或 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7BT%7D+%5Cmathbf%7BA%7D+%3D+%5Cmathbf%7BI%7D) ,则称 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 为正交矩阵,正交矩阵常用字母 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BQ%7D) 来表示。 我们可以发现这和逆矩阵的定义( ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5Cmathbf%7BA%7D%5E%7B-1%7D+%3D+%5Cmathbf%7BI%7D) )很像,因此正交矩阵的转置等于其逆矩阵,即 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7BT%7D+%3D+%5Cmathbf%7BA%7D%5E%7B-1%7D)。 除此之外, ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 或 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7BT%7D) 的**各行都是单位向量且两两正交,且各列也都是单位向量且两两正交**。 **推导:** 假设 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D+%3D+%5Cbegin%7Bbmatrix%7D+a+%26+b+%5C%5C+c+%26+d+%5Cend%7Bbmatrix%7D) 为正交矩阵,那么 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7BT%7D+%3D+%5Cbegin%7Bbmatrix%7D+a+%26+c+%5C%5C+b+%26+d+%5Cend%7Bbmatrix%7D) ,可得: ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D+%5Cmathbf%7BA%7D%5E%7BT%7D+%3D+%5Cbegin%7Bbmatrix%7D+aa%2Bbb+%26+ac%2Bbd+%5C%5C+ca%2Bdb+%26+cc%2Bdd+%5Cend%7Bbmatrix%7D+%3D+%5Cbegin%7Bbmatrix%7D+1+%26+0+%5C%5C+0+%26+1+%5Cend%7Bbmatrix%7D) 可得 ac+bd=0,aa+bb=cc+dd=1。 若按照 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 的行来取向量,我们可得到向量 ![](https://www.zhihu.com/equation?tex=%5Cvec%7Bi%7D%3D%28a%2Cb%29) 和 ![](https://www.zhihu.com/equation?tex=%5Cvec%7Bj%7D%3D%28c%2Cd%29) 。 做点积得 ![](https://www.zhihu.com/equation?tex=%5Cvec%7Bi%7D%5Ccdot+%5Cvec%7Bj%7D%3Dac%2Bbd) ,前面已得到 ac+bd=0,所以 ![](https://www.zhihu.com/equation?tex=%5Cvec%7Bi%7D%5Ccdot+%5Cvec%7Bj%7D%3D0) ,根据正交的定义可得,这两个向量正交。 然后再来取模,可得 ![](https://www.zhihu.com/equation?tex=+%7C+%5Cvec%7Bi%7D+%7C%3D%5Csqrt%7Baa%2Bbb%7D) ,前面得到 aa+bb=1,因此 ![](https://www.zhihu.com/equation?tex=%5Cvec%7Bi%7D) 的模长为 1,为单位向量, ![](https://www.zhihu.com/equation?tex=%5Cvec%7Bj%7D) 同理为单位向量。 上面我们验证了 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D) 中各行都是单位向量且两两正交,要验证每列也是这样的情况只需要使用 ![](https://www.zhihu.com/equation?tex=%5Cmathbf%7BA%7D%5E%7BT%7D+%5Cmathbf%7BA%7D+%3D+%5Cmathbf%7BI%7D) 来推导即可。同样的在三维空间也可以用此方法来推导,用 3*3 的矩阵相乘即可。 在坐标系中,我们 x 轴的单位向量为 (1, 0, 0),y 轴为 (0, 1, 0),z 轴为 (0, 0, 1),那么他们所组成的矩阵即为: ![](https://www.zhihu.com/equation?tex=+%5Cbegin%7Bbmatrix%7D+1+%26+0+%26+0%5C%5C+0+%26+1%26+0%5C%5C0%26+0%261+%5Cend%7Bbmatrix%7D) 它既是单位矩阵,又是正交矩阵。 向量运算与应用 Unity的内存管理与性能优化