Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB.net: Multiplying matrices using arrays.....

Options
  • 18-03-2005 3:09pm
    #1
    Registered Users Posts: 323 ✭✭


    Ok, I was just being lazy by trying to get the full answer to my assignment by asking for the full answer!! But, now i've a more specific problem for this assignment.

    How exactly do you multiply 2 (3 by 3) matrices together using arrays in VB.net? There is surely a shorter way of doing it than simply typing out the full formula for multiplying two 3*3 matrices i.e. array(1,2)*array(1,1), etc.

    Thanks!


Comments

  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I can't remember how matrices are multiplied together but I'm thinking that to code it you need to be using nested for loops e.g.
    FOR x = 1 TO 3
       FOR y = 1 TO 3
          'Do something with x and y here
       LOOP
    LOOP
    


  • Registered Users Posts: 323 ✭✭BangBeater


    thanks. I'm trying something like that at the moment, bt havn't got it working yet.


  • Closed Accounts Posts: 5 FunBobby


    I'm not sure if this is exactly what you want, but if its not please reply:

    If you have two (3,3) matrices (or two-dimensional arrays) called A and B,
    to multiply each cell in Matrix A by its corresponding cell in Matrix B, to produce a resultset Matrix C :


    For x = 0 to 2 ' Loop (along the columns)
    For y = 0 to 2 ' Loop (within each column along the rows)
    C(x,y) = A(x,y) * B(x,y)
    Print "C" & x & y & "=" C(x,y)
    Next y
    Next x

    (Assumes your matrix is zero based)


Advertisement