#include #include #include #include "nrutil.h" #include "structs.h" /***********************************************************************\ * Extract the diskyness/boxyness that the user wants to fit. * \***********************************************************************/ void boxy_par (char *string, struct fitpars *fpar) { char dum[10]; struct fitpars *f, *ft; int partog=1; float parval=0.; /********************************************************\ * Check to see if the Fourier array is already active. * * First, check the fitpar tree for higher order terms * \********************************************************/ sscanf (string, " %s %f %d", dum, &parval, &partog); f = fpar->high; while (f != NULL && strncmp (f->objtype, "C0", 2) != 0) f = f->next; /* No previous C0, create new */ if (f == NULL && !(parval == 0. && partog <= 0)) { ft = (struct fitpars *) malloc ((size_t) (sizeof (struct fitpars))); ft->a = (float *) malloc ((size_t) (sizeof (float)*2)); ft->ia = (int *) malloc ((size_t) (sizeof (int)*2)); ft->sig = (float *) malloc ((size_t) (sizeof (float)*2)); ft->inner = (int *) NULL; ft->outer = (int *) NULL; ft->high = (struct fitpars *) NULL; ft->next = (struct fitpars *) NULL; ft->compnum = 0; ft->npars = 1; ft->tr_num = 0; ft->normtype = 0; ft->outtype = 0; sprintf (ft->objtype, "C0"); if (fpar->high == NULL) /* First in the list */ fpar->high = ft; else{ /* Not the first in the list; must advance downward */ fpar = fpar->high; while (fpar->next != NULL) fpar = fpar->next; fpar->next = ft; }; f = ft; }; if (f != NULL) { f->a[1] = parval; f->ia[1] = partog; }; f->a[0] = 0.; f->ia[0] = -1; f->sig[0] = 0.; /* If the user wants to delete this parameter and it exists.... */ if (f != NULL && parval==0. && partog==0) { free ((float *) f->a); free ((int *) f->ia); free ((int *) f->sig); if (strncmp(fpar->high->objtype, "C0", 2) ==0) { free ((struct fitpars *) f); fpar->high = NULL; } else { fpar = fpar->high; while (strncmp (fpar->next->objtype, "C0", 2) != 0) fpar = fpar->next; free ((struct fitpars *) f); fpar->next = NULL; }; }; }