Exforsys
+ Reply to Thread
Results 1 to 4 of 4

How to write a program to implement matrix

This is a discussion on How to write a program to implement matrix within the C and C++ forums, part of the Programming Talk category; I need a help to write a program to implement the multiplication of 2 (3x3) matrix....

  1. #1
    Prince G is offline Junior Member Array
    Join Date
    May 2011
    Location
    Dianou, Bouafle, Cote D'Ivoire, Côte d'Ivoire
    Answers
    1

    Post How to write a program to implement matrix

    I need a help to write a program to implement the multiplication of 2 (3x3) matrix.


  2. #2
    lokeshm is offline Member Array
    Join Date
    Apr 2005
    Answers
    83
    Pince, You need to make use of loops and arrays. Set the value of two matrices in an array then you can multiply as follows

    product_result = product_result+matrix_1[i][j]*matrix_2[j][k];
    result_matrix[i][k]=product_result;

    Here while writing the program one must remember that in matrix multiplication, the number of columns of first matrix must be equal to the number of rows of second matrix.


  3. #3
    lcarter is offline Junior Member Array
    Join Date
    Jun 2011
    Answers
    4
    I think you should make use of a two dimensional array to handle this type of problem. You need to have 3 2D arrays. Two for the initial arrays to calculate for and one for the result.

    I am not that sure how the exact formula would look like but you have to save them on the third matrix so you could use it.

    There is also an implementation that would require a one dimensional array though it would be harder as you have to take note of the constants to know how you will gather the results.


  4. #4
    rafker is offline Junior Member Array
    Join Date
    Jul 2011
    Answers
    6
    I think the most straight forward approach would be to make use of a 2d array with the bounds set to the corresponding x and y of your matrix.

    If you are going to access each one of them, I suggest that you use a loop within a loop to make everything automated. Though, if you concern would be the big oh of the whole code, then this would not be an option for you because that alone would ensure a big oh of n squared.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...