View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Matrix multiplication of more than 73 X 73 entities in VBA

Yes it should.

--
Regards,
Tom Ogilvy

"Alan Beban" <unavailable wrote in message
...
Should the 3rd line be

If rngA.Columns.Count < rngB.Rows.Count Then ?

Alan Beban


Tom Ogilvy wrote:
Here would be the basic approach. You can add more error checking:

Function MyMMULT(rngA As Range, rngB As Range)
Dim ArrC() As Double
If rngA.Rows.Count < rngB.Columns.Count Then
MyMMULT = CVErr(xlErrRef)
Exit Function
End If
ReDim ArrC(1 To rngA.Rows.Count, 1 To rngB.Columns.Count)
For i = 1 To rngA.Rows.Count
For j = 1 To rngB.Columns.Count
For k = 1 To rngA.Columns.Count
ArrC(i, j) = ArrC(i, j) + rngA(i, k) * rngB(k, j)
Next k
Next j
Next i
MyMMULT = ArrC
End Function