矩阵乘法就是两个矩阵(第一个矩阵A的列数必须和第二个矩阵B的行数相等)相乘
得到一个A矩阵行B矩阵列的一个矩阵C
这里举例:(代码如下)
Dim A(5, 10), B(10, 6), C(5, 6) As Double, I, J, K, N, M, P As Integer
Private Sub Form_Load()
Show
Cls
N = 2: P = 4: M = 2
A(1, 1) = -4.513: A(1, 2) = -7.82: A(1, 3) = -11.184: A(1, 4) = -14.7185: A(2, 1) = 1: A(2, 2) = 1: A(2, 3) = 1: A(2, 4) = 1 'A矩阵
B(1, 1) = -4.513: B(1, 2) = 1: B(2, 1) = -7.82: B(2, 2) = 1: B(3, 1) = -11.184: B(3, 2) = 1: B(4, 1) = -14.7185: B(4, 2) = 1 'B矩阵
For I = 1 To N: For J = 1 To M: C(I, J) = 0
For K = 1 To P: C(I, J) = C(I, J) + A(I, K) * B(K, J): Next K: Print C(I, J);: Next J: Print: Next I '显示C矩阵
End Sub