Thread: matrix multiplication

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    2

    Thumbs down matrix multiplication

    matrix multiplication
    I have some problems with function when using arrays,
    I have problem to claculate two matrix multiplication by using three functions
    function1:-getting values from keyboard
    function2:multyplication.
    function3:display values.

    does any can have idea to do that
    thank you!

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    you pass a pointer of the matrix array to function1 and let it input the numbers.
    you pass two pointer of the matrices you want to mult to function2, and a third pointer as the result matrix.
    you again pass the pointer of the multiplied matrix to function3 to print it.
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    2
    I have poor knowledge about pointers can little bit explain the answer?

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Sorry, but i'm no expert. You'd better read the site tutorials before going on.
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    107
    In general, you have M1, an s-by-r matrix and M2 a, t-by-u matrix. The operation is defined if and only if r=t. (Definition of matrix multiplication). The dimension of the result is s-by-u. Finally, each element is an inner product of rows of M1 and columns of M2. You want a triple nested for loop of some kind:

    Code:
    for(int i = 0; i < s; i++)
    {
    	for(int j = 0; i < u; j++)
            {
                    result[i][j] = 0;
    		for(int k = 0; k < r; k++)
    			result[i][j] += m1[i][k] * m2[k][j];
            }
    }
    I can't guarantee that's what you want, but that's pretty damn close. Hopefully the rest of the forum won't skin me alive.
    Last edited by QuadraticFighte; 10-23-2010 at 12:33 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting Matrix
    By alex 2010 in forum C++ Programming
    Replies: 0
    Last Post: 06-24-2010, 09:40 AM
  2. *operator overloading: scalar matrix multiplication
    By gemini_shooter in forum C++ Programming
    Replies: 4
    Last Post: 06-08-2009, 01:14 PM
  3. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 05:57 PM
  4. What is a matrix's purpose in OpenGL
    By jimboob in forum Game Programming
    Replies: 5
    Last Post: 11-14-2004, 12:19 AM