#include #include #include #include "structs.h" #define STRLEN 1000 struct fitpars *newobject (char *objtype); void del_highpars (struct fitpars *fpar, int type); void upcase (char *com); void rotpa_pars (char *string, struct fitpars *fpar) { void rm_rotpa (struct fitpars *f); int i, mode, pa; char rtype[10], com[STRLEN]; struct fitpars *f, *ft; /*************************************************************\ * Check to see if the rotation structure is already active. * * First, check the fitpar tree for higher order terms. * \*************************************************************/ f = fpar->high; sscanf (string, "%s %s", com, rtype); upcase (com); while (f!= NULL && strncmp (f->objtype, "power", 5) != 0 && strncmp (f->objtype, "log", 3) != 0) f = f->next; /* No rotation structure, create new */ if (f == NULL && strncmp (rtype, "none", 4) != 0 && strncmp (rtype, "NONE", 4) != 0) { if (strncmp (rtype, "power", 5) == 0) ft = newobject ("power"); else ft = newobject ("log"); 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; }; /*******************************************\ * Now assign parameter values or delete R0 * \*******************************************/ if (f != NULL) { if (strncmp (com, "R0", 2) == 0) { if (strncmp (rtype, "none", 4) == 0 || strncmp (rtype, "NONE", 4) ==0) del_highpars (fpar, 0); } else if (strncmp (com, "R10", 3) == 0) sscanf (string, " %s %f %d", com, &f->a[10], &f->ia[10]); else if (strncmp (com, "R1", 2) == 0) sscanf (string, " %s %f %d", com, &f->a[1], &f->ia[1]); else if (strncmp (com, "R2", 2) == 0) sscanf (string, " %s %f %d", com, &f->a[2], &f->ia[2]); else if (strncmp (com, "R3", 2) == 0) sscanf (string, " %s %f %d", com, &f->a[3], &f->ia[3]); else if (strncmp (com, "R4", 2) == 0) sscanf (string, " %s %f %d", com, &f->a[4], &f->ia[4]); else if (strncmp (com, "R9", 2) == 0) sscanf (string, " %s %f %d", com, &f->a[9], &f->ia[9]); for (i=5; i<=8; i++) f->ia[i] = -1; }; }