#ifndef nl_system_H #define nl_system_H #include /*Non Linear generic model fitting data structure, contain all needed callback functions*/ typedef struct NL_Model_t{ /*Mandatory members - without then the fitting procedures will crash ! */ int type; /*This is meant to be used for debugging and enum types*/ copy_data_function* copy_data; /*Make a copy of ls_data, it is needed to "save" the results of an previous iteration*/ compare_function* compare; /*compare the results of different iterations*/ release_data_function* release_data; /*Release a ls_data pointer from memory, mandatory if you dont wish to have your memory taken by multiple iterations !*/ /*Optional members - they wont be called by the fitting functions and can be NULL*/ evaluate_function* evaluate; /* compute the value of the fitting function, it is optional*/ write_function* write_param; /*write the params in human readable manner into a file*/ read_function* read_param; /*read the params from a file in human readable manner*/ } nl_model_t; double non_linear_compute_S_star( nl_model_t* nl, double** X, double* F, int n, double* parameters, void* l_data_original, int nSteps ); /* Given a non-linear model {nl}, the ${n} points {X} and function points ${F}, packed parameters {parameters}m approximates the model by LS with ${nSteps} iterations and returns the mean-square error of the approximation. {l_data_original} is used solely to unpacking data */ void * non_linear_approximate( nl_model_t* nl, void * l_data_original, double* deviations, double** X, double* F, int n, int LSSteps, int NLSteps ); /* Given a non-linear model {nl}, the lighting data {l_data} as first estimative, the {n} points {X} and its image {F} it efetuates a non-linear approximation with {NLSteps} maximum iterations with internal LS approximation of ${LSSteps} iterations*/ #endif