Results 1 to 5 of 5

Thread: Program to explain the multiplication of the two matrix

  1. #1
    Join Date
    Nov 2009
    Posts
    1,118

    Program to explain the multiplication of the two matrix

    Hi Friends,

    I have to write the program for the multiplication of the two matrix. But unfortunately my "matrix multiplication" is still not clear.

    Can you provide me the program code which will explain the multiplication of the two matrix? Code in any programming language will work for me.

    Any help will be appreciated..
    Last edited by Roxy_jacob; 01-12-2009 at 11:37 AM.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Program to explain the multiplication of the two matrix

    Hi,

    Below is the java program which is I have used for the matrix multiplication.

    When you will run following program , you will get the multiplication of the two matrix which is provided in the program code:

    class MatrixMultiplyDemo

    {
    public static void main(String[] args)
    {
    int arraydemo[][]= {{15,16,17},{14,18,19}};
    int arraydemo1[][]= {{16,14,18},{15,17,18}};
    int z= arraydemo.length;

    System.out.println("Matrix 1 : ");
    for(int a = 0; a < z; a++) {
    for(int b = 0; b <= z; b++) {
    System.out.print(" "+ arraydemo[i][j]);
    }
    System.out.println();
    }
    int y= arraydemo1.length;
    System.out.println("Matrix 2 : ");
    for(int a = 0; a < y; a++) {
    for(int b = 0; b <= y; b++) {
    System.out.print(" "+arraydemo1[a][b]);
    }
    System.out.println();
    }
    System.out.println("Multiply of both matrix : ");
    for(int a = 0; a < y; a++) {
    for(int b = 0; b <= y; b++) {
    System.out.print(" "+(arraydemo[i][j]*arraydemo1[i][j]));
    }
    System.out.println();
    }
    }
    }

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Program to explain the multiplication of the two matrix

    Hi friends,

    Following program will demonstrate you the technique of multiplying two matrix.

    I have written the program which shows the output of multiplication of the first matrix "matr1" with the second matrix "matr2".

    Code:

    Void main()

    {

    int matr1[3][3] = {11,12,13,14,15,16};
    int matt2[3][3] = {11,12,13,14,15,16};

    int r[3][3];
    nt a,b,c;

    for (a=0; a<3; a++)
    for (b=0; b<3; b++)

    r[i][a] = 0;

    for (b=0; b<3; b++)
    for (b=0; b<3; b++)
    for (c=0; c<3; c++)

    *(*(r + a) + b) += (*(*(matt1 + a) + c)) * (*(*(matr2 + c)
    + j));

    for (a=0; a<3; a++)
    {
    for (b=0; b<3; b++)

    printf ("%d\t", res[a][b]);
    printf ("\n");
    }
    printf("\n");
    }


  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Program to explain the multiplication of the two matrix

    Hi all,

    I think you should use for loop to achieve the matrix multiplication.
    Please use the below for loop in your program code.

    See something following will helpful to code the program:

    for(x=0;x<n;x++)
    {
    for(y=0;y<k;y++)
    {
    n2[x][y]=0;
    for(p=0;p<k;p++)
    {
    n2[x][y]=n2[g][x] + (n[x][t] * n1[e][y]);
    }
    }
    }

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Program to explain the multiplication of the two matrix

    Hi,

    I don't now the exact logic to print the multiplication of the two given matrix. I think simple looping structure will also woks for this.
    You can use nested for loops OR nested While loop OR nested If loop in your program. I am telling you to use loop nesting concept because , the programming logic required for matrix multiplication is very complicated.

Similar Threads

  1. New Matrix Movie (Matrix ReEntered)
    By Vicious in forum Off Topic Chat
    Replies: 8
    Last Post: 08-02-2011, 08:24 PM
  2. Print multiplication table
    By MaryJ in forum Software Development
    Replies: 1
    Last Post: 19-11-2010, 10:26 PM
  3. Replies: 4
    Last Post: 25-09-2010, 05:11 PM
  4. Replies: 4
    Last Post: 25-09-2010, 05:06 PM
  5. Matrix Program
    By Zidaan in forum Software Development
    Replies: 7
    Last Post: 10-12-2008, 06:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,697,017.69075 seconds with 17 queries