/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:14 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_sblas3 s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include #include #include "p_sblas3.h" /* program DRSBLAS3 *>> 2001-05-22 DRSBLAS3 Krogh Minor change for making .f90 version. *>> 1996-05-28 DRSBLAS3 Krogh Added external statement. *>> 1994-10-19 DRSBLAS3 Krogh Changes to use M77CON *>> 1992-03-16 DRSBLAS3 CLL *>> 1991-07-25 DRSBLAS3 CLL * * Demonstrate usage of * SASUM, SNRM2, SSCAL, SSWAP, and ISAMAX * from the BLAS. * Also uses SAXPY. * ------------------------------------------------------------------ *--S replaces "?": DR?BLAS3, ?AXPY, ?ASUM, ?NRM2 *--& ?SCAL, ?SWAP, I?AMAX * ------------------------------------------------------------------ */ /* PARAMETER translations */ #define M3 10 #define M4 12 #define N3 3 #define N4 4 /* end of PARAMETER translations */ int main( ) { long int it1, j, _i, _r; float t1; static float b[M3], c[5], c2[5], c3[5], d[5], d2[5], d3[5], e[M4][M3]; static int _aini = 1; /* OFFSET Vectors w/subscript range: 1 to dimension */ float *const B = &b[0] - 1; float *const C = &c[0] - 1; float *const C2 = &c2[0] - 1; float *const C3 = &c3[0] - 1; float *const D = &d[0] - 1; float *const D2 = &d2[0] - 1; float *const D3 = &d3[0] - 1; /* end of OFFSET VECTORS */ if( _aini ){ /* Do 1 TIME INITIALIZATIONS! */ { static float _itmp0[] = {7.0e0,-3.0e0,5.0e0}; for (j = 1, _r = 0; j <= N3; j++) { B[j] = _itmp0[_r++]; } } { static float _itmp1[] = {7.0e0,-3.0e0,5.0e0,-4.0e0,1.0e0}; for (j = 1, _r = 0; j <= 5; j++) { C[j] = _itmp1[_r++]; } } { static float _itmp2[] = {7.0e0,-3.0e0,5.0e0,-4.0e0,1.0e0}; for (j = 1, _r = 0; j <= 5; j++) { C2[j] = _itmp2[_r++]; } } { static float _itmp3[] = {7.0e0,-3.0e0,5.0e0,-4.0e0,1.0e0}; for (j = 1, _r = 0; j <= 5; j++) { C3[j] = _itmp3[_r++]; } } { static float _itmp4[] = {14.0e0,-6.0e0,10.0e0,-8.0e0,2.0e0}; for (j = 1, _r = 0; j <= 5; j++) { D[j] = _itmp4[_r++]; } } { static float _itmp5[] = {14.0e0,-6.0e0,10.0e0,-8.0e0,2.0e0}; for (j = 1, _r = 0; j <= 5; j++) { D2[j] = _itmp5[_r++]; } } { static float _itmp6[] = {14.0e0,-6.0e0,10.0e0,-8.0e0,2.0e0}; for (j = 1, _r = 0; j <= 5; j++) { D3[j] = _itmp6[_r++]; } } { static float _itmp7[] = {-4.0e0,2.0e0,3.0e0,-6.0e0}; for (j = 1, _r = 0; j <= N4; j++) { e[j - 1][0] = _itmp7[_r++]; } } { static float _itmp8[] = {7.0e0,5.0e0,-6.0e0,-3.0e0}; for (j = 1, _r = 0; j <= N4; j++) { e[j - 1][1] = _itmp8[_r++]; } } { static float _itmp9[] = {3.0e0,4.0e0,-2.0e0,5.0e0}; for (j = 1, _r = 0; j <= N4; j++) { e[j - 1][2] = _itmp9[_r++]; } } _aini = 0; } /* --------------------------------------------------------------- * */ t1 = sasum( N3, b, 1 ) - 15.0e0; printf("Test of SASUM(): %g \n", t1); t1 = snrm2( 5, c, 1 ) - 10.0e0; printf("Test of SNRM2(): %g \n", t1); sscal( 5, 2.0e0, c2, 1 ); saxpy( 5, -1.0e0, c2, 1, d2, 1 ); t1 = sasum( 5, d2, 1 ); printf("Test of SSCAL(): %g \n", t1); sswap( 5, c3, 1, d3, 1 ); saxpy( 5, -1.0e0, c, 1, d3, 1 ); saxpy( 5, -1.0e0, d, 1, c3, 1 ); t1 = sasum( 5, c3, 1 ) + sasum( 5, d3, 1 ); printf("Test of SSWAP(): %g \n", t1); it1 = isamax( N4, &e[0][0], M3 ) - 4; printf("Test of ISAMAX(): %ld \n", it1); exit(0); } /* end of function */