Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Matrix multiplication of more than 73 X 73 entities in VBA

Hello all,

I interpret that Excel can handle matrix multiplication of "maximum" 73
x 73 entities in one sheet with 73 x 73 entities in another sheet. Is
this correct?

If yes, what could be the VBA code to perform matrix multiplication of
on M x N entities in one sheet with N x P entites in another matrix?
(where M, N and P are greater than 73)

Please help.

Thanks,
Thulasiram.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Matrix multiplication of more than 73 X 73 entities in VBA

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

--
Regards,
Tom Ogilvy


"Thulasiram" wrote in message
oups.com...
Hello all,

I interpret that Excel can handle matrix multiplication of "maximum" 73
x 73 entities in one sheet with 73 x 73 entities in another sheet. Is
this correct?

If yes, what could be the VBA code to perform matrix multiplication of
on M x N entities in one sheet with N x P entites in another matrix?
(where M, N and P are greater than 73)

Please help.

Thanks,
Thulasiram.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Matrix multiplication of more than 73 X 73 entities in VBA

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Matrix multiplication of more than 73 X 73 entities in VBA

Dear Tom Ogilvy,

I multiplied 2x2 matrix with 2x2 matrix and the mymmult function worked
perfect.

BUT, i multiplied 13 x 15 matrix with 15 x 20 matrix.

formula written in the cell A1 of sheet 3 is given below. then
corresponding cells are selcted, pressed F2 followed with Ctrl + Shift
+ Enter

=MMULT(Sheet1!A1:O13,Sheet2!A1:T15) ------- Gives the result

=mymmult(Sheet1!A1:O13,Sheet2!A1:T15) -------- Gives an error #REF!

I also cross-checked by multiplying the matrices (13 x 15 with 15 x 20)
in the same sheet rather in sheet 1 and 2. Still the same error # REF!
exists.

Please help me in this aspect.

Thanks,
Thulasiram.

Tom Ogilvy wrote:
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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Matrix multiplication of more than 73 X 73 entities in VBA

See Tom Ogilvy's post of 8:26pm last night in this thread.

Alan Beban

Thulasiram wrote:
Dear Tom Ogilvy,

I multiplied 2x2 matrix with 2x2 matrix and the mymmult function worked
perfect.

BUT, i multiplied 13 x 15 matrix with 15 x 20 matrix.

formula written in the cell A1 of sheet 3 is given below. then
corresponding cells are selcted, pressed F2 followed with Ctrl + Shift
+ Enter

=MMULT(Sheet1!A1:O13,Sheet2!A1:T15) ------- Gives the result

=mymmult(Sheet1!A1:O13,Sheet2!A1:T15) -------- Gives an error #REF!

I also cross-checked by multiplying the matrices (13 x 15 with 15 x 20)
in the same sheet rather in sheet 1 and 2. Still the same error # REF!
exists.

Please help me in this aspect.

Thanks,
Thulasiram.

Tom Ogilvy wrote:
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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Matrix multiplication of more than 73 X 73 entities in VBA

Alan,

I had a look at both of Tom's reply in this thread and implemented in
the VBA code. Still I get the error. That is the explanation I gave in
my last mail too.

Please help.

Thanks,
Thulasiram

Alan Beban wrote:
See Tom Ogilvy's post of 8:26pm last night in this thread.

Alan Beban

Thulasiram wrote:
Dear Tom Ogilvy,

I multiplied 2x2 matrix with 2x2 matrix and the mymmult function worked
perfect.

BUT, i multiplied 13 x 15 matrix with 15 x 20 matrix.

formula written in the cell A1 of sheet 3 is given below. then
corresponding cells are selcted, pressed F2 followed with Ctrl + Shift
+ Enter

=MMULT(Sheet1!A1:O13,Sheet2!A1:T15) ------- Gives the result

=mymmult(Sheet1!A1:O13,Sheet2!A1:T15) -------- Gives an error #REF!

I also cross-checked by multiplying the matrices (13 x 15 with 15 x 20)
in the same sheet rather in sheet 1 and 2. Still the same error # REF!
exists.

Please help me in this aspect.

Thanks,
Thulasiram.

Tom Ogilvy wrote:
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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Matrix multiplication of more than 73 X 73 entities in VBA

Alan and Tom,

I got the function working for multiplying 13 x 15 with 15 x
20!!!!!!!!!!

It was my mistake that i considered only 'a part' of Tom's 8:26pm post.
Thanks to Alan for notifying it.

Thanks again,
Thulasiram


Alan Beban wrote:
See Tom Ogilvy's post of 8:26pm last night in this thread.

Alan Beban

Thulasiram wrote:
Dear Tom Ogilvy,

I multiplied 2x2 matrix with 2x2 matrix and the mymmult function worked
perfect.

BUT, i multiplied 13 x 15 matrix with 15 x 20 matrix.

formula written in the cell A1 of sheet 3 is given below. then
corresponding cells are selcted, pressed F2 followed with Ctrl + Shift
+ Enter

=MMULT(Sheet1!A1:O13,Sheet2!A1:T15) ------- Gives the result

=mymmult(Sheet1!A1:O13,Sheet2!A1:T15) -------- Gives an error #REF!

I also cross-checked by multiplying the matrices (13 x 15 with 15 x 20)
in the same sheet rather in sheet 1 and 2. Still the same error # REF!
exists.

Please help me in this aspect.

Thanks,
Thulasiram.

Tom Ogilvy wrote:
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matrix multiplication algorithm wauer Excel Discussion (Misc queries) 0 October 7th 09 10:38 AM
Matrix Multiplication Jeff Excel Discussion (Misc queries) 1 January 18th 06 08:15 PM
Matrix Multiplication Matrix Bill Excel Worksheet Functions 1 October 6th 05 06:53 PM
matrix multiplication Carine Excel Worksheet Functions 4 July 6th 05 08:06 PM
matrix multiplication Sam Excel Programming 3 September 17th 03 03:20 PM


All times are GMT +1. The time now is 01:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"