/* GaussFit - A System for Least Squares and Robust Estimation Source Code Copyright (C) 1987 by William H. Jefferys, Michael J. Fitzpatrick and Barbara E. McArthur All Rights Reserved. */ #define import_spp #define import_libc #define import_stdio #include #include "defines.h" #include "files.h" #include "datum.h" #define NUMVALS 100 /* Depth of Value Stack */ #define NUMSAVES 100 /* Depth of Save Stack of Values */ extern int traceflag; /* trace if this falg is on */ extern FILE *fp; /* result file */ static DATUMPTR valuestack[NUMVALS]; /* value stack ("the stack") */ static int valueptr=0; /* pinter to value stack */ static DATUMPTR savestack[NUMSAVES]; /* stack to save values pooped from valuestack until they are no longer needed */ static int saveptr=0; /* save stack pointer */ DATUMPTR exportstack[MATSIZE]; /* stack to save values pending export */ int exportptr=0; /* export stack pointer */ tracevalue() { if(traceflag >= 2 && valueptr>0) /* print values on top of stack if flag >= 2 */ { fprintf(fp," Stackptr = %d,",valueptr-1); printvalue("_TOS",valuestack[valueptr-1]);/* print the top of stack */ } } markvalue() /* mark all active data structures in stacks */ { int i; for(i=0;i0) /* see if something is there */ { --valueptr; /* decrement pointer */ savestack[saveptr] = valuestack[valueptr]; /* protect object against garbage colleciton */ if(savestack[saveptr]->car) /* see if object popped was a vector */ fatalerror("Popped a vector for a value\n",""); /* if so, error */ if(saveptr0) /* check that something is there */ { --valueptr; /* decrement pointer */ savestack[saveptr] = valuestack[valueptr]; /* protect object against garbage collection */ if(saveptrvalue); /* print the body */ if(traceflag >= 3) { /* print derviatives if tracefalg >= 3 */ while(k = k->next) { /* get next derivative */ /* if (k->name == 0) { fprintf(stderr, "stop!\n"); sleep(15); } */ if(k->index[4]) { /* print indexed paramter */ int i; fprintf(fp," Deriv[%4s", getnam(k->name)); insz = getindexsz(); prIndex(fp, k->index,insz); /* print subscripts */ /* for (i=0; iindex[4]; ++i) { if (i!=0) fprintf(fp,", "); fprintf(fp,"%2d",k->index[i]); } */ fprintf(fp,"] = %lf\n", k->value); } else { /* print global paramter */ fprintf(fp," Deriv[%4s ] = %lf\n", getnam(k->name),k->value); } } } } else fprintf(fp," %4s = %ld\n",name,k); } printvalue(name,k) /* print a scalar or a vector */ char *name; DATUMPTR k; { if(k) { /* only print non-null */ if(k->car) { /* if vector */ int h, i, j, dims, nelems; int div[5]; ArrayBlockPtr a; a = k->car; dims = a->dim[4]; for (i=0,nelems=1; idim[i]; div[0] = div[1] = div[2] = div[3] = 1; for (i=1; idim[j]; } for(h=0;helem[h]); /* points to actual value */ } } else printonevalue(name,k); /* it's a scalar */ } else printonevalue(name,k); }