home *** CD-ROM | disk | FTP | other *** search
- /* General form test program for scientific functions */
-
- /* Routine Tested: MARITH */
-
- main()
-
- {
- int iflag,lra,lrb,lrc,nrow,ncol;
- static float a[5][6]={0.,-1.,-2.,-3.,-4.,-5.,
- 1., 0.,-1.,-2.,-3.,-4.,
- 2., 1., 0.,-1.,-2.,-3.,
- 3., 2., 1., 0.,-1.,-2.,
- 4., 3., 2., 1., 0.,-1.
- };
- static float b[5][6]={ 0.,-1.,-2.,-3.,-4.,-5.,
- 1., 0.,-1.,-2.,-3.,-4.,
- 2., 1., 0.,-1.,-2.,-3.,
- 3., 2., 1., 0.,-1.,-2.,
- 4., 3., 2., 1., 0.,-1.
- };
- float c[5][6],scalar;
-
- lra = 6;
- lrb = 6;
- lrc = 6;
- nrow = 5;
- ncol = 6;
- scalar = .5;
-
- /* case 1, add a to b */
- iflag = 1;
- marith(lra,lrb,lrc,nrow,ncol,iflag,a,b,c,scalar);
- printr(c,nrow,ncol); /* print the result */
-
- /* case 2, subtract b from a */
- iflag = 2;
- marith(lra,lrb,lrc,nrow,ncol,iflag,a,b,c,scalar);
- printr(c,nrow,ncol); /* print the result */
-
- /* case 3, multiply b by scalar */
- iflag = 3;
- marith(lra,lrb,lrc,nrow,ncol,iflag,a,b,c,scalar);
- printr(c,nrow,ncol); /* print the result */
-
- /* case 4, multiply b by scalar and add to a */
- iflag = 4;
- marith(lra,lrb,lrc,nrow,ncol,iflag,a,b,c,scalar);
- printr(c,nrow,ncol); /* print the result */
-
- /* case 5, multiply b by scalar and subtract from a */
- iflag = 5;
- marith(lra,lrb,lrc,nrow,ncol,iflag,a,b,c,scalar);
- printr(c,nrow,ncol); /* print the result */
- }
-
- /* Routine to print matrices */
-
- printr(a,nrow,ncol)
-
- int nrow,ncol;
- float a[];
-
- {
- int *fp,j,k,ne;
-
- ne = ncol-1;
-
- *fp=fopen("PRN:","w"); /* open the printer */
-
- fprintf(*fp,"Test Results from MARITH\n\n");
- printf("Test Results from MARITH\n\n");
-
- for(j = 0; j <= nrow-1 ; j++)
- {
- for(k = j*ncol; k <= j*ncol+ne ; k++)
- {
- fprintf(*fp,"%5.1f ",a[k]);
- printf("%5.1f ",a[k]);
- };
- fprintf(*fp,"\n");
- printf("\n");
- }
- fprintf(*fp,"\n\n");
- printf("\n\n");
-
- }
-
- afil(a,b,ne) /* routine to reset array to original form */
-
- int ne;
- float a[],b[];
-
- {
- int i;
-
- for(i = 0; i <= ne-1; i++)
- a[i] = b[i];
- }
-
-
-
-
-