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

  1.     marith(lra,lrb,lrc,nrow,ncol,iflag,a,b,c,scalar)
  2.  
  3.       /*this function performs matrix addition, subtraction, and*/
  4.       /*multiplication by a constant, as specified by the control*/
  5.       /*parameter iflag.*/
  6.  
  7.       int lra,lrb,lrc,nrow,ncol,iflag;
  8.       float a[],b[],c[],scalar;
  9.     {
  10.       int i,j,ija,ijb,ijc;
  11.       float x;
  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 = b[ijb];
  22.          if (iflag != 1 && iflag != 2) x *= scalar;
  23.          if (iflag == 2 || iflag == 5) x = -x;
  24.          if (iflag != 3) x += a[ija];
  25.          c[ijc] = x;
  26.          ija++;
  27.          ijb++;
  28.          ijc++;
  29.         }       /* end of j loop */
  30.       }         /* end of i loop */
  31.     }
  32.