67char *option[N_OPTIONS] = {
82 "Usage: sddslorentzianfit [OPTIONS] [<inputfile>] [<outputfile>]\n"
84 " -pipe=<input>,<output> Use standard input/output pipes.\n"
85 " -columns=<x-name>,<y-name>[,ySigma=<sy-name>]\n"
86 " Specify the names of the x and y data columns,\n"
87 " and optionally the y sigma column.\n"
88 " -fitRange=<lower>|@<param>,<upper>|@<param>\n"
89 " Define the fitting range with lower and upper bounds.\n"
90 " Values can be direct or parameter references.\n"
91 " -guesses=<baseline|@param>,<center|@param>,<height|@param>,<gamma|@param>\n"
92 " Provide initial guesses for the fit parameters.\n"
93 " -fixValue=<baseline|@param>,<center|@param>,<height|@param>,<gamma|@param>\n"
94 " Fix specific fit parameters to given values or parameters.\n"
95 " -verbosity=<integer> Set verbosity level (higher for more detail).\n"
96 " -stepSize=<factor> Define the step size factor for the fitting algorithm.\n"
97 " -tolerance=<value> Set the tolerance for convergence of the fit.\n"
98 " -limits=<evaluations>,<passes> Set maximum number of evaluations and passes.\n"
99 " -majorOrder=row|column Specify the major order for data storage.\n"
100 " -fullOutput Enable detailed output including residuals.\n"
102 " Performs a Lorentzian fit of the form:\n"
103 " y = baseline + height * gamma^2 / (gamma^2 + (x - center)^2)\n"
106 " (" __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
")\n";
108void report(
double res,
double *a,
long pass,
long n_eval,
long n_dimen);
109void setupOutputFile(
SDDS_DATASET *OutputTable,
long *xIndex,
long *yIndex,
long *syIndex,
long *fitIndex,
110 long *residualIndex,
long fullOutput,
char *output,
SDDS_DATASET *InputTable,
111 char *xName,
char *yName,
char *syName,
short columnMajorOrder);
112long computeStartingPoint(
double *a,
double *da,
double *x,
double *y, int64_t n,
unsigned long guessFlags,
113 double gammaGuess,
double centerGuess,
double baselineGuess,
double heightGuess,
115double fitFunction(
double *a,
long *invalid);
116int64_t makeFilteredCopy(
double **xFit,
double **yFit,
double **syFit,
double *x,
double *y,
double *sy,
117 int64_t n,
double lower,
double upper);
119static double *xDataFit = NULL, *yDataFit = NULL, *syDataFit = NULL;
120static int64_t nDataFit = 0;
122#define GUESS_BASELINE_GIVEN 0x0001
123#define FIX_BASELINE_GIVEN (0x0001 << 4)
124#define GUESS_HEIGHT_GIVEN 0x0002
125#define FIX_HEIGHT_GIVEN (0x0002 << 4)
126#define GUESS_CENTER_GIVEN 0x0004
127#define FIX_CENTER_GIVEN (0x0004 << 4)
128#define GUESS_GAMMA_GIVEN 0x0008
129#define FIX_GAMMA_GIVEN (0x0008 << 4)
131#define BASELINE_INDEX 0
132#define HEIGHT_INDEX 1
133#define CENTER_INDEX 2
136int main(
int argc,
char **argv) {
137 double *xData = NULL, *yData = NULL, *syData = NULL;
142 char *input, *output, *xName, *yName, *syName;
143 long xIndex, yIndex, fitIndex, residualIndex, syIndex_col, retval;
144 double *fitData, *residualData, rmsResidual, chiSqr, sigLevel;
145 unsigned long guessFlags, dummyFlags, pipeFlags, majorOrderFlag;
146 double gammaGuess, centerGuess, baselineGuess, heightGuess;
147 double tolerance, stepSize;
148 double a[4], da[4], lower, upper, result;
149 double aLow[4], aHigh[4];
150 short disable[4] = {0, 0, 0, 0};
151 int32_t nEvalMax = 5000, nPassMax = 100;
152 long nEval, verbosity, fullOutput = 0;
154 short columnMajorOrder = -1;
155 char *lowerPar, *upperPar, *baselineGuessPar, *gammaGuessPar, *centerGuessPar, *heightGuessPar;
158 argc =
scanargs(&s_arg, argc, argv);
159 if (argc < 2 || argc > (2 + N_OPTIONS)) {
160 fprintf(stderr,
"%s", USAGE);
164 for (i = 0; i < 4; i++)
165 aLow[i] = -(aHigh[i] = DBL_MAX);
166 aLow[GAMMA_INDEX] = 0;
167 input = output = NULL;
171 guessFlags = gammaGuess = heightGuess = baselineGuess = centerGuess = pipeFlags = 0;
172 xName = yName = syName = NULL;
174 lowerPar = upperPar = gammaGuessPar = heightGuessPar = baselineGuessPar = centerGuessPar = NULL;
175 for (i_arg = 1; i_arg < argc; i_arg++) {
176 if (s_arg[i_arg].arg_type == OPTION) {
177 switch (
match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
178 case SET_MAJOR_ORDER:
180 s_arg[i_arg].n_items--;
181 if (s_arg[i_arg].n_items > 0 && (!
scanItemList(&majorOrderFlag, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
"row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
"column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL)))
182 SDDS_Bomb(
"invalid -majorOrder syntax/values");
183 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
184 columnMajorOrder = 1;
185 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
186 columnMajorOrder = 0;
189 if (s_arg[i_arg].n_items != 3)
191 if (s_arg[i_arg].list[1][0] ==
'@') {
192 cp_str(&lowerPar, s_arg[i_arg].list[1] + 1);
193 }
else if (sscanf(s_arg[i_arg].list[1],
"%lf", &lower) != 1)
194 SDDS_Bomb(
"invalid fitRange lower value provided");
195 if (s_arg[i_arg].list[2][0] ==
'@') {
196 cp_str(&upperPar, s_arg[i_arg].list[2] + 1);
197 }
else if (sscanf(s_arg[i_arg].list[2],
"%lf", &upper) != 1)
198 SDDS_Bomb(
"invalid fitRange upper value provided");
201 if (s_arg[i_arg].n_items != 2 || sscanf(s_arg[i_arg].list[1],
"%lf", &tolerance) != 1 || tolerance <= 0)
202 SDDS_Bomb(
"incorrect -tolerance syntax");
205 if (s_arg[i_arg].n_items != 2 || sscanf(s_arg[i_arg].list[1],
"%lf", &stepSize) != 1 || stepSize <= 0)
209 if (s_arg[i_arg].n_items != 2 || sscanf(s_arg[i_arg].list[1],
"%ld", &verbosity) != 1)
210 SDDS_Bomb(
"incorrect -verbosity syntax");
213 if (s_arg[i_arg].n_items < 2)
215 s_arg[i_arg].n_items -= 1;
216 dummyFlags = guessFlags;
217 if (!
scanItemList(&guessFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
218 "baseline",
SDDS_STRING, &baselineGuessPar, 1, GUESS_BASELINE_GIVEN,
219 "height",
SDDS_STRING, &heightGuessPar, 1, GUESS_HEIGHT_GIVEN,
220 "center",
SDDS_STRING, ¢erGuessPar, 1, GUESS_CENTER_GIVEN,
221 "gamma",
SDDS_STRING, &gammaGuessPar, 1, GUESS_GAMMA_GIVEN, NULL))
223 if (baselineGuessPar) {
224 if (baselineGuessPar[0] ==
'@') {
227 if (sscanf(baselineGuessPar,
"%lf", &baselineGuess) != 1)
228 SDDS_Bomb(
"Invalid baseline guess value provided.");
229 free(baselineGuessPar);
230 baselineGuessPar = NULL;
233 if (heightGuessPar) {
234 if (heightGuessPar[0] ==
'@') {
237 if (sscanf(heightGuessPar,
"%lf", &heightGuess) != 1)
238 SDDS_Bomb(
"Invalid height guess value provided.");
239 free(heightGuessPar);
240 heightGuessPar = NULL;
243 if (centerGuessPar) {
244 if (centerGuessPar[0] ==
'@') {
247 if (sscanf(centerGuessPar,
"%lf", ¢erGuess) != 1)
248 SDDS_Bomb(
"Invalid center guess value provided.");
249 free(centerGuessPar);
250 centerGuessPar = NULL;
254 if (gammaGuessPar[0] ==
'@') {
257 if (sscanf(gammaGuessPar,
"%lf", &gammaGuess) != 1)
258 SDDS_Bomb(
"Invalid gamma guess value provided.");
260 gammaGuessPar = NULL;
263 if ((dummyFlags >> 4) & guessFlags)
264 SDDS_Bomb(
"can't have -fixValue and -guesses for the same item");
265 guessFlags |= dummyFlags;
268 if (s_arg[i_arg].n_items < 2)
270 s_arg[i_arg].n_items -= 1;
271 dummyFlags = guessFlags;
272 if (!
scanItemList(&guessFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
273 "baseline",
SDDS_STRING, &baselineGuessPar, 1, FIX_BASELINE_GIVEN,
274 "height",
SDDS_STRING, &heightGuessPar, 1, FIX_HEIGHT_GIVEN,
275 "center",
SDDS_STRING, ¢erGuessPar, 1, FIX_CENTER_GIVEN,
276 "gamma",
SDDS_STRING, &gammaGuessPar, 1, FIX_GAMMA_GIVEN, NULL))
278 if (dummyFlags & (guessFlags >> 4))
279 SDDS_Bomb(
"can't have -fixValue and -guesses for the same item");
280 guessFlags |= dummyFlags;
281 if (baselineGuessPar) {
282 if (baselineGuessPar[0] ==
'@') {
285 if (sscanf(baselineGuessPar,
"%lf", &baselineGuess) != 1)
286 SDDS_Bomb(
"Invalid baseline guess value provided.");
287 free(baselineGuessPar);
288 baselineGuessPar = NULL;
291 if (heightGuessPar) {
292 if (heightGuessPar[0] ==
'@') {
295 if (sscanf(heightGuessPar,
"%lf", &heightGuess) != 1)
296 SDDS_Bomb(
"Invalid height guess value provided.");
297 free(heightGuessPar);
298 heightGuessPar = NULL;
301 if (centerGuessPar) {
302 if (centerGuessPar[0] ==
'@') {
305 if (sscanf(centerGuessPar,
"%lf", ¢erGuess) != 1)
306 SDDS_Bomb(
"Invalid center guess value provided.");
307 free(centerGuessPar);
308 centerGuessPar = NULL;
312 if (gammaGuessPar[0] ==
'@') {
315 if (sscanf(gammaGuessPar,
"%lf", &gammaGuess) != 1)
316 SDDS_Bomb(
"Invalid gamma guess value provided.");
318 gammaGuessPar = NULL;
323 if (s_arg[i_arg].n_items != 3 && s_arg[i_arg].n_items != 4)
325 xName = s_arg[i_arg].list[1];
326 yName = s_arg[i_arg].list[2];
327 s_arg[i_arg].n_items -= 3;
328 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 3, &s_arg[i_arg].n_items, 0,
336 if (s_arg[i_arg].n_items < 2)
338 s_arg[i_arg].n_items -= 1;
339 if (!
scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
340 "evaluations",
SDDS_LONG, &nEvalMax, 1, 0,
341 "passes",
SDDS_LONG, &nPassMax, 1, 0, NULL) ||
342 nEvalMax <= 0 || nPassMax <= 0)
346 if (!
processPipeOption(s_arg[i_arg].list + 1, s_arg[i_arg].n_items - 1, &pipeFlags))
350 fprintf(stderr,
"Error: Unknown or ambiguous option: %s\n", s_arg[i_arg].list[0]);
351 fprintf(stderr,
"%s", USAGE);
357 input = s_arg[i_arg].list[0];
358 else if (output == NULL)
359 output = s_arg[i_arg].list[0];
367 for (i = 0; i < 4; i++) {
368 if ((guessFlags >> 4) & (1 << i)) {
373 if (!xName || !yName) {
374 fprintf(stderr,
"Error: -columns option must be specified.\n");
375 fprintf(stderr,
"%s", USAGE);
383 (syName && !
SDDS_FindColumn(&InputTable, FIND_NUMERIC_TYPE, syName, NULL)))
384 SDDS_Bomb(
"One or more of the specified data columns do not exist or are non-numeric.");
386 setupOutputFile(&OutputTable, &xIndex, &yIndex, &syIndex_col, &fitIndex, &residualIndex,
387 fullOutput, output, &InputTable, xName, yName, syName, columnMajorOrder);
390 xData = yData = syData = NULL;
391 fitData = residualData = NULL;
413 if ((nDataFit = makeFilteredCopy(&xDataFit, &yDataFit, &syDataFit, xData, yData, syData, nData, lower, upper)) < 5)
422 if (!computeStartingPoint(a, da, xDataFit, yDataFit, nDataFit, guessFlags, gammaGuess, centerGuess, baselineGuess, heightGuess, stepSize)) {
423 fprintf(stderr,
"Error: Couldn't compute starting point for page %ld--skipping\n", retval);
427 fprintf(stderr,
"Starting values: gamma=%.6e center=%.6e baseline=%.6e height=%.6e\n", a[GAMMA_INDEX], a[CENTER_INDEX], a[BASELINE_INDEX], a[HEIGHT_INDEX]);
429 fprintf(stderr,
"Starting steps: gamma=%.6e center=%.6e baseline=%.6e height=%.6e\n", da[GAMMA_INDEX], da[CENTER_INDEX], da[BASELINE_INDEX], da[HEIGHT_INDEX]);
431 nEval =
simplexMin(&result, a, da, aLow, aHigh, disable, 4, -DBL_MAX, tolerance, fitFunction, (verbosity > 0 ? report : NULL), nEvalMax, nPassMax, 12, 3, 1.0, 0);
432 if (xData != xDataFit) {
440 fprintf(stderr,
"%ld evaluations of fit function required, giving result %e\n", nEval, result);
442 fitData =
trealloc(fitData,
sizeof(*fitData) * nData);
443 residualData =
trealloc(residualData,
sizeof(*residualData) * nData);
444 for (i = result = 0; i < nData; i++) {
445 fitData[i] = a[BASELINE_INDEX] + a[HEIGHT_INDEX] / (1 + sqr((xDataFit[i] - a[CENTER_INDEX]) / a[GAMMA_INDEX]));
446 residualData[i] = yData[i] - fitData[i];
447 result += sqr(residualData[i]);
449 rmsResidual = sqrt(result / nData);
451 for (i = chiSqr = 0; i < nData; i++)
452 chiSqr += sqr(residualData[i] / syData[i]);
455 sy2 = result / (nData - 4);
456 for (i = chiSqr = 0; i < nData; i++)
457 chiSqr += sqr(residualData[i]) / sy2;
461 fprintf(stderr,
"gamma: %.15e\ncenter: %.15e\nbaseline: %.15e\nheight: %.15e\n", a[GAMMA_INDEX], a[CENTER_INDEX], a[BASELINE_INDEX], a[HEIGHT_INDEX]);
465 fprintf(stderr,
"Significance level: %.5e\n", sigLevel);
466 fprintf(stderr,
"RMS deviation: %.15e\n", rmsResidual);
471 !
SDDS_SetColumn(&OutputTable, SDDS_SET_BY_INDEX, xData, nData, xIndex) ||
472 !
SDDS_SetColumn(&OutputTable, SDDS_SET_BY_INDEX, fitData, nData, fitIndex) ||
474 "lorentzianfitGamma", a[GAMMA_INDEX],
475 "lorentzianfitCenter", a[CENTER_INDEX],
476 "lorentzianfitBaseline", a[BASELINE_INDEX],
477 "lorentzianfitHeight", a[HEIGHT_INDEX],
478 "lorentzianfitRmsResidual", rmsResidual,
479 "lorentzianfitSigLevel", sigLevel, NULL) ||
481 (!
SDDS_SetColumn(&OutputTable, SDDS_SET_BY_INDEX, yData, nData, yIndex) ||
482 !
SDDS_SetColumn(&OutputTable, SDDS_SET_BY_INDEX, residualData, nData, residualIndex) ||
483 (syName && !
SDDS_SetColumn(&OutputTable, SDDS_SET_BY_INDEX, syData, nData, syIndex_col)))) ||
505 if (baselineGuessPar)
506 free(baselineGuessPar);
508 free(heightGuessPar);
515void setupOutputFile(
SDDS_DATASET *OutputTable,
long *xIndex,
long *yIndex,
long *syIndex,
long *fitIndex,
516 long *residualIndex,
long fullOutput,
char *output,
SDDS_DATASET *InputTable,
517 char *xName,
char *yName,
char *syName,
short columnMajorOrder) {
518 char *name, *yUnits, *description, *xUnits;
520 static char *residualNamePart =
"Residual";
521 static char *residualDescriptionPart =
"Residual of Lorentzian fit to ";
530 if (columnMajorOrder != -1)
531 OutputTable->layout.data_mode.column_major = columnMajorOrder;
533 OutputTable->layout.data_mode.column_major = InputTable->layout.data_mode.column_major;
534 name =
tmalloc(
sizeof(*name) * (strlen(yName) + strlen(residualNamePart) + 1));
535 description =
tmalloc(
sizeof(*description) * (strlen(yName) + strlen(residualDescriptionPart) + 1));
546 sprintf(name,
"%s%s", yName, residualNamePart);
547 sprintf(description,
"%s%s", yName, residualDescriptionPart);
552 sprintf(name,
"%sFit", yName);
553 sprintf(description,
"Lorentzian fit to %s", yName);
557 if (
SDDS_DefineParameter(OutputTable,
"lorentzianfitBaseline", NULL, yUnits,
"Baseline from Lorentzian fit",
559 SDDS_DefineParameter(OutputTable,
"lorentzianfitHeight", NULL, yUnits,
"Height from Lorentzian fit",
561 SDDS_DefineParameter(OutputTable,
"lorentzianfitCenter", NULL, xUnits,
"Center from Lorentzian fit",
563 SDDS_DefineParameter(OutputTable,
"lorentzianfitGamma", NULL, xUnits,
"Gamma from Lorentzian fit",
565 SDDS_DefineParameter(OutputTable,
"lorentzianfitRmsResidual", NULL, yUnits,
"RMS residual from Lorentzian fit",
567 SDDS_DefineParameter(OutputTable,
"lorentzianfitSigLevel", NULL, NULL,
"Significance level from chi-squared test",
574double fitFunction(
double *a,
long *invalid) {
575 double sum, tmp, center, gamma, base, norm;
579 gamma = a[GAMMA_INDEX];
580 center = a[CENTER_INDEX];
581 base = a[BASELINE_INDEX];
582 norm = a[HEIGHT_INDEX];
585 for (i = sum = 0; i < nDataFit; i++) {
586 tmp = (xDataFit[i] - center) / gamma;
587 tmp = norm / (1 + sqr(tmp)) + base;
588 sum += sqr(tmp - yDataFit[i]);
590 return (sum / nDataFit);
592 for (i = sum = 0; i < nDataFit; i++) {
593 tmp = (xDataFit[i] - center) / gamma;
594 tmp = norm / (1 + sqr(tmp)) + base;
595 sum += sqr((tmp - yDataFit[i]) / syDataFit[i]);
597 return (sum / nDataFit);
601void report(
double y,
double *x,
long pass,
long nEval,
long n_dimen) {
604 fprintf(stderr,
"Pass %ld, after %ld evaluations: result = %.16e\na = ", pass, nEval, y);
605 for (i = 0; i < n_dimen; i++)
606 fprintf(stderr,
"%.8e ", x[i]);
610long computeStartingPoint(
double *a,
double *da,
double *x,
double *y, int64_t n,
unsigned long guessFlags,
611 double gammaGuess,
double centerGuess,
double baselineGuess,
double heightGuess,
613 double xhalf, dhalf, ymin, ymax, xcenter, tmp, xmax, xmin;
621 ymax = xmax = -DBL_MAX;
622 ymin = xmin = DBL_MAX;
623 for (i = 0; i < n; i++) {
624 if (xmax < (tmp = fabs(x[i])))
639 for (i = 0; i < n; i++) {
640 tmp = fabs(fabs(y[i] - ymax) / (ymax - ymin) - 0.5);
646 if (dhalf != DBL_MAX)
647 a[GAMMA_INDEX] = fabs(xhalf - xcenter) / 1.177;
649 a[GAMMA_INDEX] = xmax - xmin;
650 a[CENTER_INDEX] = xcenter;
651 a[BASELINE_INDEX] = ymin;
652 a[HEIGHT_INDEX] = ymax - ymin;
654 if (guessFlags & (GUESS_GAMMA_GIVEN + FIX_GAMMA_GIVEN))
655 a[GAMMA_INDEX] = gammaGuess;
656 if (guessFlags & (GUESS_CENTER_GIVEN + FIX_CENTER_GIVEN))
657 a[CENTER_INDEX] = centerGuess;
658 if (guessFlags & (GUESS_BASELINE_GIVEN + FIX_BASELINE_GIVEN))
659 a[BASELINE_INDEX] = baselineGuess;
660 if (guessFlags & (GUESS_HEIGHT_GIVEN + FIX_HEIGHT_GIVEN))
661 a[HEIGHT_INDEX] = heightGuess;
664 for (i = 0; i < 4; i++)
665 if (!(da[i] = a[i] * stepSize))
671int64_t makeFilteredCopy(
double **xFit,
double **yFit,
double **syFit,
double *x,
double *y,
672 double *sy, int64_t n,
double lower,
double upper) {
675 if (!(*xFit = (
double *)malloc(
sizeof(**xFit) * n)) ||
676 !(*yFit = (
double *)malloc(
sizeof(**yFit) * n)) ||
677 (sy && !(*syFit = (
double *)malloc(
sizeof(**syFit) * n))))
680 for (i = j = 0; i < n; i++) {
681 if (x[i] < lower || x[i] > upper)
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_CopyParameters(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
int32_t SDDS_SetColumn(SDDS_DATASET *SDDS_dataset, int32_t mode, void *data, int64_t rows,...)
Sets the values for one data column in the current data table of an SDDS dataset.
int32_t SDDS_ChangeColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Modifies a specific field in a column definition within the SDDS dataset.
int32_t SDDS_GetColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified column in the SDDS dataset.
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_DefineColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length)
Defines a data column within the SDDS dataset.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_DefineParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, char *fixed_value)
Defines a data parameter with a fixed string value.
int32_t SDDS_TransferColumnDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a column definition from a source dataset to a target dataset.
int32_t SDDS_TransferAllParameterDefinitions(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Transfers all parameter definitions from a source dataset to a target dataset.
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
char * SDDS_FindColumn(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
Finds the first column in the SDDS dataset that matches the specified criteria.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
#define SDDS_STRING
Identifier for the string data type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
#define SDDS_DOUBLE
Identifier for the double data type.
void * trealloc(void *old_ptr, uint64_t size_of_block)
Reallocates a memory block to a new size.
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
char * cp_str(char **s, char *t)
Copies a string, allocating memory for storage.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
long processPipeOption(char **item, long items, unsigned long *flags)
void processFilenames(char *programName, char **input, char **output, unsigned long pipeFlags, long noWarnings, long *tmpOutputUsed)
void free_scanargs(SCANNED_ARG **scanned, int argc)
long scanItemList(unsigned long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items and assigns values based on provided keywords and types.
double ChiSqrSigLevel(double ChiSquared0, long nu)
Computes the probability that a chi-squared variable exceeds a given value.
long simplexMin(double *yReturn, double *xGuess, double *dxGuess, double *xLowerLimit, double *xUpperLimit, short *disable, long dimensions, double target, double tolerance, double(*func)(double *x, long *invalid), void(*report)(double ymin, double *xmin, long pass, long evals, long dims), long maxEvaluations, long maxPasses, long maxDivisions, double divisorFactor, double passRangeFactor, unsigned long flags)
Top-level convenience function for simplex-based minimization.