home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-SSP.ARJ / MATMUL.TST < prev    next >
Encoding:
Text File  |  1984-08-31  |  1.8 KB  |  81 lines

  1.         /* General form test program for scientific functions */
  2.  
  3.         /* Routine Tested:  MATMUL */
  4.  
  5.         main()
  6.  
  7.         {
  8.         int lra,lrb,lrc,i,j,k;
  9.         static float a[4][5]={0.,-1.,-2.,-3.,-4.,
  10.                               1., 0.,-1.,-2.,-3.,
  11.                               2., 1., 0.,-1.,-2.,
  12.                               3., 2., 1., 0.,-1.
  13.                              };
  14.         static float b[5][3]={-1.,-3.,-5.,
  15.                                0.,-2.,-4.,
  16.                                1.,-1.,-3.,
  17.                                2., 0.,-2.,
  18.                                3., 1.,-1.
  19.                              };
  20.         float c[4][3];
  21.  
  22.         lra = 5;
  23.         lrb = 3;
  24.         lrc = 3;
  25.         i = 4;
  26.         j = 5;
  27.         k = 3;
  28.  
  29.         matmul(lra,lrb,lrc,i,j,k,a,b,c);    /* call the function */
  30.         printr(c,i,k);                      /* print the result  */
  31.         }
  32.  
  33.                 /* Routine to print matrices */
  34.  
  35.       printr(a,nrow,ncol)
  36.  
  37.         int nrow,ncol;
  38.         float a[];
  39.  
  40.       {
  41.         int *fp,j,k,ne;
  42.  
  43.         ne = ncol-1;
  44.  
  45.         *fp=fopen("PRN:","w");                 /* open the printer */
  46.  
  47.         fprintf(*fp,"Test Results from MATMUL\n\n");
  48.          printf("Test Results from MATMUL\n\n");
  49.  
  50.         for(j = 0; j <= nrow-1 ; j++)
  51.          {
  52.           for(k = j*ncol; k <= j*ncol+ne ; k++)
  53.            {
  54.             fprintf(*fp,"%5.1f  ",a[k]);
  55.              printf("%5.1f  ",a[k]);
  56.            };
  57.            fprintf(*fp,"\n");
  58.             printf("\n");
  59.          }
  60.            fprintf(*fp,"\n\n");
  61.             printf("\n\n");
  62.  
  63.        }
  64.  
  65.   afil(a,b,ne)          /* routine to reset array to original form */
  66.  
  67.         int ne;
  68.         float a[],b[];
  69.  
  70.      {
  71.         int i;
  72.  
  73.         for(i = 0; i <= ne-1; i++)
  74.           a[i] = b[i];
  75.      }
  76.  
  77.  
  78.  
  79.  
  80.  
  81.