|
-
Mar 30th, 2003, 09:54 PM
#1
Thread Starter
Member
Matrix Algebra
Can anyone provide me with an algorithm to multiply 2 matrices (If possible it needs to work with vectors too) for vb.net?
-
Mar 31st, 2003, 12:09 AM
#2
Frenzied Member
Productrowcolumn = Sum[ Arowx * Bxcolumn ] for all values of x.
Where Product is the matrix product of matrices A, B
Note that for matrices, multiplication is not commutative: A*B seldom equals B*A
If you do not grok the above formula, the following is the formula for The element in row 2 column 3 of the product of A and B, assuming A and B are 4X4 matrices.
Product23 = A21* B13 + A22* B23 + A23* B3 3 + A24* B43
Superscripts represent rows and sub scripts represent colums.
Note that rectangular matrices can be multiplied.
If A is a 4X5 (4 rows & 5 columns), while B is a 5X4 (5 rows & 4 columns), the above general formula would work. The product would be a 4X4 matrix. For the element in row 2 column 3, the formula would be the following.
Product23 = A21* B13 + A22* B23 + A23* B3 3 + A24* B43 + A25* B53
The above uses tensor notation. For vectors, ordinary notation is usually used.
Product = A1* B1 + A2* B21 + A3* B3
Where Product is the scalar product of two 3D vectors: A & B.
Tensor notation is preferred for matrices because there is an obvious pattern to correct formulae, making it easy to find typo's
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Mar 31st, 2003, 07:24 AM
#3
Thread Starter
Member
I know that already. Can anyone post vbcode to do it? (I was taught a while ago, and was dependant on a calculator to do it)
-
Mar 31st, 2003, 09:53 AM
#4
Frenzied Member
Brian728s: Post code for this? How much do you know about VB syntax and programming?
I do not use VB Net, but it cannot be that much different from VB 6.0
How about something like the following?
VB Code:
Dim A(0 To 10, 0 To 10) As Double
Dim B(0 To 10, 0 To 10) As Double
Dim Product(0 To 10, 0 To 10) As Double
Dim J As Integer
Dim K As Integer
Dim X As Integer
For J = 0 To 10
For K = 0 To 10
Product(J, K) = A(J, X) * B(X, K)
For X = 1 To 10
Product(J, K) = Product(J, K) + A(J, X) * B(X, K)
Next X
Next K
Next J
Perhaps you need a good book (try one of Sam's) or a course. The above should be easy once you know the matrix multiply algorithm. I think you need more help than you can find here.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|