matrix multiplication

This is a discussion on matrix multiplication within the C++ Programming forums, part of the General Programming Boards category; what is the algorithm for the product of two same size matrices?...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    39

    matrix multiplication

    what is the algorithm for the product of two same size matrices?
    once a kohatian,always a kohatian!

  2. #2
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    heres the program of two 3x3 mat. I dug it up from some unknown hidden corner of my comp.


    Code:
    void mulofmatr(void)
    {
     int a[3][3],b[3][3],c[3][3],i,j,p,q,x,y,pro,sum;
     clrscr();
      
     cout<<"ENTER ELEMENTS OF MATRIX A[3][3] :\n";
     for(i=0;i<3;i++)
      for(j=0;j<3;j++)
       cin>>a[i][j];
    
     cout<<"ENTER ELEMENTS OF MATRIX B[3][3] :\n";
     for(i=0;i<3;i++)
      for(j=0;j<3;j++)
       cin>>b[i][j];
    
     for(i=0;i<3;i++)
      for(j=0;j<3;j++)
      {
       p=i;
       q=0;
       x=0;
       y=j;
       sum=0;
       pro=1;
       while(q<=2)
       {
        pro=a[p][q]*b[x][y];
        sum=sum+pro;
        q=q+1;
        x=x+1;
       }
       c[i][j]=sum;
      }
    
      cout<<"\nELEMENTS OF MATRIX C AFTER MULTIPLICATION : ";
      for(i=0;i<3;i++)
     {
      cout<<'\n';
      for(j=0;j<3;j++)
      {
       cout<<c[i][j];
       cout<<"\t";
      }
     }
    
    }
    Last edited by ihsir; 04-18-2002 at 08:33 AM.
    -

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  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 Multiplication ( Accessing data from a file ) HELP
    By six_degreez in forum C Programming
    Replies: 2
    Last Post: 07-24-2008, 05:21 PM
  4. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 04:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21