矩阵乘法 Matrix Multiplication

矩阵乘法Matrix Multiplication

什么是矩阵

A Matrix is an array of numbers:

现在假设我们有两个矩阵 A 和 B

A 有 m 行 n 列

B 有 n 行 p 列

要实现矩阵乘法,第一个矩阵的列数必须等于第二个矩阵的行数。所以这里 A 的 n 列和 B 的 n 行一定要相同。

A 和 B 相乘得到矩阵 C,矩阵 C 有 m 行和 p 列。

矩阵相乘

两个矩阵相乘需要使用点积运算(Dot Product)。

计算第1行和第1列:

            

用 ChatGPT 来解释一下:

The dot product, also known as the scalar product, is an operation that takes two equal-length sequences of numbers (usually coordinate vectors) and returns a single number.

Given two vectors ( $\mathbf{a} = [a_1, a_2, ..., a_n] $) and ( $\mathbf{b} = [b_1, b_2, ..., b_n] $), the dot product is calculated as follows:

$$ \mathbf{a} \cdot \mathbf{b} = a_1b_1 + a_2b_2 + ... + a_nb_n $$

In other words, it's the sum of the products of the corresponding entries of the two sequences of numbers.

For example, if we have two 3-dimensional vectors ($ \mathbf{a} = [a_1, a_2, a_3] $) and ( $\mathbf{b} = [b_1, b_2, b_3] $), their dot product would be:

$$ \mathbf{a} \cdot \mathbf{b} = a_1b_1 + a_2b_2 + a_3b_3 $$

The dot product is widely used in physics and engineering to calculate the angle between two vectors, the length of a vector, and the projection of one vector onto another, among other things.

继续点积相乘:

        

       

结果:

最后放一个三个矩阵相乘的:

来自 ChatGPT 和 Wolfram


参考资料:

How to Multiply Matrices

ChatGPT with Plugins