/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:19 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_sspge s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include #include #include "p_sspge.h" /*>> 2006-03-11 DRSSPGE Krogh Initial code. *--S replaces "?": DR?SPGE, ?SPGE * Demo driver for DRSPGE */ /* PARAMETER translations */ #define LA 300 #define LIA (LA + 5*N) #define N 6 /* end of PARAMETER translations */ int main( ) { long int i, j, k, _i, _r; static long int ia[LA + 5*N]; float bb[N], errres, errx, opt[3], size; static float a[LA]; static float x[N]={-2.0e0,-1.0e0,-2.0e0,-1.0e0,-1.0e0,-1.0e0}; static float b[N]={8.0e0,6.0e0,-2.0e0,-1.0e0,5.0e0,-1.0e0}; static long ispec[7]={0,LIA,LA,0,3,4,0}; static int _aini = 1; /* OFFSET Vectors w/subscript range: 1 to dimension */ float *const A = &a[0] - 1; float *const B = &b[0] - 1; float *const Bb = &bb[0] - 1; long *const Ia = &ia[0] - 1; long *const Ispec = &ispec[0] - 1; float *const Opt = &opt[0] - 1; float *const X = &x[0] - 1; /* end of OFFSET VECTORS */ if( _aini ){ /* Do 1 TIME INITIALIZATIONS! */ Ia[1] = 2; A[1] = 0.e0; Ia[2] = 1; A[2] = -2.e0; Ia[3] = 4; A[3] = 1.e0; Ia[4] = 1; A[4] = 0.e0; Ia[5] = 3; A[5] = -2.e0; Ia[6] = 2; A[6] = 0.e0; Ia[7] = 2; A[7] = -2.e0; Ia[8] = 5; A[8] = -2.e0; Ia[9] = 3; A[9] = 0.e0; Ia[10] = 1; A[10] = -1.e0; Ia[11] = 5; A[11] = -1.e0; Ia[12] = 6; A[12] = 2.e0; Ia[13] = 5; A[13] = 0.e0; Ia[14] = 1; A[14] = -1.e0; Ia[15] = 2; A[15] = -2.e0; Ia[16] = 3; A[16] = 2.e0; Ia[17] = 4; A[17] = -1.e0; Ia[18] = 6; A[18] = -2.e0; Ia[19] = 3; A[19] = 0.e0; Ia[20] = 1; A[20] = -2.e0; Ia[21] = 3; A[21] = 2.e0; Ia[22] = 6; A[22] = 1.e0; _aini = 0; } for (i = 1; i <= N; i++) { Bb[i] = B[i]; } /* Call SSPGE to get the solution */ sspge( N, ispec, ia, a, b, opt ); /* Get maximal errors in the residual and the solution. */ errres = 0.e0; size = 0.e0; k = 1; for (j = 1; j <= N; j++) { for (i = k + 1; i <= (k + Ia[k]); i++) { size = fmaxf( size, fabsf( A[i]*X[j] ) ); Bb[Ia[i]] += -A[i]*B[j]; } k = i; } for (j = 1; j <= N; j++) { errres = fmaxf( errres, fabsf( Bb[j] ) ); } errres /= size; errx = 0.e0; for (i = 1; i <= N; i++) { errx = fmaxf( errx, fabsf( X[i] - B[i] ) ); } i = (long)( log10f( fabsf( Opt[2] ) ) ); if (i > 0) i += 1; Opt[2] *= powif(10.e0,-i); i += nint( Opt[3] ); printf(" Problem N RESERR XERR Unused Used RCOND DET x10^?\n"); printf("DEMOTEST 6%10.2e%10.2e%8ld%8ld%10.2e%9.5f%6ld\n", errres, errx, Ispec[4], Ispec[3] - Ispec[4], Opt[1], Opt[2], i); exit(0); } /* end of function */