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

  1.    cmaari(lra,lrb,lrc,nrow,ncol,iflag,ar,ai,br,bi,cr,ci,scr,sci)
  2.  
  3.       /*purpose... to perform addition, subtraction, and*/
  4.       /*multiplication on a matrix with complex elements*/
  5.       /*by a complex constant.*/
  6.  
  7.       int lra,lrb,lrc,nrow,ncol,iflag;
  8.       float ar[],ai[],br[],bi[],cr[],ci[],scr,sci;
  9.     {
  10.       int i,j,ija,ijb,ijc;
  11.       float dr,di,x,y;
  12.  
  13.       for(i = 0; i <= nrow-1; i++)
  14.       {
  15.        ija = i * lra;
  16.        ijb = i * lrb;
  17.        ijc = i * lrc;
  18.  
  19.        for(j = 0; j <= ncol-1; j++)
  20.         {
  21.          x = br[ijb];
  22.          y = bi[ijb];
  23.          if(iflag == 1 || iflag ==2) goto b10;
  24.           dr = scr * x - sci * y;
  25.           di = scr * y + sci * x;
  26.           cr[ijc] = dr;
  27.           ci[ijc] = di;
  28.          if(iflag != 4 && iflag != 5) goto b20;
  29.          if(iflag != 4)
  30.           {dr = -dr;
  31.            di = -di;}
  32.          cr[ijc] = ar[ija] + dr;
  33.          ci[ijc] = ai[ija] + di;
  34.           goto b20;
  35.  b10:    if(iflag != 1)
  36.           {x = -x;
  37.            y = -y;}
  38.          cr[ijc] = ar[ija] + x;
  39.          ci[ijc] = ai[ija] + y;
  40.  
  41.  b20:    ija++;
  42.          ijb++;
  43.          ijc++;
  44.         }       /* end of j loop */
  45.       }         /* end of i loop */
  46.     }
  47.  
  48.