#include #include "structs.h" #define TO 0 #define FROM 1 int istrunc (char *objtype); void copy_pars (float a[], int ia[], struct fitpars *fpar, int dir) { int i; static int k = 0; static int high = 0; struct fitpars *h; if (fpar != NULL) { for (i = 1; i<= fpar->npars; i++) { /*------------------------------------------------------\ | Truncation parameters in the fpar->high structures | | are only pointers to the real truncationstructure | | stored elsewhere. So these parameters shouldn't | | be counted multiple times. | \------------------------------------------------------*/ if (high == 0 || (high == 1 && !istrunc (fpar->objtype))) { k++; if (dir == TO) { fpar->a[i] = a[k]; } else if (dir == FROM ) { a[k] = fpar->a[i]; ia[k] = fpar->ia[i]; }; }; }; /* Go into high order list if high == 1 */ if (high == 1 && fpar->next != NULL) copy_pars (a, ia, fpar->next, dir); /*----------------------------------------------------------\ | Check to see if there are high order terms. | | fpar->high->high parameters are only mirror parameters, | | so they don't count as free parameters. | \----------------------------------------------------------*/ else if (fpar->high != NULL && high == 0) { high += 1; copy_pars (a, ia, fpar->high, dir); high -= 1; /* keep track of when we pop out of this list */ } ; /* No high order terms or just exiting high order terms */ if (high == 0 && fpar->next != NULL) copy_pars (a, ia, fpar->next, dir); }; if (high == 0 && fpar->next == NULL) k = 0; }