home *** CD-ROM | disk | FTP | other *** search
- /* General form test program for scientific functions */
-
- /* Routine Tested: MAELEM */
-
- main()
-
- {
- int i,iflag,j,lra,nrow,ncol,ne;
- float a[48],s;
- static float b[48]={2., 3., 4., 5., 6., 7.,
- 3., 4., 5., 6., 7., 8.,
- 4., 5., 6., 7., 8., 9.,
- 5., 6., 7., 8., 9.,10.,
- 6., 7., 8., 9.,10.,11.,
- 7., 8., 9.,10.,11.,12.,
- 8., 9.,10.,11.,12.,13.,
- 9.,10.,11.,12.,13.,14.
- };
-
-
- lra = 6;
- nrow = 8;
- ncol = 6;
- ne = nrow*ncol;
-
- /* First case, multiply row 4 by the scalar 5.0 */
- afil(a,b,ne); /* fill array for start */
- i = 4;
- s = 5.0;
- iflag = 1;
- maelem(lra,nrow,ncol,a,i,j,s,iflag);/* call the function */
- printr(a,nrow,ncol); /* print the result */
-
-
- /* Second case, switch rows 5 and 2 */
- afil(a,b,ne); /* fill array for start */
- i = 5;
- j = 2;
- iflag = 2;
- maelem(lra,nrow,ncol,a,i,j,s,iflag);/* call the function */
- printr(a,nrow,ncol); /* print the result */
-
- /* Third case, multiply row 3 by 4.0 and add the result to row 5 */
- afil(a,b,ne); /* fill array for start */
- i = 5;
- j = 3;
- s = 4.0;
- iflag = 3;
- maelem(lra,nrow,ncol,a,i,j,s,iflag);/* call the function */
- printr(a,nrow,ncol); /* print the result */
-
- /* Fourth case, multiply column 4 by the scalar 5.0 */
- afil(a,b,ne); /* fill array for start */
- i = 4;
- s = 5.0;
- iflag = 4;
- maelem(lra,nrow,ncol,a,i,j,s,iflag);/* call the function */
- printr(a,nrow,ncol); /* print the result */
-
- /* Fifth case, switch columns 5 and 2 */
- afil(a,b,ne); /* fill array for start */
- i = 5;
- j = 2;
- iflag = 5;
- maelem(lra,nrow,ncol,a,i,j,s,iflag);/* call the function */
- printr(a,nrow,ncol); /* print the result */
-
- /* Sixth Case, multiply column 3 by 4.0 and add the result to column 5 */
- afil(a,b,ne); /* fill array for start */
- i = 5;
- j = 3;
- s = 4.0;
- iflag = 6;
- maelem(lra,nrow,ncol,a,i,j,s,iflag);/* call the function */
- printr(a,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 MAELEM\n\n");
- printf("Test Results from MAELEM\n\n");
-
- for(j = 0; j <= nrow-1 ; j++)
- {
- for(k = j*ncol; k <= j*ncol+ne ; k++)
- {
- fprintf(*fp,"%4.1f ",a[k]);
- printf("%4.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];
- }
-
-
-
-
-