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

  1.     cmamul(lra,lrb,lrc,i,j,k,ar,ai,br,bi,cr,ci)
  2.  
  3.       /*purpose... the multiplication of two two-dimensional*/
  4.       /*matrices with complex elements.*/
  5.  
  6.       int lra,lrb,lrc,i,j,k;
  7.       float ar[],ai[],br[],bi[],cr[],ci[];
  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.         cr[lm] = 0.0;
  20.         ci[lm] = 0.0;
  21.         for(n = 0; n <= j - 1; n++)     /* cols of a */
  22.         {
  23.          cr[lm] += ar[ln]*br[nm]-ai[ln]*bi[nm];
  24.          ci[lm] += ar[ln]*bi[nm] + ai[ln]*br[nm];
  25.          nm += lrb;                     /* advance 1 row in B */
  26.          ln++;                          /* advance 1 col in A */
  27.         }         /* end of n loop */
  28.         lm++;                           /* advance 1 col in C */
  29.        }          /* end of m loop */
  30.       }           /* end of l loop */
  31.     }
  32.