64 SET_STANDARDDEVIATION,
84char *option[N_OPTIONS] = {
107#define TOPLIMIT_GIVEN 0x0001U
108#define BOTTOMLIMIT_GIVEN 0x0002U
109#define POSITIONCOLUMN_GIVEN 0x0004U
110#define PERCENT_GIVEN 0x0008U
116 char **sourceColumn, *resultColumn, *positionColumn;
117 long sourceColumns, sumPower, optionCode, positionColumnIndex;
120 double topLimit, bottomLimit;
128 char **sourceColumn, *resultColumn, *positionColumn;
129 long sourceColumns, optionCode, resultIndex, sumPower, positionColumnIndex;
132 double topLimit, bottomLimit;
135long addStatRequests(
STAT_REQUEST **statRequest,
long requests,
char **item,
long items,
long code,
unsigned long flag);
140 "Usage: sddsrowstats [<input>] [<output>] [options]\n"
142 " -pipe[=input][,output]\n"
143 " Use pipe for input and/or output.\n"
145 " Suppress warning messages.\n"
146 " -mean=<newName>[,<limitOps>],<columnNameList>\n"
147 " Compute the mean of the specified columns.\n"
148 " -rms=<newName>[,<limitOps>],<columnNameList>\n"
149 " Compute the root mean square of the specified columns.\n"
150 " -median=<newName>[,<limitOps>],<columnNameList>\n"
151 " Compute the median of the specified columns.\n"
152 " -minimum=<newName>[,positionColumn=<name>][,<limitOps>],<columnNameList>\n"
153 " Compute the minimum value among the specified columns.\n"
154 " -maximum=<newName>[,positionColumn=<name>][,<limitOps>],<columnNameList>\n"
155 " Compute the maximum value among the specified columns.\n"
156 " -standardDeviation=<newName>[,<limitOps>],<columnNameList>\n"
157 " Compute the standard deviation of the specified columns.\n"
158 " -sigma=<newName>[,<limitOps>],<columnNameList>\n"
159 " Compute the sigma (standard deviation) of the specified columns.\n"
160 " -mad=<newName>[,<limitOps>],<columnNameList>\n"
161 " Compute the median absolute deviation (MAD) of the specified columns.\n"
162 " -sum=<newName>[,<limitOps>][,power=<integer>],<columnNameList>\n"
163 " Compute the sum of the specified columns.\n"
164 " -spread=<newName>[,<limitOps>],<columnNameList>\n"
165 " Compute the spread (max - min) of the specified columns.\n"
166 " -drange=<newName>[,<limitOps>],<columnNameList>\n"
167 " Compute the decile range of the specified columns.\n"
168 " -qrange=<newName>[,<limitOps>],<columnNameList>\n"
169 " Compute the quartile range of the specified columns.\n"
170 " -smallest=<newName>[,positionColumn=<name>][,<limitOps>],<columnNameList>\n"
171 " Compute the smallest absolute value among the specified columns.\n"
172 " -largest=<newName>[,positionColumn=<name>][,<limitOps>],<columnNameList>\n"
173 " Compute the largest absolute value among the specified columns.\n"
174 " -count=<newName>[,<limitOps>],<columnNameList>\n"
175 " Count the number of valid entries in the specified columns.\n"
176 " -percentile=<newName>[,<limitOps>],value=<percent>,<columnNameList>\n"
177 " Compute the specified percentile of the given columns.\n"
178 " -majorOrder=row|column\n"
179 " Set the data ordering to row-major or column-major.\n"
180 " -threads=<number>\n"
181 " Specify the number of threads to use for computations.\n"
182 "\n<limitOps> is of the form [topLimit=<value>,][bottomLimit=<value>]\n"
183 "\nComputes statistics for each row of each input table, adding new columns to the\n"
184 "output table. Each row statistic is done using data from the columns listed in\n"
185 "<columnNameList>, which is a comma-separated list of optionally-wildcarded column\n"
186 "names. positionColumn=<name> for minimum, maximum, smallest, largest option is to store \n"
187 "the corresponding column name of the minimum, maximum, smallest, or largest in each row to \n"
188 "the new output column - <name>.\n"
189 "\nProgram by Michael Borland. (" __DATE__
" " __TIME__
", SVN revision: " SVN_VERSION
")\n";
191int main(
int argc,
char **argv) {
196 SCANNED_ARG *scanned;
200 long i_arg, code, iStat, tmpFileUsed, iColumn, posColIndex;
201 int64_t rows, row, count;
202 long noWarnings, maxSourceColumns;
203 char *input, *output, *positionColumn, **posColumnName;
204 double **inputData, *outputData, value1, value2, topLimit, bottomLimit;
205 unsigned long pipeFlags, scanFlags, majorOrderFlag;
207 double *statWorkArray;
208 double quartilePoint[2] = {25.0, 75.0}, quartileResult[2];
209 double decilePoint[2] = {10.0, 90.0}, decileResult[2];
211 short columnMajorOrder = -1;
215 argc =
scanargs(&scanned, argc, argv);
217 bomb(
"too few arguments", USAGE);
220 posColumnName = NULL;
221 input = output = positionColumn = NULL;
224 stats = requests = pipeFlags = 0;
227 statWorkArray = NULL;
229 for (i_arg = 1; i_arg < argc; i_arg++) {
231 if (scanned[i_arg].arg_type == OPTION) {
233 switch (code =
match_string(scanned[i_arg].list[0], option, N_OPTIONS, 0)) {
238 case SET_STANDARDDEVIATION:
248 if (scanned[i_arg].n_items < 3) {
249 fprintf(stderr,
"error: invalid -%s syntax\n", option[code]);
252 if (!
scanItemList(&scanFlags, scanned[i_arg].list, &scanned[i_arg].n_items,
253 SCANITEMLIST_UNKNOWN_VALUE_OK | SCANITEMLIST_REMOVE_USED_ITEMS |
254 SCANITEMLIST_IGNORE_VALUELESS,
255 "positionColumn",
SDDS_STRING, &positionColumn, 1, POSITIONCOLUMN_GIVEN,
256 "toplimit",
SDDS_DOUBLE, &topLimit, 1, TOPLIMIT_GIVEN,
257 "bottomlimit",
SDDS_DOUBLE, &bottomLimit, 1, BOTTOMLIMIT_GIVEN, NULL)) {
258 sprintf(s,
"invalid -%s syntax", scanned[i_arg].list[0]);
261 requests = addStatRequests(&request, requests, scanned[i_arg].list + 1, scanned[i_arg].n_items - 1, code, scanFlags);
262 request[requests - 1].topLimit = topLimit;
263 request[requests - 1].bottomLimit = bottomLimit;
264 if (positionColumn) {
265 if (code == SET_MAXIMUM || code == SET_MINIMUM || code == SET_LARGEST || code == SET_SMALLEST)
266 SDDS_CopyString(&request[requests - 1].positionColumn, positionColumn);
267 free(positionColumn);
268 positionColumn = NULL;
272 if (scanned[i_arg].n_items < 3) {
273 fprintf(stderr,
"error: invalid -%s syntax\n", option[code]);
276 if (!
scanItemList(&scanFlags, scanned[i_arg].list, &scanned[i_arg].n_items,
277 SCANITEMLIST_UNKNOWN_VALUE_OK | SCANITEMLIST_REMOVE_USED_ITEMS |
278 SCANITEMLIST_IGNORE_VALUELESS,
280 "toplimit",
SDDS_DOUBLE, &topLimit, 1, TOPLIMIT_GIVEN,
281 "bottomlimit",
SDDS_DOUBLE, &bottomLimit, 1, BOTTOMLIMIT_GIVEN, NULL) ||
282 !(scanFlags & PERCENT_GIVEN) || percent <= 0 || percent >= 100)
284 requests = addStatRequests(&request, requests, scanned[i_arg].list + 1, scanned[i_arg].n_items - 1, code, scanFlags);
285 request[requests - 1].percent = percent;
286 request[requests - 1].topLimit = topLimit;
287 request[requests - 1].bottomLimit = bottomLimit;
290 if (scanned[i_arg].n_items < 3) {
291 fprintf(stderr,
"error: invalid -%s syntax\n", option[code]);
295 if (!
scanItemList(&scanFlags, scanned[i_arg].list, &scanned[i_arg].n_items,
296 SCANITEMLIST_UNKNOWN_VALUE_OK | SCANITEMLIST_REMOVE_USED_ITEMS | SCANITEMLIST_IGNORE_VALUELESS,
298 "toplimit",
SDDS_DOUBLE, &topLimit, 1, TOPLIMIT_GIVEN,
299 "bottomlimit",
SDDS_DOUBLE, &bottomLimit, 1, BOTTOMLIMIT_GIVEN, NULL))
301 requests = addStatRequests(&request, requests, scanned[i_arg].list + 1, scanned[i_arg].n_items - 1, code, scanFlags);
302 request[requests - 1].sumPower = power;
303 request[requests - 1].topLimit = topLimit;
304 request[requests - 1].bottomLimit = bottomLimit;
307 if (!
processPipeOption(scanned[i_arg].list + 1, scanned[i_arg].n_items - 1, &pipeFlags))
313 case SET_MAJOR_ORDER:
315 scanned[i_arg].n_items--;
316 if (scanned[i_arg].n_items > 0 &&
317 (!
scanItemList(&majorOrderFlag, scanned[i_arg].list + 1, &scanned[i_arg].n_items, 0,
318 "row", -1, NULL, 0, SDDS_ROW_MAJOR_ORDER,
319 "column", -1, NULL, 0, SDDS_COLUMN_MAJOR_ORDER, NULL)))
320 SDDS_Bomb(
"invalid -majorOrder syntax/values");
321 if (majorOrderFlag & SDDS_COLUMN_MAJOR_ORDER)
322 columnMajorOrder = 1;
323 else if (majorOrderFlag & SDDS_ROW_MAJOR_ORDER)
324 columnMajorOrder = 0;
327 if (scanned[i_arg].n_items != 2 ||
328 !sscanf(scanned[i_arg].list[1],
"%d", &threads) || threads < 1)
332 fprintf(stderr,
"error: unknown option '%s' given\n", scanned[i_arg].list[0]);
339 input = scanned[i_arg].list[0];
341 output = scanned[i_arg].list[0];
347 processFilenames(
"sddsrowstats", &input, &output, pipeFlags, noWarnings, &tmpFileUsed);
355 if (!(stat = compileStatDefinitions(&inData, request, requests, &stats, noWarnings))) {
360 SDDS_Bomb(
"No valid statistics requests.");
361 for (iStat = maxSourceColumns = 0; iStat < stats; iStat++) {
362 if (stat[iStat].sourceColumns > maxSourceColumns)
363 maxSourceColumns = stat[iStat].sourceColumns;
365 if (!(statWorkArray = malloc(
sizeof(*statWorkArray) * maxSourceColumns)))
366 SDDS_Bomb(
"allocation failure (statWorkArray)");
368 if (!setupOutputFile(&outData, output, &inData, stat, stats, columnMajorOrder)) {
381 if (!(outputData = (
double *)malloc(
sizeof(*outputData) * rows))) {
384 if (!(posColumnName = (
char **)malloc(
sizeof(*posColumnName) * rows))) {
387 for (iStat = 0; iStat < stats; iStat++) {
388 if (!(inputData = (
double **)malloc(
sizeof(*inputData) * stat[iStat].sourceColumns))) {
391 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
396 for (row = 0; row < rows; row++)
397 outputData[row] = DBL_MAX;
398 switch (stat[iStat].optionCode) {
400 for (row = 0; row < rows; row++) {
403 posColumnName[row] = NULL;
404 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
405 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
407 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
409 if (inputData[iColumn][row] < value1) {
410 value1 = inputData[iColumn][row];
411 posColIndex = iColumn;
414 outputData[row] = value1;
415 if (stat[iStat].positionColumn)
416 posColumnName[row] = stat[iStat].sourceColumn[posColIndex];
420 for (row = 0; row < rows; row++) {
423 posColumnName[row] = NULL;
424 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
425 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
427 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
429 if (inputData[iColumn][row] > value1) {
430 posColIndex = iColumn;
431 value1 = inputData[iColumn][row];
434 outputData[row] = value1;
435 if (stat[iStat].positionColumn)
436 posColumnName[row] = stat[iStat].sourceColumn[posColIndex];
440 for (row = 0; row < rows; row++) {
443 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
444 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
446 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
448 value1 += inputData[iColumn][row];
452 outputData[row] = value1 / count;
456 for (row = 0; row < rows; row++) {
457 for (iColumn = count = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
458 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
460 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
462 statWorkArray[count] = inputData[iColumn][row];
469 case SET_STANDARDDEVIATION:
470 for (row = 0; row < rows; row++) {
474 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
475 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
477 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
479 value1 += inputData[iColumn][row];
480 value2 += inputData[iColumn][row] * inputData[iColumn][row];
484 if ((value1 = value2 / count - sqr(value1 / count)) <= 0)
487 outputData[row] = sqrt(value1 * count / (count - 1.0));
492 for (row = 0; row < rows; row++) {
496 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
497 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
499 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
501 value1 += inputData[iColumn][row];
502 value2 += inputData[iColumn][row] * inputData[iColumn][row];
506 if ((value1 = value2 / count - sqr(value1 / count)) <= 0)
509 outputData[row] = sqrt(value1 / (count - 1.0));
514 for (row = 0; row < rows; row++) {
517 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
518 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
520 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
522 value1 += sqr(inputData[iColumn][row]);
526 outputData[row] = sqrt(value1 / count);
530 for (row = 0; row < rows; row++) {
533 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
534 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
536 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
538 value1 +=
ipow(inputData[iColumn][row], stat[iStat].sumPower);
542 outputData[row] = value1;
546 for (row = 0; row < rows; row++) {
548 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
549 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
551 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
555 outputData[row] = count;
559 for (row = 0; row < rows; row++) {
560 for (iColumn = count = value1 = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
561 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
563 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
565 statWorkArray[count] = inputData[iColumn][row];
573 for (row = 0; row < rows; row++) {
574 for (iColumn = count = value1 = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
575 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
577 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
579 statWorkArray[count] = inputData[iColumn][row];
583 outputData[row] = decileResult[1] - decileResult[0];
587 for (row = 0; row < rows; row++) {
588 for (iColumn = count = value1 = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
589 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
591 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
593 statWorkArray[count] = inputData[iColumn][row];
597 outputData[row] = quartileResult[1] - quartileResult[0];
601 for (row = 0; row < rows; row++) {
604 posColumnName[row] = NULL;
605 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
606 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
608 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
610 if ((value2 = fabs(inputData[iColumn][row])) < value1) {
611 posColIndex = iColumn;
615 outputData[row] = value1;
616 if (stat[iStat].positionColumn)
617 posColumnName[row] = stat[iStat].sourceColumn[posColIndex];
621 for (row = 0; row < rows; row++) {
624 posColumnName[row] = NULL;
625 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
626 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
628 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
630 if ((value2 = fabs(inputData[iColumn][row])) > value1) {
631 posColIndex = iColumn;
635 outputData[row] = value1;
636 if (stat[iStat].positionColumn)
637 posColumnName[row] = stat[iStat].sourceColumn[posColIndex];
641 for (row = 0; row < rows; row++) {
644 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
645 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
647 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
649 if (inputData[iColumn][row] < value1)
650 value1 = inputData[iColumn][row];
651 if (inputData[iColumn][row] > value2)
652 value2 = inputData[iColumn][row];
654 outputData[row] = value2 - value1;
658 for (row = 0; row < rows; row++) {
659 for (iColumn = count = value1 = 0; iColumn < stat[iStat].sourceColumns; iColumn++) {
660 if (stat[iStat].flags & TOPLIMIT_GIVEN && inputData[iColumn][row] > stat[iStat].topLimit)
662 if (stat[iStat].flags & BOTTOMLIMIT_GIVEN && inputData[iColumn][row] < stat[iStat].bottomLimit)
664 statWorkArray[count] = inputData[iColumn][row];
667 outputData[row] = HUGE_VAL;
673 SDDS_Bomb(
"invalid statistic code (accumulation loop)");
676 if (!
SDDS_SetColumn(&outData, SDDS_SET_BY_INDEX, outputData, rows, stat[iStat].resultIndex))
679 if (stat[iStat].positionColumn) {
680 if (!
SDDS_SetColumn(&outData, SDDS_SET_BY_INDEX, posColumnName, rows, stat[iStat].positionColumnIndex))
683 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++)
684 free(inputData[iColumn]);
691 posColumnName = NULL;
697 for (iStat = 0; iStat < stats; iStat++) {
698 if (stat[iStat].positionColumn)
699 free(stat[iStat].positionColumn);
700 for (iColumn = 0; iColumn < stat[iStat].sourceColumns; iColumn++)
701 free(stat[iStat].sourceColumn[iColumn]);
702 free(stat[iStat].sourceColumn);
718long addStatRequests(
STAT_REQUEST **statRequest,
long requests,
char **item,
long items,
long code,
unsigned long flags) {
720 if (!(*statRequest =
SDDS_Realloc(*statRequest,
sizeof(**statRequest) * (requests + 1))) ||
721 !((*statRequest)[requests].sourceColumn = (
char **)malloc(
sizeof(*(*statRequest)[requests].sourceColumn) * (items - 1))))
723 for (i = 0; i < items - 1; i++)
724 SDDS_CopyString(&((*statRequest)[requests].sourceColumn[i]), item[i + 1]);
725 (*statRequest)[requests].resultColumn = item[0];
726 (*statRequest)[requests].sourceColumns = items - 1;
727 (*statRequest)[requests].optionCode = code;
728 (*statRequest)[requests].sumPower = 1;
729 (*statRequest)[requests].flags = flags;
730 (*statRequest)[requests].positionColumn = NULL;
737 long iReq, iName, iStat;
741 for (iReq = iStat = 0; iReq < requests; iReq++) {
742 if ((stat[iStat].sourceColumns = expandColumnPairNames(inData, &request[iReq].sourceColumn, NULL, request[iReq].sourceColumns, NULL, 0, FIND_NUMERIC_TYPE, 0)) <= 0) {
744 fprintf(stderr,
"Warning: no match for column names (sddsrowstats):\n");
745 for (iName = 0; iName < request[iReq].sourceColumns; iName++)
746 fprintf(stderr,
"%s, ", request[iReq].sourceColumn[iName]);
750 stat[iStat].sourceColumn = request[iReq].sourceColumn;
751 stat[iStat].resultColumn = request[iReq].resultColumn;
752 stat[iStat].optionCode = request[iReq].optionCode;
753 stat[iStat].sumPower = request[iReq].sumPower;
754 stat[iStat].flags = request[iReq].flags;
755 stat[iStat].topLimit = request[iReq].topLimit;
756 stat[iStat].bottomLimit = request[iReq].bottomLimit;
757 stat[iStat].positionColumn = request[iReq].positionColumn;
758 stat[iStat].percent = request[iReq].percent;
769 char s[SDDS_MAXLINE];
773 if (columnMajorOrder != -1)
774 outData->layout.data_mode.column_major = columnMajorOrder;
776 outData->layout.data_mode.column_major = inData->layout.data_mode.column_major;
777 for (column = 0; column < stats; column++) {
779 sprintf(s,
"Problem transferring definition of column %s to %s\n", stat[column].sourceColumn[0], stat[column].resultColumn);
783 if ((stat[column].resultIndex =
SDDS_GetColumnIndex(outData, stat[column].resultColumn)) < 0) {
784 sprintf(s,
"Problem creating column %s", stat[column].resultColumn);
788 if (stat[column].positionColumn) {
790 sprintf(s,
"Problem define column %s\n", stat[column].positionColumn);
794 if ((stat[column].positionColumnIndex =
SDDS_GetColumnIndex(outData, stat[column].positionColumn)) < 0) {
795 sprintf(s,
"Problem creating column %s", stat[column].positionColumn);
803 sprintf(s,
"Problem changing attributes of new column %s", stat[column].resultColumn);
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_InitializeCopy(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, char *filename, char *filemode)
int32_t SDDS_CopyPage(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
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_DefineSimpleColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data column within the SDDS dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
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.
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
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.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
void * SDDS_Realloc(void *old_ptr, size_t new_size)
Reallocates memory to a new size.
#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 bomb(char *error, char *usage)
Reports error messages to the terminal and aborts the program.
double ipow(const double x, const int64_t p)
Compute x raised to the power p (x^p).
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.
long computeMomentsThreaded(double *mean, double *rms, double *standDev, double *meanAbsoluteDev, double *x, long n, long numThreads)
Computes the mean, RMS, standard deviation, and mean absolute deviation of an array using multiple th...
long replaceFileAndBackUp(char *file, char *replacement)
Replaces a file with a replacement file and creates a backup of the original.
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.