home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-SSP.ARJ / MATMUL.C < prev    next >
Encoding:
Text File  |  1984-06-15  |  936 b   |  31 lines

  1.     matmul(lra,lrb,lrc,i,j,k,a,b,c)
  2.  
  3.       /*this function performs the multiplication of two*/
  4.       /*two-dimensional matrices:  c(i,k)=a(i,j)*b(j,k) */
  5.  
  6.       float a[],b[],c[];
  7.       int lra,lrb,lrc,i,j,k;
  8.  
  9.     {
  10.       int l,lm,ln,m,n,nm;
  11.  
  12.       for(l = 0; l <= i-1; l++)         /* rows of a */
  13.       {
  14.        lm = l * lrc;
  15.        for(m = 0; m <= k-1; m++)        /* cols of b */
  16.        {
  17.         ln = l * lra;
  18.         nm = m;
  19.         c[lm] = 0.0;
  20.         for(n = 0; n <= j - 1; n++)     /* cols of a */
  21.         {
  22.          c[lm] += a[ln]*b[nm];          /* c[l,m] += a[l,n]*b[n,m] */
  23.          nm += lrb;                     /* advance 1 row in B */
  24.          ln++;                          /* advance 1 col in A */
  25.         }         /* end of n loop */
  26.         lm++;                           /* advance 1 col in C */
  27.        }          /* end of m loop */
  28.       }           /* end of l loop */
  29.     }
  30.  
  31.