引用:http://hi.baidu.com/yongjianspaces/blog/item/3f10ae9980ce5e1d6f068c7d.html
Public
Function
Test(a()
As
Byte
, b()
As
Byte
)
As
Variant
Dim i As Integer
Dim c() As Integer
ReDim c( UBound (a, 1 ), UBound (b, 1 ))
For i = 0 To UBound (a, 1 )
’代码自行添加
Dim i As Integer
Dim c() As Integer
ReDim c( UBound (a, 1 ), UBound (b, 1 ))
For i = 0 To UBound (a, 1 )
’代码自行添加
Next
i
Test = c
End Function
Test = c
End Function
Public Function iMUL(a() As Integer, b() As Integer) As Variant
Dim i, j, k As Integer
If UBound(a, 2) <> UBound(b, 1) Then
MsgBox "参数错误,请输入两个可以相乘的矩阵!"
End
End If
Dim c() As Integer
ReDim c(UBound(a, 1), UBound(b, 2))
For i = 0 To UBound(a, 1)
For k = 0 To UBound(b, 2)
c(i, k) = 0
For j = 0 To UBound(a, 2)
c(i, k) = c(i, k) + a(i, j) * b(j, k)
Next j
Next k
Next i
iMUL = c
End Function
Dim i, j, k As Integer
If UBound(a, 2) <> UBound(b, 1) Then
MsgBox "参数错误,请输入两个可以相乘的矩阵!"
End
End If
Dim c() As Integer
ReDim c(UBound(a, 1), UBound(b, 2))
For i = 0 To UBound(a, 1)
For k = 0 To UBound(b, 2)
c(i, k) = 0
For j = 0 To UBound(a, 2)
c(i, k) = c(i, k) + a(i, j) * b(j, k)
Next j
Next k
Next i
iMUL = c
End Function