include "ffit.h" # f_fit_init -- initialize pointer procedure f_fit_init (npar) int npar # i: number of parameters to be fit #-- pointer fnl # pointer to struct (returned as function value) int k begin call malloc (fnl, LEN_FFIT, TY_STRUCT) F_NPTS(fnl) = 0 F_NPAR(fnl) = max (1, npar) F_XMIN(fnl) = 0. F_XMAX(fnl) = 0. F_YMIN(fnl) = 0. F_YMAX(fnl) = 0. F_OPTION(fnl) = F_LEAST_SQUARES F_XPT(fnl) = NULL F_YPT(fnl) = NULL call malloc (F_VPT(fnl), npar, TY_BOOL) call malloc (F_PPT(fnl), npar, TY_REAL) do k = 1, F_NPAR(fnl) { F_VAR(fnl,k) = false F_PAR(fnl,k) = 0. } return (fnl) end # f_fit_free -- free memory procedure f_fit_free (fnl) pointer fnl # pointer to fitting struct #-- begin if (fnl == NULL) return if (F_PPT(fnl) != NULL) call mfree (F_PPT(fnl), TY_REAL) if (F_VPT(fnl) != NULL) call mfree (F_VPT(fnl), TY_BOOL) if (F_YPT(fnl) != NULL) call mfree (F_YPT(fnl), TY_REAL) if (F_XPT(fnl) != NULL) call mfree (F_XPT(fnl), TY_REAL) call mfree (fnl, TY_STRUCT) end