Results 1 to 4 of 4

Thread: Matrix Algebra

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    56

    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?

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151
    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.

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    56
    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)

  4. #4
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151
    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:
    1. Dim A(0 To 10, 0 To 10) As Double
    2. Dim B(0 To 10, 0 To 10) As Double
    3. Dim Product(0 To 10, 0 To 10) As Double
    4.  
    5. Dim J As Integer
    6. Dim K As Integer
    7. Dim X As Integer
    8.  
    9.  
    10. For J = 0 To 10
    11.         For K = 0 To 10
    12.                 Product(J, K) = A(J, X) * B(X, K)
    13.                 For X = 1 To 10
    14.                         Product(J, K) = Product(J, K) + A(J, X) * B(X, K)
    15.                     Next X
    16.             Next K
    17.     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
  •  



Click Here to Expand Forum to Full Width