/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:08 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_dblas3 s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include #include #include "p_dblas3.h" /* program DRDBLAS3 *>> 2001-05-22 DRDBLAS3 Krogh Minor change for making .f90 version. *>> 1996-05-28 DRDBLAS3 Krogh Added external statement. *>> 1994-10-19 DRDBLAS3 Krogh Changes to use M77CON *>> 1992-03-16 DRDBLAS3 CLL *>> 1991-07-25 DRDBLAS3 CLL * * Demonstrate usage of * DASUM, DNRM2, DSCAL, DSWAP, and IDAMAX * from the BLAS. * Also uses DAXPY. * ------------------------------------------------------------------ *--D 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; double t1; static double 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 */ double *const B = &b[0] - 1; double *const C = &c[0] - 1; double *const C2 = &c2[0] - 1; double *const C3 = &c3[0] - 1; double *const D = &d[0] - 1; double *const D2 = &d2[0] - 1; double *const D3 = &d3[0] - 1; /* end of OFFSET VECTORS */ if( _aini ){ /* Do 1 TIME INITIALIZATIONS! */ { static double _itmp0[] = {7.0e0,-3.0e0,5.0e0}; for (j = 1, _r = 0; j <= N3; j++) { B[j] = _itmp0[_r++]; } } { static double _itmp1[] = {7.0e0,-3.0e0,5.0e0,-4.0e0,1.0e0}; for (j = 1, _r = 0; j <= 5; j++) { C[j] = _itmp1[_r++]; } } { static double _itmp2[] = {7.0e0,-3.0e0,5.0e0,-4.0e0,1.0e0}; for (j = 1, _r = 0; j <= 5; j++) { C2[j] = _itmp2[_r++]; } } { static double _itmp3[] = {7.0e0,-3.0e0,5.0e0,-4.0e0,1.0e0}; for (j = 1, _r = 0; j <= 5; j++) { C3[j] = _itmp3[_r++]; } } { static double _itmp4[] = {14.0e0,-6.0e0,10.0e0,-8.0e0,2.0e0}; for (j = 1, _r = 0; j <= 5; j++) { D[j] = _itmp4[_r++]; } } { static double _itmp5[] = {14.0e0,-6.0e0,10.0e0,-8.0e0,2.0e0}; for (j = 1, _r = 0; j <= 5; j++) { D2[j] = _itmp5[_r++]; } } { static double _itmp6[] = {14.0e0,-6.0e0,10.0e0,-8.0e0,2.0e0}; for (j = 1, _r = 0; j <= 5; j++) { D3[j] = _itmp6[_r++]; } } { static double _itmp7[] = {-4.0e0,2.0e0,3.0e0,-6.0e0}; for (j = 1, _r = 0; j <= N4; j++) { e[j - 1][0] = _itmp7[_r++]; } } { static double _itmp8[] = {7.0e0,5.0e0,-6.0e0,-3.0e0}; for (j = 1, _r = 0; j <= N4; j++) { e[j - 1][1] = _itmp8[_r++]; } } { static double _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 = dasum( N3, b, 1 ) - 15.0e0; printf("Test of DASUM(): %g \n", t1); t1 = dnrm2( 5, c, 1 ) - 10.0e0; printf("Test of DNRM2(): %g \n", t1); dscal( 5, 2.0e0, c2, 1 ); daxpy( 5, -1.0e0, c2, 1, d2, 1 ); t1 = dasum( 5, d2, 1 ); printf("Test of DSCAL(): %g \n", t1); dswap( 5, c3, 1, d3, 1 ); daxpy( 5, -1.0e0, c, 1, d3, 1 ); daxpy( 5, -1.0e0, d, 1, c3, 1 ); t1 = dasum( 5, c3, 1 ) + dasum( 5, d3, 1 ); printf("Test of DSWAP(): %g \n", t1); it1 = idamax( N4, &e[0][0], M3 ) - 4; printf("Test of IDAMAX(): %ld \n", it1); exit(0); } /* end of function */