00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "jsoc_main.h"
00036
00037 #define kRecSetIn "recSetIn"
00038 #define kWithRecSet "withRecSet"
00039 #define kSeriesOut "seriesOut"
00040 #define kSegList "segments"
00041 #define kOp "op"
00042 #define kBzero "bzero"
00043 #define kBscale "bscale"
00044 #define kDatatype "dtype"
00045 #define kNoSegsFlag "n"
00046 #define kNotSpecified "NOT SPECIFIED"
00047 #define kMaxSegs 1024
00048 #define kMaxQuery 2048
00049 #define kOutSeriesDesc "Output series for arithTool calculation."
00050 #define kInSliceLower "sl"
00051 #define kInSliceUpper "su"
00052 #define kPosOut "pout"
00053
00054 #define TESTER 0
00055
00056 typedef enum
00057 {
00058 kArithOpUnknown = 0,
00059 kArithOpMul,
00060 kArithOpDiv,
00061 kArithOpAdd,
00062 kArithOpSub,
00063 kArithOpBinaryDummy,
00064 kArithOpAbs,
00065 kArithOpSqrt,
00066 kArithOpLog,
00067 kArithOpPow,
00068 kArithOpSqr,
00069 kArithOpRecip,
00070 kArithOpSubmean,
00071 kArithOpNop,
00072 kArithOpLastDummy
00073 } ArithOp_t;
00074
00075 ModuleArgs_t module_args[] =
00076 {
00077 {ARG_FLAG, "h", "0", "help - print usage info"},
00078 {ARG_STRING, kRecSetIn, "", "A set of records with segments upon which to operate."},
00079 {ARG_INTS, kInSliceLower, "-1", "Bottom-left corner of slice (-1 means no slicing)"},
00080 {ARG_INTS, kInSliceUpper, "-1", "Upper-right corner of slice (-1 means no slicing)"},
00081 {ARG_STRING, kWithRecSet, kNotSpecified, "For binary operations, the second operand."},
00082 {ARG_STRING, kSeriesOut, kNotSpecified, "Name of series in which to save extracted data."},
00083 {ARG_INTS, kPosOut, "-1", "Bottom-left corner of the output data array at which data are to be written."},
00084 {ARG_STRING, kSegList, kNotSpecified, "Comma-separated list of segments on which to operate."},
00085 {ARG_STRING, kOp, "", "The operation to perform."},
00086 {ARG_DOUBLE, kBzero, "0.0", "For integer output, the bzero to use."},
00087 {ARG_DOUBLE, kBscale, "1.0", "For integer output, the bscale to use."},
00088 {ARG_NUME, kDatatype, "double", "Data type of in-memory data array.", "char,short,int,longlong,float,double,raw"},
00089 {ARG_FLAG, kNoSegsFlag, NULL, "Don't create an output segmetn file - just copy keywords.", NULL},
00090 {ARG_END}
00091 };
00092
00093 char *module_name = "arithTool";
00094
00095 typedef struct DRMSContainer_struct
00096 {
00097 HContainer_t *items;
00098 void (*Free)(HContainer_t *);
00099 HIterator_t iter;
00100 } DRMSContainer_t;
00101
00102
00103
00104 static int NiceIntro()
00105 {
00106 int usage = cmdparams_get_int(&cmdparams, "h", NULL);
00107 if (usage)
00108 {
00109 printf ("Usage:\n\tarithTool [-h] "
00110 "op=<operation> recSetIn=<recspec> [withRecSet=<recspec>] [seriesOut=<seriesname>] [segList=<segments>]\n"
00111 " details are:\n"
00112 " -h: help - show this message then exit\n"
00113 " <seriesname> - fully qualified series name.\n"
00114 " <timerange> - time value range set.\n"
00115 " seriesIn defaults to sdo.fds.\n"
00116 " timeRange defaults to all records in seriesIn.\n"
00117 " seriesOut defaults to sdo.fdsStateVectors.\n"
00118 " example - extractFdsStateV seriesIn=su_arta.TestFDSData timeRange=2006.11.20_22:38:00-2006.11.20_22:45:00,2006.11.20_22:52:00. seriesOut=su_arta.TestFDSHelio\n");
00119 return 1;
00120 }
00121
00122 return 0;
00123 }
00124
00125
00126 static ArithOp_t MapOp(char *opStr)
00127 {
00128 ArithOp_t op = kArithOpUnknown;
00129
00130 if (strncmp(opStr, "mul", 3) == 0)
00131 {
00132 op = kArithOpMul;
00133 }
00134 else if (strncmp(opStr, "div", 3) == 0)
00135 {
00136 op = kArithOpDiv;
00137 }
00138 else if (strncmp(opStr, "add", 3) == 0)
00139 {
00140 op = kArithOpAdd;
00141 }
00142 else if (strncmp(opStr, "sub", 3) == 0)
00143 {
00144 op = kArithOpSub;
00145 }
00146 else if (strncmp(opStr, "abs", 3) == 0)
00147 {
00148 op = kArithOpAbs;
00149 }
00150 else if (strncmp(opStr, "sqrt", 4) == 0)
00151 {
00152 op = kArithOpSqrt;
00153 }
00154 else if (strncmp(opStr, "log", 3) == 0)
00155 {
00156 op = kArithOpLog;
00157 }
00158 else if (strncmp(opStr, "pow", 3) == 0)
00159 {
00160 op = kArithOpPow;
00161 }
00162 else if (strncmp(opStr, "sqr", 3) == 0)
00163 {
00164 op = kArithOpSqr;
00165 }
00166 else if (strncmp(opStr, "recip", 5) == 0)
00167 {
00168 op = kArithOpRecip;
00169 }
00170 else if (strncmp(opStr, "nomean", 6) == 0)
00171 {
00172 op = kArithOpSubmean;
00173 }
00174 else if (strncmp(opStr, "nop", 3) == 0)
00175 {
00176 op = kArithOpNop;
00177 }
00178
00179 return op;
00180 }
00181
00182
00183 static int CreateDRMSPrimeKeyContainer(DRMS_Record_t *recTemplate, DRMSContainer_t *conPrimeKeys,
00184 void (*hconFree)(HContainer_t *hc))
00185 {
00186 int error = 0;
00187 int drmsst = DRMS_SUCCESS;
00188
00189
00190
00191 if (conPrimeKeys != NULL)
00192 {
00193
00194 conPrimeKeys->items = (HContainer_t *)malloc(sizeof(HContainer_t));
00195
00196 if (conPrimeKeys->items != NULL)
00197 {
00198 hcon_init(conPrimeKeys->items, sizeof(DRMS_Keyword_t *), DRMS_MAXKEYNAMELEN, NULL, NULL);
00199 int iPrimeKeys = 0;
00200 int nkeys = 0;
00201
00202 char **keyarr =
00203 drms_series_createpkeyarray(drms_env, recTemplate->seriesinfo->seriesname, &nkeys, &drmsst);
00204
00205 while (iPrimeKeys < nkeys)
00206 {
00207 DRMS_Keyword_t *keyword = drms_keyword_lookup(recTemplate, keyarr[iPrimeKeys], 1);
00208
00209 if (keyword != NULL)
00210 {
00211 DRMS_Keyword_t **newKeyword =
00212 (DRMS_Keyword_t **)hcon_allocslot_lower(conPrimeKeys->items,
00213 keyword->info->name);
00214
00215 if (newKeyword != NULL)
00216 {
00217 *newKeyword = keyword;
00218 }
00219 else
00220 {
00221 error = 1;
00222 break;
00223 }
00224 }
00225 else
00226 {
00227 error = 1;
00228 break;
00229 }
00230
00231 iPrimeKeys++;
00232 }
00233
00234 drms_series_destroypkeyarray(&keyarr, nkeys);
00235
00236
00237 conPrimeKeys->Free = hconFree;
00238 hiter_new(&(conPrimeKeys->iter), conPrimeKeys->items);
00239 }
00240 }
00241 else
00242 {
00243 error = 1;
00244 }
00245
00246 return error;
00247 }
00248
00249
00250 static void CreateDRMSSegmentContainer(DRMS_Record_t *recTemplate, DRMSContainer_t *conSegs,
00251 void (*hconFree)(HContainer_t *hc))
00252 {
00253
00254 conSegs->items = &(recTemplate->segments);
00255 conSegs->Free = hconFree;
00256 hiter_new(&(conSegs->iter), conSegs->items);
00257 }
00258
00259 static void DestroyDRMSContainer(DRMSContainer_t *pCon)
00260 {
00261 int wasinit = (pCon->items != NULL);
00262
00263 if (pCon != NULL)
00264 {
00265 if (pCon->Free != NULL && pCon->items != NULL)
00266 {
00267 (*(pCon->Free))(pCon->items);
00268 }
00269
00270 pCon->items = NULL;
00271
00272 if (wasinit)
00273 {
00274 hiter_free(&(pCon->iter));
00275 }
00276 }
00277 }
00278
00279 static void ReleaseHContainer(HContainer_t *hcon)
00280 {
00281 if (hcon != NULL)
00282 {
00283
00284 hcon_free(hcon);
00285 free(hcon);
00286 }
00287 }
00288
00289 static int IsValidOp(ArithOp_t op)
00290 {
00291 return (op >= kArithOpUnknown && op < kArithOpLastDummy);
00292 }
00293
00294 static int IsBinaryOp(ArithOp_t op)
00295 {
00296 if (IsValidOp(op))
00297 {
00298 return op < kArithOpBinaryDummy;
00299 }
00300
00301 return 0;
00302 }
00303
00304
00305
00306 static int KeysEqual(DRMSContainer_t *keys1, DRMSContainer_t *keys2)
00307 {
00308 int ret = 1;
00309
00310
00311
00312
00313
00314 if (hcon_size(keys1->items) != hcon_size(keys2->items))
00315 {
00316 ret = 0;
00317 }
00318 else
00319 {
00320 hiter_rewind(&(keys1->iter));
00321 DRMS_Keyword_t **currKey = NULL;
00322 DRMS_Keyword_t **currKey2 = NULL;
00323 while ((currKey = (DRMS_Keyword_t **)hiter_getnext(&(keys1->iter))) != NULL)
00324 {
00325 if ((currKey2 = hcon_lookup_lower(keys2->items, (*currKey)->info->name)) == NULL)
00326 {
00327 ret = 0;
00328 break;
00329 }
00330 else
00331 {
00332
00333 if (drms_keyword_type(*currKey) != drms_keyword_type(*currKey2))
00334 {
00335 ret = 0;
00336 break;
00337 }
00338 }
00339 }
00340 }
00341
00342 return ret;
00343 }
00344
00345
00346
00347
00348
00349
00350 static int CreateMatchingSegs(DRMSContainer_t *segs1, DRMSContainer_t *segs2, DRMSContainer_t *matchSet)
00351 {
00352 int nMatch = 0;
00353
00354 hiter_rewind(&(segs1->iter));
00355 DRMS_Segment_t *currSeg = NULL;
00356
00357 while ((currSeg = (DRMS_Segment_t *)hiter_getnext(&(segs1->iter))) != NULL)
00358 {
00359 if (segs1 == segs2 ||
00360 hcon_lookup_lower(segs2->items, currSeg->info->name) != NULL)
00361 {
00362 nMatch++;
00363
00364 if (matchSet != NULL)
00365 {
00366 if (nMatch == 1)
00367 {
00368 matchSet->items = (HContainer_t *)malloc(sizeof(HContainer_t));
00369 if (matchSet->items != NULL)
00370 {
00371 hcon_init(matchSet->items, sizeof(DRMS_Segment_t *),
00372 DRMS_MAXSEGNAMELEN,
00373 NULL,
00374 NULL);
00375 }
00376 else
00377 {
00378 nMatch = -1;
00379 break;
00380 }
00381 }
00382
00383 DRMS_Segment_t **newSeg =
00384 (DRMS_Segment_t **)hcon_allocslot_lower(matchSet->items, currSeg->info->name);
00385
00386 if (newSeg != NULL)
00387 {
00388 *newSeg = currSeg;
00389 }
00390 else
00391 {
00392 nMatch = -1;
00393 break;
00394 }
00395 }
00396 }
00397 }
00398
00399 if (nMatch > 0 && matchSet != NULL)
00400 {
00401 matchSet->Free = ReleaseHContainer;
00402 hiter_new(&(matchSet->iter), matchSet->items);
00403 }
00404
00405 return nMatch;
00406 }
00407
00408 static int ValidateBinaryOperands(char *recSetIn,
00409 char **segNameArr,
00410 int nSegs,
00411 DRMSContainer_t *inKeys, DRMSContainer_t *inSegs,
00412 DRMSContainer_t *withKeys, DRMSContainer_t *withSegs,
00413 DRMSContainer_t *segsToProc)
00414 {
00415 int error = 0;
00416 int status = 0;
00417
00418 int nWithRecs = 0;
00419 DRMS_RecordSet_t *recSet = drms_open_records(drms_env, recSetIn, &status);
00420 error = (status != DRMS_SUCCESS);
00421
00422 if (error == 0)
00423 {
00424 nWithRecs = recSet->n;
00425 drms_close_records(recSet, DRMS_FREE_RECORD);
00426 }
00427
00428
00429
00430
00431 if (!error)
00432 {
00433 if (nWithRecs > 1)
00434 {
00435 if (!KeysEqual(inKeys, withKeys))
00436 {
00437 error = 1;
00438 }
00439 }
00440 }
00441
00442 if (!error)
00443 {
00444 int nMatch = 0;
00445
00446 if (nSegs > 0)
00447 {
00448
00449
00450
00451
00452 int iSeg = 0;
00453
00454 for (; iSeg < nSegs; iSeg++)
00455 {
00456 char *aSegName = segNameArr[iSeg];
00457
00458 if (hcon_lookup_lower(inSegs->items, aSegName) == NULL ||
00459 hcon_lookup_lower(withSegs->items, aSegName) == NULL)
00460 {
00461 error = 1;
00462 fprintf(stderr, "Segment %s not present in an input recordset.\n",
00463 aSegName);
00464 break;
00465 }
00466 }
00467
00468
00469 if (!error)
00470 {
00471 nMatch = CreateMatchingSegs(inSegs, inSegs, segsToProc);
00472 }
00473 }
00474 else
00475 {
00476
00477 nMatch = CreateMatchingSegs(inSegs, withSegs, segsToProc);
00478 }
00479
00480 if (nMatch == -1)
00481 {
00482 DestroyDRMSContainer(segsToProc);
00483 error = 1;
00484 }
00485
00486 if (!error && nMatch == 0)
00487 {
00488 error = 1;
00489 }
00490 }
00491
00492 return error;
00493 }
00494
00495
00496 static char *CreateStrFromDRMSValue(DRMS_Record_t *rec, char *keyName, int *error)
00497 {
00498 return drms_getkey_string(rec, keyName, error);
00499 }
00500
00501 static int MultChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
00502 {
00503 int error = 0;
00504
00505 int first = 1;
00506 int percentDone = 0;
00507 int update = 0;
00508
00509 const char *rop = NULL;
00510 const char *lop = NULL;
00511
00512 if (!pInData)
00513 {
00514 error = 1;
00515 fprintf(stderr, "Missing input data.\n");
00516 }
00517 else if (!pWithData)
00518 {
00519 error = 1;
00520 fprintf(stderr, "Missing input data.\n");
00521 }
00522 else
00523 {
00524 char *result = NULL;
00525 arraylen_t index = 0;
00526
00527 for (; index < nElements; index++)
00528 {
00529 result = &(pOutData[index]);
00530 *result = DRMS_MISSING_CHAR;
00531
00532 if (!drms_ismissing_char(pInData[index]) &&
00533 (!!drms_ismissing_char(pWithData[index])))
00534 {
00535 percentDone = index * 100/nElements;
00536
00537 if (first)
00538 {
00539 fprintf(stdout, "%03d%% done", percentDone);
00540 first = 0;
00541 }
00542 else if (percentDone == update)
00543 {
00544 update++;
00545 fprintf(stdout,
00546 "\b\b\b\b\b\b\b\b\b%03d%% done",
00547 percentDone);
00548 fflush(stdout);
00549 }
00550
00551 lop = &(pInData[index]);
00552 rop = &(pWithData[index]);
00553 *result = *lop * *rop;
00554 }
00555 }
00556
00557 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
00558 fflush(stdout);
00559 }
00560
00561 return error;
00562 }
00563
00564 static int MultShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
00565 {
00566 int error = 0;
00567
00568 int first = 1;
00569 int percentDone = 0;
00570 int update = 0;
00571
00572 const short *rop = NULL;
00573 const short *lop = NULL;
00574
00575 if (!pInData)
00576 {
00577 error = 1;
00578 fprintf(stderr, "Missing input data.\n");
00579 }
00580 else if (!pWithData)
00581 {
00582 error = 1;
00583 fprintf(stderr, "Missing input data.\n");
00584 }
00585 else
00586 {
00587 short *result = NULL;
00588 arraylen_t index = 0;
00589
00590 for (; index < nElements; index++)
00591 {
00592 result = &(pOutData[index]);
00593 *result = DRMS_MISSING_SHORT;
00594
00595 if (!drms_ismissing_short(pInData[index]) &&
00596 (!!drms_ismissing_short(pWithData[index])))
00597 {
00598 percentDone = index * 100/nElements;
00599
00600 if (first)
00601 {
00602 fprintf(stdout, "%03d%% done", percentDone);
00603 first = 0;
00604 }
00605 else if (percentDone == update)
00606 {
00607 update++;
00608 fprintf(stdout,
00609 "\b\b\b\b\b\b\b\b\b%03d%% done",
00610 percentDone);
00611 fflush(stdout);
00612 }
00613
00614 lop = &(pInData[index]);
00615 rop = &(pWithData[index]);
00616 *result = *lop * *rop;
00617
00618 }
00619 }
00620
00621 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
00622 fflush(stdout);
00623 }
00624
00625 return error;
00626 }
00627
00628 static int MultInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
00629 {
00630 int error = 0;
00631
00632 int first = 1;
00633 int percentDone = 0;
00634 int update = 0;
00635
00636 const int *rop = NULL;
00637 const int *lop = NULL;
00638
00639 if (!pInData)
00640 {
00641 error = 1;
00642 fprintf(stderr, "Missing input data.\n");
00643 }
00644 else if (!pWithData)
00645 {
00646 error = 1;
00647 fprintf(stderr, "Missing input data.\n");
00648 }
00649 else
00650 {
00651 int *result = NULL;
00652 arraylen_t index = 0;
00653
00654 for (; index < nElements; index++)
00655 {
00656 result = &(pOutData[index]);
00657 *result = DRMS_MISSING_INT;
00658
00659 if (!drms_ismissing_int(pInData[index]) &&
00660 (!!drms_ismissing_int(pWithData[index])))
00661 {
00662 percentDone = index * 100/nElements;
00663
00664 if (first)
00665 {
00666 fprintf(stdout, "%03d%% done", percentDone);
00667 first = 0;
00668 }
00669 else if (percentDone == update)
00670 {
00671 update++;
00672 fprintf(stdout,
00673 "\b\b\b\b\b\b\b\b\b%03d%% done",
00674 percentDone);
00675 fflush(stdout);
00676 }
00677
00678 lop = &(pInData[index]);
00679 rop = &(pWithData[index]);
00680 *result = *lop * *rop;
00681
00682 }
00683 }
00684
00685 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
00686 fflush(stdout);
00687 }
00688
00689 return error;
00690 }
00691
00692 static int MultLongLong(const long long *pInData,
00693 const long long *pWithData,
00694 arraylen_t nElements,
00695 long long *pOutData)
00696 {
00697 int error = 0;
00698
00699 int first = 1;
00700 int percentDone = 0;
00701 int update = 0;
00702
00703 const long long *rop = NULL;
00704 const long long *lop = NULL;
00705
00706 if (!pInData)
00707 {
00708 error = 1;
00709 fprintf(stderr, "Missing input data.\n");
00710 }
00711 else if (!pWithData)
00712 {
00713 error = 1;
00714 fprintf(stderr, "Missing input data.\n");
00715 }
00716 else
00717 {
00718 long long *result = NULL;
00719 arraylen_t index = 0;
00720
00721 for (; index < nElements; index++)
00722 {
00723 result = &(pOutData[index]);
00724 *result = DRMS_MISSING_LONGLONG;
00725
00726 if (!drms_ismissing_longlong(pInData[index]) &&
00727 (!!drms_ismissing_longlong(pWithData[index])))
00728 {
00729 percentDone = index * 100/nElements;
00730
00731 if (first)
00732 {
00733 fprintf(stdout, "%03d%% done", percentDone);
00734 first = 0;
00735 }
00736 else if (percentDone == update)
00737 {
00738 update++;
00739 fprintf(stdout,
00740 "\b\b\b\b\b\b\b\b\b%03d%% done",
00741 percentDone);
00742 fflush(stdout);
00743 }
00744
00745 lop = &(pInData[index]);
00746 rop = &(pWithData[index]);
00747 *result = *lop * *rop;
00748
00749 }
00750 }
00751
00752 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
00753 fflush(stdout);
00754 }
00755
00756 return error;
00757 }
00758
00759 static int MultFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
00760 {
00761 int error = 0;
00762
00763 int first = 1;
00764 int percentDone = 0;
00765 int update = 0;
00766
00767 const float *rop = NULL;
00768 const float *lop = NULL;
00769
00770 if (!pInData)
00771 {
00772 error = 1;
00773 fprintf(stderr, "Missing input data.\n");
00774 }
00775 else if (!pWithData)
00776 {
00777 error = 1;
00778 fprintf(stderr, "Missing input data.\n");
00779 }
00780 else
00781 {
00782 float *result = NULL;
00783 arraylen_t index = 0;
00784
00785 for (; index < nElements; index++)
00786 {
00787 result = &(pOutData[index]);
00788 *result = DRMS_MISSING_FLOAT;
00789
00790 if (!drms_ismissing_float(pInData[index]) &&
00791 (!!drms_ismissing_float(pWithData[index])))
00792 {
00793 percentDone = index * 100/nElements;
00794
00795 if (first)
00796 {
00797 fprintf(stdout, "%03d%% done", percentDone);
00798 first = 0;
00799 }
00800 else if (percentDone == update)
00801 {
00802 update++;
00803 fprintf(stdout,
00804 "\b\b\b\b\b\b\b\b\b%03d%% done",
00805 percentDone);
00806 fflush(stdout);
00807 }
00808
00809 lop = &(pInData[index]);
00810 rop = &(pWithData[index]);
00811 *result = *lop * *rop;
00812
00813 }
00814 }
00815
00816 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
00817 fflush(stdout);
00818 }
00819
00820 return error;
00821 }
00822
00823 static int MultDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
00824 {
00825 int error = 0;
00826
00827 int first = 1;
00828 int percentDone = 0;
00829 int update = 0;
00830
00831 const double *rop = NULL;
00832 const double *lop = NULL;
00833
00834 if (!pInData)
00835 {
00836 error = 1;
00837 fprintf(stderr, "Missing input data.\n");
00838 }
00839 else if (!pWithData)
00840 {
00841 error = 1;
00842 fprintf(stderr, "Missing input data.\n");
00843 }
00844 else
00845 {
00846 double *result = NULL;
00847 arraylen_t index = 0;
00848
00849 for (; index < nElements; index++)
00850 {
00851 result = &(pOutData[index]);
00852 *result = DRMS_MISSING_DOUBLE;
00853
00854 if (!drms_ismissing_double(pInData[index]) &&
00855 (!!drms_ismissing_double(pWithData[index])))
00856 {
00857 percentDone = index * 100/nElements;
00858
00859 if (first)
00860 {
00861 fprintf(stdout, "%03d%% done", percentDone);
00862 first = 0;
00863 }
00864 else if (percentDone == update)
00865 {
00866 update++;
00867 fprintf(stdout,
00868 "\b\b\b\b\b\b\b\b\b%03d%% done",
00869 percentDone);
00870 fflush(stdout);
00871 }
00872
00873 lop = &(pInData[index]);
00874 rop = &(pWithData[index]);
00875 *result = *lop * *rop;
00876
00877 }
00878 }
00879
00880 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
00881 fflush(stdout);
00882 }
00883
00884 return error;
00885 }
00886
00887 static int DivChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
00888 {
00889 int error = 0;
00890
00891 int first = 1;
00892 int percentDone = 0;
00893 int update = 0;
00894
00895 const char *rop = NULL;
00896 const char *lop = NULL;
00897
00898 if (!pInData)
00899 {
00900 error = 1;
00901 fprintf(stderr, "Missing input data.\n");
00902 }
00903 else if (!pWithData)
00904 {
00905 error = 1;
00906 fprintf(stderr, "Missing input data.\n");
00907 }
00908 else
00909 {
00910 char *result = NULL;
00911 arraylen_t index = 0;
00912
00913 for (; index < nElements; index++)
00914 {
00915 result = &(pOutData[index]);
00916 *result = DRMS_MISSING_CHAR;
00917
00918 if (!drms_ismissing_char(pInData[index]) &&
00919 (!!drms_ismissing_char(pWithData[index])))
00920 {
00921 percentDone = index * 100/nElements;
00922
00923 if (first)
00924 {
00925 fprintf(stdout, "%03d%% done", percentDone);
00926 first = 0;
00927 }
00928 else if (percentDone == update)
00929 {
00930 update++;
00931 fprintf(stdout,
00932 "\b\b\b\b\b\b\b\b\b%03d%% done",
00933 percentDone);
00934 fflush(stdout);
00935 }
00936
00937 lop = &(pInData[index]);
00938 rop = &(pWithData[index]);
00939 *result = *lop / *rop;
00940
00941 }
00942 }
00943
00944 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
00945 fflush(stdout);
00946 }
00947
00948 return error;
00949 }
00950
00951 static int DivShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
00952 {
00953 int error = 0;
00954
00955 int first = 1;
00956 int percentDone = 0;
00957 int update = 0;
00958
00959 const short *rop = NULL;
00960 const short *lop = NULL;
00961
00962 if (!pInData)
00963 {
00964 error = 1;
00965 fprintf(stderr, "Missing input data.\n");
00966 }
00967 else if (!pWithData)
00968 {
00969 error = 1;
00970 fprintf(stderr, "Missing input data.\n");
00971 }
00972 else
00973 {
00974 short *result = NULL;
00975 arraylen_t index = 0;
00976
00977 for (; index < nElements; index++)
00978 {
00979 result = &(pOutData[index]);
00980 *result = DRMS_MISSING_SHORT;
00981
00982 if (!drms_ismissing_short(pInData[index]) &&
00983 (!!drms_ismissing_short(pWithData[index])))
00984 {
00985 percentDone = index * 100/nElements;
00986
00987 if (first)
00988 {
00989 fprintf(stdout, "%03d%% done", percentDone);
00990 first = 0;
00991 }
00992 else if (percentDone == update)
00993 {
00994 update++;
00995 fprintf(stdout,
00996 "\b\b\b\b\b\b\b\b\b%03d%% done",
00997 percentDone);
00998 fflush(stdout);
00999 }
01000
01001 lop = &(pInData[index]);
01002 rop = &(pWithData[index]);
01003 *result = *lop / *rop;
01004
01005 }
01006 }
01007
01008 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01009 fflush(stdout);
01010 }
01011
01012 return error;
01013 }
01014
01015 static int DivInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
01016 {
01017 int error = 0;
01018
01019 int first = 1;
01020 int percentDone = 0;
01021 int update = 0;
01022
01023 const int *rop = NULL;
01024 const int *lop = NULL;
01025
01026 if (!pInData)
01027 {
01028 error = 1;
01029 fprintf(stderr, "Missing input data.\n");
01030 }
01031 else if (!pWithData)
01032 {
01033 error = 1;
01034 fprintf(stderr, "Missing input data.\n");
01035 }
01036 else
01037 {
01038 int *result = NULL;
01039 arraylen_t index = 0;
01040
01041 for (; index < nElements; index++)
01042 {
01043 result = &(pOutData[index]);
01044 *result = DRMS_MISSING_INT;
01045
01046 if (!drms_ismissing_int(pInData[index]) &&
01047 (!!drms_ismissing_int(pWithData[index])))
01048 {
01049 percentDone = index * 100/nElements;
01050
01051 if (first)
01052 {
01053 fprintf(stdout, "%03d%% done", percentDone);
01054 first = 0;
01055 }
01056 else if (percentDone == update)
01057 {
01058 update++;
01059 fprintf(stdout,
01060 "\b\b\b\b\b\b\b\b\b%03d%% done",
01061 percentDone);
01062 fflush(stdout);
01063 }
01064
01065 lop = &(pInData[index]);
01066 rop = &(pWithData[index]);
01067 *result = *lop / *rop;
01068
01069 }
01070 }
01071
01072 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01073 fflush(stdout);
01074 }
01075
01076 return error;
01077 }
01078
01079 static int DivLongLong(const long long *pInData,
01080 const long long *pWithData,
01081 arraylen_t nElements,
01082 long long *pOutData)
01083 {
01084 int error = 0;
01085
01086 int first = 1;
01087 int percentDone = 0;
01088 int update = 0;
01089
01090 const long long *rop = NULL;
01091 const long long *lop = NULL;
01092
01093 if (!pInData)
01094 {
01095 error = 1;
01096 fprintf(stderr, "Missing input data.\n");
01097 }
01098 else if (!pWithData)
01099 {
01100 error = 1;
01101 fprintf(stderr, "Missing input data.\n");
01102 }
01103 else
01104 {
01105 long long *result = NULL;
01106 arraylen_t index = 0;
01107
01108 for (; index < nElements; index++)
01109 {
01110 result = &(pOutData[index]);
01111 *result = DRMS_MISSING_LONGLONG;
01112
01113 if (!drms_ismissing_longlong(pInData[index]) &&
01114 (!!drms_ismissing_longlong(pWithData[index])))
01115 {
01116 percentDone = index * 100/nElements;
01117
01118 if (first)
01119 {
01120 fprintf(stdout, "%03d%% done", percentDone);
01121 first = 0;
01122 }
01123 else if (percentDone == update)
01124 {
01125 update++;
01126 fprintf(stdout,
01127 "\b\b\b\b\b\b\b\b\b%03d%% done",
01128 percentDone);
01129 fflush(stdout);
01130 }
01131
01132 lop = &(pInData[index]);
01133 rop = &(pWithData[index]);
01134 *result = *lop / *rop;
01135
01136 }
01137 }
01138
01139 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01140 fflush(stdout);
01141 }
01142
01143 return error;
01144 }
01145
01146 static int DivFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
01147 {
01148 int error = 0;
01149
01150 int first = 1;
01151 int percentDone = 0;
01152 int update = 0;
01153
01154 const float *rop = NULL;
01155 const float *lop = NULL;
01156
01157 if (!pInData)
01158 {
01159 error = 1;
01160 fprintf(stderr, "Missing input data.\n");
01161 }
01162 else if (!pWithData)
01163 {
01164 error = 1;
01165 fprintf(stderr, "Missing input data.\n");
01166 }
01167 else
01168 {
01169 float *result = NULL;
01170 arraylen_t index = 0;
01171
01172 for (; index < nElements; index++)
01173 {
01174 result = &(pOutData[index]);
01175 *result = DRMS_MISSING_FLOAT;
01176
01177 if (!drms_ismissing_float(pInData[index]) &&
01178 (!!drms_ismissing_float(pWithData[index])))
01179 {
01180 percentDone = index * 100/nElements;
01181
01182 if (first)
01183 {
01184 fprintf(stdout, "%03d%% done", percentDone);
01185 first = 0;
01186 }
01187 else if (percentDone == update)
01188 {
01189 update++;
01190 fprintf(stdout,
01191 "\b\b\b\b\b\b\b\b\b%03d%% done",
01192 percentDone);
01193 fflush(stdout);
01194 }
01195
01196 lop = &(pInData[index]);
01197 rop = &(pWithData[index]);
01198 *result = *lop / *rop;
01199
01200 }
01201 }
01202
01203 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01204 fflush(stdout);
01205 }
01206
01207 return error;
01208 }
01209
01210 static int DivDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
01211 {
01212 int error = 0;
01213
01214 int first = 1;
01215 int percentDone = 0;
01216 int update = 0;
01217
01218 const double *rop = NULL;
01219 const double *lop = NULL;
01220
01221 if (!pInData)
01222 {
01223 error = 1;
01224 fprintf(stderr, "Missing input data.\n");
01225 }
01226 else if (!pWithData)
01227 {
01228 error = 1;
01229 fprintf(stderr, "Missing input data.\n");
01230 }
01231 else
01232 {
01233 double *result = NULL;
01234 arraylen_t index = 0;
01235
01236 for (; index < nElements; index++)
01237 {
01238 result = &(pOutData[index]);
01239 *result = DRMS_MISSING_DOUBLE;
01240
01241 if (!drms_ismissing_double(pInData[index]) &&
01242 (!!drms_ismissing_double(pWithData[index])))
01243 {
01244 percentDone = index * 100/nElements;
01245
01246 if (first)
01247 {
01248 fprintf(stdout, "%03d%% done", percentDone);
01249 first = 0;
01250 }
01251 else if (percentDone == update)
01252 {
01253 update++;
01254 fprintf(stdout,
01255 "\b\b\b\b\b\b\b\b\b%03d%% done",
01256 percentDone);
01257 fflush(stdout);
01258 }
01259
01260 lop = &(pInData[index]);
01261 rop = &(pWithData[index]);
01262 *result = *lop / *rop;
01263
01264 }
01265 }
01266
01267 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01268 fflush(stdout);
01269 }
01270
01271 return error;
01272 }
01273
01274 static int AddChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
01275 {
01276 int error = 0;
01277
01278 int first = 1;
01279 int percentDone = 0;
01280 int update = 0;
01281
01282 const char *rop = NULL;
01283 const char *lop = NULL;
01284
01285 if (!pInData)
01286 {
01287 error = 1;
01288 fprintf(stderr, "Missing input data.\n");
01289 }
01290 else if (!pWithData)
01291 {
01292 error = 1;
01293 fprintf(stderr, "Missing input data.\n");
01294 }
01295 else
01296 {
01297 char *result = NULL;
01298 arraylen_t index = 0;
01299
01300 for (; index < nElements; index++)
01301 {
01302 result = &(pOutData[index]);
01303 *result = DRMS_MISSING_CHAR;
01304
01305 if (!drms_ismissing_char(pInData[index]) &&
01306 (!!drms_ismissing_char(pWithData[index])))
01307 {
01308 percentDone = index * 100/nElements;
01309
01310 if (first)
01311 {
01312 fprintf(stdout, "%03d%% done", percentDone);
01313 first = 0;
01314 }
01315 else if (percentDone == update)
01316 {
01317 update++;
01318 fprintf(stdout,
01319 "\b\b\b\b\b\b\b\b\b%03d%% done",
01320 percentDone);
01321 fflush(stdout);
01322 }
01323
01324 lop = &(pInData[index]);
01325 rop = &(pWithData[index]);
01326 *result = *lop + *rop;
01327 }
01328 }
01329
01330 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01331 fflush(stdout);
01332 }
01333
01334 return error;
01335 }
01336
01337 static int AddShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
01338 {
01339 int error = 0;
01340
01341 int first = 1;
01342 int percentDone = 0;
01343 int update = 0;
01344
01345 const short *rop = NULL;
01346 const short *lop = NULL;
01347
01348 if (!pInData)
01349 {
01350 error = 1;
01351 fprintf(stderr, "Missing input data.\n");
01352 }
01353 else if (!pWithData)
01354 {
01355 error = 1;
01356 fprintf(stderr, "Missing input data.\n");
01357 }
01358 else
01359 {
01360 short *result = NULL;
01361 arraylen_t index = 0;
01362
01363 for (; index < nElements; index++)
01364 {
01365 result = &(pOutData[index]);
01366 *result = DRMS_MISSING_SHORT;
01367
01368 if (!drms_ismissing_short(pInData[index]) &&
01369 (!!drms_ismissing_short(pWithData[index])))
01370 {
01371 percentDone = index * 100/nElements;
01372
01373 if (first)
01374 {
01375 fprintf(stdout, "%03d%% done", percentDone);
01376 first = 0;
01377 }
01378 else if (percentDone == update)
01379 {
01380 update++;
01381 fprintf(stdout,
01382 "\b\b\b\b\b\b\b\b\b%03d%% done",
01383 percentDone);
01384 fflush(stdout);
01385 }
01386
01387 lop = &(pInData[index]);
01388 rop = &(pWithData[index]);
01389 *result = *lop + *rop;
01390 }
01391 }
01392
01393 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01394 fflush(stdout);
01395 }
01396
01397 return error;
01398 }
01399
01400 static int AddInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
01401 {
01402 int error = 0;
01403
01404 int first = 1;
01405 int percentDone = 0;
01406 int update = 0;
01407
01408 const int *rop = NULL;
01409 const int *lop = NULL;
01410
01411 if (!pInData)
01412 {
01413 error = 1;
01414 fprintf(stderr, "Missing input data.\n");
01415 }
01416 else if (!pWithData)
01417 {
01418 error = 1;
01419 fprintf(stderr, "Missing input data.\n");
01420 }
01421 else
01422 {
01423 int *result = NULL;
01424 arraylen_t index = 0;
01425
01426 for (; index < nElements; index++)
01427 {
01428 result = &(pOutData[index]);
01429 *result = DRMS_MISSING_INT;
01430
01431 if (!drms_ismissing_int(pInData[index]) &&
01432 (!!drms_ismissing_int(pWithData[index])))
01433 {
01434 percentDone = index * 100/nElements;
01435
01436 if (first)
01437 {
01438 fprintf(stdout, "%03d%% done", percentDone);
01439 first = 0;
01440 }
01441 else if (percentDone == update)
01442 {
01443 update++;
01444 fprintf(stdout,
01445 "\b\b\b\b\b\b\b\b\b%03d%% done",
01446 percentDone);
01447 fflush(stdout);
01448 }
01449
01450 lop = &(pInData[index]);
01451 rop = &(pWithData[index]);
01452 *result = *lop + *rop;
01453 }
01454 }
01455
01456 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01457 fflush(stdout);
01458 }
01459
01460 return error;
01461 }
01462
01463 static int AddLongLong(const long long *pInData,
01464 const long long *pWithData,
01465 arraylen_t nElements,
01466 long long *pOutData)
01467 {
01468 int error = 0;
01469
01470 int first = 1;
01471 int percentDone = 0;
01472 int update = 0;
01473
01474 const long long *rop = NULL;
01475 const long long *lop = NULL;
01476
01477 if (!pInData)
01478 {
01479 error = 1;
01480 fprintf(stderr, "Missing input data.\n");
01481 }
01482 else if (!pWithData)
01483 {
01484 error = 1;
01485 fprintf(stderr, "Missing input data.\n");
01486 }
01487 else
01488 {
01489 long long *result = NULL;
01490 arraylen_t index = 0;
01491
01492 for (; index < nElements; index++)
01493 {
01494 result = &(pOutData[index]);
01495 *result = DRMS_MISSING_LONGLONG;
01496
01497 if (!drms_ismissing_longlong(pInData[index]) &&
01498 (!!drms_ismissing_longlong(pWithData[index])))
01499 {
01500 percentDone = index * 100/nElements;
01501
01502 if (first)
01503 {
01504 fprintf(stdout, "%03d%% done", percentDone);
01505 first = 0;
01506 }
01507 else if (percentDone == update)
01508 {
01509 update++;
01510 fprintf(stdout,
01511 "\b\b\b\b\b\b\b\b\b%03d%% done",
01512 percentDone);
01513 fflush(stdout);
01514 }
01515
01516 lop = &(pInData[index]);
01517 rop = &(pWithData[index]);
01518 *result = *lop + *rop;
01519 }
01520 }
01521
01522 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01523 fflush(stdout);
01524 }
01525
01526 return error;
01527 }
01528
01529 static int AddFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
01530 {
01531 int error = 0;
01532
01533 int first = 1;
01534 int percentDone = 0;
01535 int update = 0;
01536
01537 const float *rop = NULL;
01538 const float *lop = NULL;
01539
01540 if (!pInData)
01541 {
01542 error = 1;
01543 fprintf(stderr, "Missing input data.\n");
01544 }
01545 else if (!pWithData)
01546 {
01547 error = 1;
01548 fprintf(stderr, "Missing input data.\n");
01549 }
01550 else
01551 {
01552 float *result = NULL;
01553 arraylen_t index = 0;
01554
01555 for (; index < nElements; index++)
01556 {
01557 result = &(pOutData[index]);
01558 *result = DRMS_MISSING_FLOAT;
01559
01560 if (!drms_ismissing_float(pInData[index]) &&
01561 (!!drms_ismissing_float(pWithData[index])))
01562 {
01563 percentDone = index * 100/nElements;
01564
01565 if (first)
01566 {
01567 fprintf(stdout, "%03d%% done", percentDone);
01568 first = 0;
01569 }
01570 else if (percentDone == update)
01571 {
01572 update++;
01573 fprintf(stdout,
01574 "\b\b\b\b\b\b\b\b\b%03d%% done",
01575 percentDone);
01576 fflush(stdout);
01577 }
01578
01579 lop = &(pInData[index]);
01580 rop = &(pWithData[index]);
01581 *result = *lop + *rop;
01582 }
01583 }
01584
01585 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01586 fflush(stdout);
01587 }
01588
01589 return error;
01590 }
01591
01592 static int AddDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
01593 {
01594 int error = 0;
01595
01596 int first = 1;
01597 int percentDone = 0;
01598 int update = 0;
01599
01600 const double *rop = NULL;
01601 const double *lop = NULL;
01602
01603 if (!pInData)
01604 {
01605 error = 1;
01606 fprintf(stderr, "Missing input data.\n");
01607 }
01608 else if (!pWithData)
01609 {
01610 error = 1;
01611 fprintf(stderr, "Missing input data.\n");
01612 }
01613 else
01614 {
01615 double *result = NULL;
01616 arraylen_t index = 0;
01617
01618 for (; index < nElements; index++)
01619 {
01620 result = &(pOutData[index]);
01621 *result = DRMS_MISSING_DOUBLE;
01622
01623 if (!drms_ismissing_double(pInData[index]) &&
01624 (!!drms_ismissing_double(pWithData[index])))
01625 {
01626 percentDone = index * 100/nElements;
01627
01628 if (first)
01629 {
01630 fprintf(stdout, "%03d%% done", percentDone);
01631 first = 0;
01632 }
01633 else if (percentDone == update)
01634 {
01635 update++;
01636 fprintf(stdout,
01637 "\b\b\b\b\b\b\b\b\b%03d%% done",
01638 percentDone);
01639 fflush(stdout);
01640 }
01641
01642 lop = &(pInData[index]);
01643 rop = &(pWithData[index]);
01644 *result = *lop + *rop;
01645 }
01646 }
01647
01648 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01649 fflush(stdout);
01650 }
01651
01652 return error;
01653 }
01654
01655 static int SubChar(const char *pInData, const char *pWithData, arraylen_t nElements, char *pOutData)
01656 {
01657 int error = 0;
01658
01659 int first = 1;
01660 int percentDone = 0;
01661 int update = 0;
01662
01663 const char *rop = NULL;
01664 const char *lop = NULL;
01665
01666 if (!pInData)
01667 {
01668 error = 1;
01669 fprintf(stderr, "Missing input data.\n");
01670 }
01671 else if (!pWithData)
01672 {
01673 error = 1;
01674 fprintf(stderr, "Missing input data.\n");
01675 }
01676 else
01677 {
01678 char *result = NULL;
01679 arraylen_t index = 0;
01680
01681 for (; index < nElements; index++)
01682 {
01683 result = &(pOutData[index]);
01684 *result = DRMS_MISSING_CHAR;
01685
01686 if (!drms_ismissing_char(pInData[index]) &&
01687 (!!drms_ismissing_char(pWithData[index])))
01688 {
01689 percentDone = index * 100/nElements;
01690
01691 if (first)
01692 {
01693 fprintf(stdout, "%03d%% done", percentDone);
01694 first = 0;
01695 }
01696 else if (percentDone == update)
01697 {
01698 update++;
01699 fprintf(stdout,
01700 "\b\b\b\b\b\b\b\b\b%03d%% done",
01701 percentDone);
01702 fflush(stdout);
01703 }
01704
01705 lop = &(pInData[index]);
01706 rop = &(pWithData[index]);
01707 *result = *lop - *rop;
01708 }
01709 }
01710
01711 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01712 fflush(stdout);
01713 }
01714
01715 return error;
01716 }
01717
01718 static int SubShort(const short *pInData, const short *pWithData, arraylen_t nElements, short *pOutData)
01719 {
01720 int error = 0;
01721
01722 int first = 1;
01723 int percentDone = 0;
01724 int update = 0;
01725
01726 const short *rop = NULL;
01727 const short *lop = NULL;
01728
01729 if (!pInData)
01730 {
01731 error = 1;
01732 fprintf(stderr, "Missing input data.\n");
01733 }
01734 else if (!pWithData)
01735 {
01736 error = 1;
01737 fprintf(stderr, "Missing input data.\n");
01738 }
01739 else
01740 {
01741 short *result = NULL;
01742 arraylen_t index = 0;
01743
01744 for (; index < nElements; index++)
01745 {
01746 result = &(pOutData[index]);
01747 *result = DRMS_MISSING_SHORT;
01748
01749 if (!drms_ismissing_short(pInData[index]) &&
01750 (!!drms_ismissing_short(pWithData[index])))
01751 {
01752 percentDone = index * 100/nElements;
01753
01754 if (first)
01755 {
01756 fprintf(stdout, "%03d%% done", percentDone);
01757 first = 0;
01758 }
01759 else if (percentDone == update)
01760 {
01761 update++;
01762 fprintf(stdout,
01763 "\b\b\b\b\b\b\b\b\b%03d%% done",
01764 percentDone);
01765 fflush(stdout);
01766 }
01767
01768 lop = &(pInData[index]);
01769 rop = &(pWithData[index]);
01770 *result = *lop - *rop;
01771 }
01772 }
01773
01774 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01775 fflush(stdout);
01776 }
01777
01778 return error;
01779 }
01780
01781 static int SubInt(const int *pInData, const int *pWithData, arraylen_t nElements, int *pOutData)
01782 {
01783 int error = 0;
01784
01785 int first = 1;
01786 int percentDone = 0;
01787 int update = 0;
01788
01789 const int *rop = NULL;
01790 const int *lop = NULL;
01791
01792 if (!pInData)
01793 {
01794 error = 1;
01795 fprintf(stderr, "Missing input data.\n");
01796 }
01797 else if (!pWithData)
01798 {
01799 error = 1;
01800 fprintf(stderr, "Missing input data.\n");
01801 }
01802 else
01803 {
01804 int *result = NULL;
01805 arraylen_t index = 0;
01806
01807 for (; index < nElements; index++)
01808 {
01809 result = &(pOutData[index]);
01810 *result = DRMS_MISSING_INT;
01811
01812 if (!drms_ismissing_int(pInData[index]) &&
01813 (!!drms_ismissing_int(pWithData[index])))
01814 {
01815 percentDone = index * 100/nElements;
01816
01817 if (first)
01818 {
01819 fprintf(stdout, "%03d%% done", percentDone);
01820 first = 0;
01821 }
01822 else if (percentDone == update)
01823 {
01824 update++;
01825 fprintf(stdout,
01826 "\b\b\b\b\b\b\b\b\b%03d%% done",
01827 percentDone);
01828 fflush(stdout);
01829 }
01830
01831 lop = &(pInData[index]);
01832 rop = &(pWithData[index]);
01833 *result = *lop - *rop;
01834 }
01835 }
01836
01837 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01838 fflush(stdout);
01839 }
01840
01841 return error;
01842 }
01843
01844 static int SubLongLong(const long long *pInData,
01845 const long long *pWithData,
01846 arraylen_t nElements,
01847 long long *pOutData)
01848 {
01849 int error = 0;
01850
01851 int first = 1;
01852 int percentDone = 0;
01853 int update = 0;
01854
01855 const long long *rop = NULL;
01856 const long long *lop = NULL;
01857
01858 if (!pInData)
01859 {
01860 error = 1;
01861 fprintf(stderr, "Missing input data.\n");
01862 }
01863 else if (!pWithData)
01864 {
01865 error = 1;
01866 fprintf(stderr, "Missing input data.\n");
01867 }
01868 else
01869 {
01870 long long *result = NULL;
01871 arraylen_t index = 0;
01872
01873 for (; index < nElements; index++)
01874 {
01875 result = &(pOutData[index]);
01876 *result = DRMS_MISSING_LONGLONG;
01877
01878 if (!drms_ismissing_longlong(pInData[index]) &&
01879 (!!drms_ismissing_longlong(pWithData[index])))
01880 {
01881 percentDone = index * 100/nElements;
01882
01883 if (first)
01884 {
01885 fprintf(stdout, "%03d%% done", percentDone);
01886 first = 0;
01887 }
01888 else if (percentDone == update)
01889 {
01890 update++;
01891 fprintf(stdout,
01892 "\b\b\b\b\b\b\b\b\b%03d%% done",
01893 percentDone);
01894 fflush(stdout);
01895 }
01896
01897 lop = &(pInData[index]);
01898 rop = &(pWithData[index]);
01899 *result = *lop - *rop;
01900 }
01901 }
01902
01903 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01904 fflush(stdout);
01905 }
01906
01907 return error;
01908 }
01909
01910 static int SubFloat(const float *pInData, const float *pWithData, arraylen_t nElements, float *pOutData)
01911 {
01912 int error = 0;
01913
01914 int first = 1;
01915 int percentDone = 0;
01916 int update = 0;
01917
01918 const float *rop = NULL;
01919 const float *lop = NULL;
01920
01921 if (!pInData)
01922 {
01923 error = 1;
01924 fprintf(stderr, "Missing input data.\n");
01925 }
01926 else if (!pWithData)
01927 {
01928 error = 1;
01929 fprintf(stderr, "Missing input data.\n");
01930 }
01931 else
01932 {
01933 float *result = NULL;
01934 arraylen_t index = 0;
01935
01936 for (; index < nElements; index++)
01937 {
01938 result = &(pOutData[index]);
01939 *result = DRMS_MISSING_FLOAT;
01940
01941 if (!drms_ismissing_float(pInData[index]) &&
01942 (!!drms_ismissing_float(pWithData[index])))
01943 {
01944 percentDone = index * 100/nElements;
01945
01946 if (first)
01947 {
01948 fprintf(stdout, "%03d%% done", percentDone);
01949 first = 0;
01950 }
01951 else if (percentDone == update)
01952 {
01953 update++;
01954 fprintf(stdout,
01955 "\b\b\b\b\b\b\b\b\b%03d%% done",
01956 percentDone);
01957 fflush(stdout);
01958 }
01959
01960 lop = &(pInData[index]);
01961 rop = &(pWithData[index]);
01962 *result = *lop - *rop;
01963 }
01964 }
01965
01966 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
01967 fflush(stdout);
01968 }
01969
01970 return error;
01971 }
01972
01973 static int SubDouble(const double *pInData, const double *pWithData, arraylen_t nElements, double *pOutData)
01974 {
01975 int error = 0;
01976
01977 int first = 1;
01978 int percentDone = 0;
01979 int update = 0;
01980
01981 const double *rop = NULL;
01982 const double *lop = NULL;
01983
01984 if (!pInData)
01985 {
01986 error = 1;
01987 fprintf(stderr, "Missing input data.\n");
01988 }
01989 else if (!pWithData)
01990 {
01991 error = 1;
01992 fprintf(stderr, "Missing input data.\n");
01993 }
01994 else
01995 {
01996 double *result = NULL;
01997 arraylen_t index = 0;
01998
01999 for (; index < nElements; index++)
02000 {
02001 result = &(pOutData[index]);
02002 *result = DRMS_MISSING_DOUBLE;
02003
02004 if (!drms_ismissing_double(pInData[index]) &&
02005 (!!drms_ismissing_double(pWithData[index])))
02006 {
02007 percentDone = index * 100/nElements;
02008
02009 if (first)
02010 {
02011 fprintf(stdout, "%03d%% done", percentDone);
02012 first = 0;
02013 }
02014 else if (percentDone == update)
02015 {
02016 update++;
02017 fprintf(stdout,
02018 "\b\b\b\b\b\b\b\b\b%03d%% done",
02019 percentDone);
02020 fflush(stdout);
02021 }
02022
02023 lop = &(pInData[index]);
02024 rop = &(pWithData[index]);
02025 *result = *lop - *rop;
02026 }
02027 }
02028
02029 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02030 fflush(stdout);
02031 }
02032
02033 return error;
02034 }
02035
02036 static int AbsChar(const char *pInData, arraylen_t nElements, char *pOutData)
02037 {
02038 int error = 0;
02039
02040 int first = 1;
02041 int percentDone = 0;
02042 int update = 0;
02043
02044 const char *lop = NULL;
02045
02046 if (!pInData)
02047 {
02048 error = 1;
02049 fprintf(stderr, "Missing input data.\n");
02050 }
02051 else
02052 {
02053 char *result = NULL;
02054 arraylen_t index = 0;
02055
02056 for (; index < nElements; index++)
02057 {
02058 result = &(pOutData[index]);
02059 *result = DRMS_MISSING_CHAR;
02060
02061 if (!drms_ismissing_char(pInData[index]))
02062 {
02063 percentDone = index * 100/nElements;
02064
02065 if (first)
02066 {
02067 fprintf(stdout, "%03d%% done", percentDone);
02068 first = 0;
02069 }
02070 else if (percentDone == update)
02071 {
02072 update++;
02073 fprintf(stdout,
02074 "\b\b\b\b\b\b\b\b\b%03d%% done",
02075 percentDone);
02076 fflush(stdout);
02077 }
02078
02079 lop = &(pInData[index]);
02080 *result = abs(*lop);
02081 }
02082 }
02083
02084 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02085 fflush(stdout);
02086 }
02087
02088 return error;
02089 }
02090
02091 static int AbsShort(const short *pInData, arraylen_t nElements, short *pOutData)
02092 {
02093 int error = 0;
02094
02095 int first = 1;
02096 int percentDone = 0;
02097 int update = 0;
02098
02099 const short *lop = NULL;
02100
02101 if (!pInData)
02102 {
02103 error = 1;
02104 fprintf(stderr, "Missing input data.\n");
02105 }
02106 else
02107 {
02108 short *result = NULL;
02109 arraylen_t index = 0;
02110
02111 for (; index < nElements; index++)
02112 {
02113 result = &(pOutData[index]);
02114 *result = DRMS_MISSING_SHORT;
02115
02116 if (!drms_ismissing_short(pInData[index]))
02117 {
02118 percentDone = index * 100/nElements;
02119
02120 if (first)
02121 {
02122 fprintf(stdout, "%03d%% done", percentDone);
02123 first = 0;
02124 }
02125 else if (percentDone == update)
02126 {
02127 update++;
02128 fprintf(stdout,
02129 "\b\b\b\b\b\b\b\b\b%03d%% done",
02130 percentDone);
02131 fflush(stdout);
02132 }
02133
02134 lop = &(pInData[index]);
02135 *result = abs(*lop);
02136 }
02137 }
02138
02139 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02140 fflush(stdout);
02141 }
02142
02143 return error;
02144 }
02145
02146 static int AbsInt(const int *pInData, arraylen_t nElements, int *pOutData)
02147 {
02148 int error = 0;
02149
02150 int first = 1;
02151 int percentDone = 0;
02152 int update = 0;
02153
02154 const int *lop = NULL;
02155
02156 if (!pInData)
02157 {
02158 error = 1;
02159 fprintf(stderr, "Missing input data.\n");
02160 }
02161 else
02162 {
02163 int *result = NULL;
02164 arraylen_t index = 0;
02165
02166 for (; index < nElements; index++)
02167 {
02168 result = &(pOutData[index]);
02169 *result = DRMS_MISSING_INT;
02170
02171 if (!drms_ismissing_int(pInData[index]))
02172 {
02173 percentDone = index * 100/nElements;
02174
02175 if (first)
02176 {
02177 fprintf(stdout, "%03d%% done", percentDone);
02178 first = 0;
02179 }
02180 else if (percentDone == update)
02181 {
02182 update++;
02183 fprintf(stdout,
02184 "\b\b\b\b\b\b\b\b\b%03d%% done",
02185 percentDone);
02186 fflush(stdout);
02187 }
02188
02189 lop = &(pInData[index]);
02190 *result = abs(*lop);
02191 }
02192 }
02193
02194 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02195 fflush(stdout);
02196 }
02197
02198 return error;
02199 }
02200
02201 static int AbsLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
02202 {
02203 int error = 0;
02204
02205 int first = 1;
02206 int percentDone = 0;
02207 int update = 0;
02208
02209 const long long *lop = NULL;
02210
02211 if (!pInData)
02212 {
02213 error = 1;
02214 fprintf(stderr, "Missing input data.\n");
02215 }
02216 else
02217 {
02218 long long *result = NULL;
02219 arraylen_t index = 0;
02220
02221 for (; index < nElements; index++)
02222 {
02223 result = &(pOutData[index]);
02224 *result = DRMS_MISSING_LONGLONG;
02225
02226 if (!drms_ismissing_longlong(pInData[index]))
02227 {
02228 percentDone = index * 100/nElements;
02229
02230 if (first)
02231 {
02232 fprintf(stdout, "%03d%% done", percentDone);
02233 first = 0;
02234 }
02235 else if (percentDone == update)
02236 {
02237 update++;
02238 fprintf(stdout,
02239 "\b\b\b\b\b\b\b\b\b%03d%% done",
02240 percentDone);
02241 fflush(stdout);
02242 }
02243
02244 lop = &(pInData[index]);
02245 *result = llabs(*lop);
02246 }
02247 }
02248
02249 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02250 fflush(stdout);
02251 }
02252
02253 return error;
02254 }
02255
02256 static int AbsFloat(const float *pInData, arraylen_t nElements, float *pOutData)
02257 {
02258 int error = 0;
02259
02260 int first = 1;
02261 int percentDone = 0;
02262 int update = 0;
02263
02264 const float *lop = NULL;
02265
02266 if (!pInData)
02267 {
02268 error = 1;
02269 fprintf(stderr, "Missing input data.\n");
02270 }
02271 else
02272 {
02273 float *result = NULL;
02274 arraylen_t index = 0;
02275
02276 for (; index < nElements; index++)
02277 {
02278 result = &(pOutData[index]);
02279 *result = DRMS_MISSING_FLOAT;
02280
02281 if (!drms_ismissing_float(pInData[index]))
02282 {
02283 percentDone = index * 100/nElements;
02284
02285 if (first)
02286 {
02287 fprintf(stdout, "%03d%% done", percentDone);
02288 first = 0;
02289 }
02290 else if (percentDone == update)
02291 {
02292 update++;
02293 fprintf(stdout,
02294 "\b\b\b\b\b\b\b\b\b%03d%% done",
02295 percentDone);
02296 fflush(stdout);
02297 }
02298
02299 lop = &(pInData[index]);
02300 *result = fabsf(*lop);
02301 }
02302 }
02303
02304 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02305 fflush(stdout);
02306 }
02307
02308 return error;
02309 }
02310
02311 static int AbsDouble(const double *pInData, arraylen_t nElements, double *pOutData)
02312 {
02313 int error = 0;
02314
02315 int first = 1;
02316 int percentDone = 0;
02317 int update = 0;
02318
02319 const double *lop = NULL;
02320
02321 if (!pInData)
02322 {
02323 error = 1;
02324 fprintf(stderr, "Missing input data.\n");
02325 }
02326 else
02327 {
02328 double *result = NULL;
02329 arraylen_t index = 0;
02330
02331 for (; index < nElements; index++)
02332 {
02333 result = &(pOutData[index]);
02334 *result = DRMS_MISSING_DOUBLE;
02335
02336 if (!drms_ismissing_double(pInData[index]))
02337 {
02338 percentDone = index * 100/nElements;
02339
02340 if (first)
02341 {
02342 fprintf(stdout, "%03d%% done", percentDone);
02343 first = 0;
02344 }
02345 else if (percentDone == update)
02346 {
02347 update++;
02348 fprintf(stdout,
02349 "\b\b\b\b\b\b\b\b\b%03d%% done",
02350 percentDone);
02351 fflush(stdout);
02352 }
02353
02354 lop = &(pInData[index]);
02355 *result = fabs(*lop);
02356 }
02357 }
02358
02359 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02360 fflush(stdout);
02361 }
02362
02363 return error;
02364 }
02365
02366 static int SqrtChar(const char *pInData, arraylen_t nElements, char *pOutData)
02367 {
02368 int error = 0;
02369
02370 int first = 1;
02371 int percentDone = 0;
02372 int update = 0;
02373
02374 const char *lop = NULL;
02375
02376 if (!pInData)
02377 {
02378 error = 1;
02379 fprintf(stderr, "Missing input data.\n");
02380 }
02381 else
02382 {
02383 char *result = NULL;
02384 arraylen_t index = 0;
02385
02386 for (; index < nElements; index++)
02387 {
02388 result = &(pOutData[index]);
02389 *result = DRMS_MISSING_CHAR;
02390
02391 if (!drms_ismissing_char(pInData[index]))
02392 {
02393 percentDone = index * 100/nElements;
02394
02395 if (first)
02396 {
02397 fprintf(stdout, "%03d%% done", percentDone);
02398 first = 0;
02399 }
02400 else if (percentDone == update)
02401 {
02402 update++;
02403 fprintf(stdout,
02404 "\b\b\b\b\b\b\b\b\b%03d%% done",
02405 percentDone);
02406 fflush(stdout);
02407 }
02408
02409 lop = &(pInData[index]);
02410 *result = sqrt(abs(*lop));
02411 }
02412 }
02413
02414 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02415 fflush(stdout);
02416 }
02417
02418 return error;
02419 }
02420
02421 static int SqrtShort(const short *pInData, arraylen_t nElements, short *pOutData)
02422 {
02423 int error = 0;
02424
02425 int first = 1;
02426 int percentDone = 0;
02427 int update = 0;
02428
02429 const short *lop = NULL;
02430
02431 if (!pInData)
02432 {
02433 error = 1;
02434 fprintf(stderr, "Missing input data.\n");
02435 }
02436 else
02437 {
02438 short *result = NULL;
02439 arraylen_t index = 0;
02440
02441 for (; index < nElements; index++)
02442 {
02443 result = &(pOutData[index]);
02444 *result = DRMS_MISSING_SHORT;
02445
02446 if (!drms_ismissing_short(pInData[index]))
02447 {
02448 percentDone = index * 100/nElements;
02449
02450 if (first)
02451 {
02452 fprintf(stdout, "%03d%% done", percentDone);
02453 first = 0;
02454 }
02455 else if (percentDone == update)
02456 {
02457 update++;
02458 fprintf(stdout,
02459 "\b\b\b\b\b\b\b\b\b%03d%% done",
02460 percentDone);
02461 fflush(stdout);
02462 }
02463
02464 lop = &(pInData[index]);
02465 *result = sqrt(abs(*lop));
02466 }
02467 }
02468
02469 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02470 fflush(stdout);
02471 }
02472
02473 return error;
02474 }
02475
02476 static int SqrtInt(const int *pInData, arraylen_t nElements, int *pOutData)
02477 {
02478 int error = 0;
02479
02480 int first = 1;
02481 int percentDone = 0;
02482 int update = 0;
02483
02484 const int *lop = NULL;
02485
02486 if (!pInData)
02487 {
02488 error = 1;
02489 fprintf(stderr, "Missing input data.\n");
02490 }
02491 else
02492 {
02493 int *result = NULL;
02494 arraylen_t index = 0;
02495
02496 for (; index < nElements; index++)
02497 {
02498 result = &(pOutData[index]);
02499 *result = DRMS_MISSING_INT;
02500
02501 if (!drms_ismissing_int(pInData[index]))
02502 {
02503 percentDone = index * 100/nElements;
02504
02505 if (first)
02506 {
02507 fprintf(stdout, "%03d%% done", percentDone);
02508 first = 0;
02509 }
02510 else if (percentDone == update)
02511 {
02512 update++;
02513 fprintf(stdout,
02514 "\b\b\b\b\b\b\b\b\b%03d%% done",
02515 percentDone);
02516 fflush(stdout);
02517 }
02518
02519 lop = &(pInData[index]);
02520 *result = sqrt(abs(*lop));
02521 }
02522 }
02523
02524 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02525 fflush(stdout);
02526 }
02527
02528 return error;
02529 }
02530
02531 static int SqrtLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
02532 {
02533 int error = 0;
02534
02535 int first = 1;
02536 int percentDone = 0;
02537 int update = 0;
02538
02539 const long long *lop = NULL;
02540
02541 if (!pInData)
02542 {
02543 error = 1;
02544 fprintf(stderr, "Missing input data.\n");
02545 }
02546 else
02547 {
02548 long long *result = NULL;
02549 arraylen_t index = 0;
02550
02551 for (; index < nElements; index++)
02552 {
02553 result = &(pOutData[index]);
02554 *result = DRMS_MISSING_LONGLONG;
02555
02556 if (!drms_ismissing_longlong(pInData[index]))
02557 {
02558 percentDone = index * 100/nElements;
02559
02560 if (first)
02561 {
02562 fprintf(stdout, "%03d%% done", percentDone);
02563 first = 0;
02564 }
02565 else if (percentDone == update)
02566 {
02567 update++;
02568 fprintf(stdout,
02569 "\b\b\b\b\b\b\b\b\b%03d%% done",
02570 percentDone);
02571 fflush(stdout);
02572 }
02573
02574 lop = &(pInData[index]);
02575 *result = sqrt(llabs(*lop));
02576 }
02577 }
02578
02579 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02580 fflush(stdout);
02581 }
02582
02583 return error;
02584 }
02585
02586 static int SqrtFloat(const float *pInData, arraylen_t nElements, float *pOutData)
02587 {
02588 int error = 0;
02589
02590 int first = 1;
02591 int percentDone = 0;
02592 int update = 0;
02593
02594 const float *lop = NULL;
02595
02596 if (!pInData)
02597 {
02598 error = 1;
02599 fprintf(stderr, "Missing input data.\n");
02600 }
02601 else
02602 {
02603 float *result = NULL;
02604 arraylen_t index = 0;
02605
02606 for (; index < nElements; index++)
02607 {
02608 result = &(pOutData[index]);
02609 *result = DRMS_MISSING_FLOAT;
02610
02611 if (!drms_ismissing_float(pInData[index]))
02612 {
02613 percentDone = index * 100/nElements;
02614
02615 if (first)
02616 {
02617 fprintf(stdout, "%03d%% done", percentDone);
02618 first = 0;
02619 }
02620 else if (percentDone == update)
02621 {
02622 update++;
02623 fprintf(stdout,
02624 "\b\b\b\b\b\b\b\b\b%03d%% done",
02625 percentDone);
02626 fflush(stdout);
02627 }
02628
02629 lop = &(pInData[index]);
02630 *result = sqrt(fabsf(*lop));
02631 }
02632 }
02633
02634 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02635 fflush(stdout);
02636 }
02637
02638 return error;
02639 }
02640
02641 static int SqrtDouble(const double *pInData, arraylen_t nElements, double *pOutData)
02642 {
02643 int error = 0;
02644
02645 int first = 1;
02646 int percentDone = 0;
02647 int update = 0;
02648
02649 const double *lop = NULL;
02650
02651 if (!pInData)
02652 {
02653 error = 1;
02654 fprintf(stderr, "Missing input data.\n");
02655 }
02656 else
02657 {
02658 double *result = NULL;
02659 arraylen_t index = 0;
02660
02661 for (; index < nElements; index++)
02662 {
02663 result = &(pOutData[index]);
02664 *result = DRMS_MISSING_DOUBLE;
02665
02666 if (!drms_ismissing_double(pInData[index]))
02667 {
02668 percentDone = index * 100/nElements;
02669
02670 if (first)
02671 {
02672 fprintf(stdout, "%03d%% done", percentDone);
02673 first = 0;
02674 }
02675 else if (percentDone == update)
02676 {
02677 update++;
02678 fprintf(stdout,
02679 "\b\b\b\b\b\b\b\b\b%03d%% done",
02680 percentDone);
02681 fflush(stdout);
02682 }
02683
02684 lop = &(pInData[index]);
02685 *result = sqrt(fabs(*lop));
02686 }
02687 }
02688
02689 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02690 fflush(stdout);
02691 }
02692
02693 return error;
02694 }
02695
02696 static int LogChar(const char *pInData, arraylen_t nElements, char *pOutData)
02697 {
02698 int error = 0;
02699
02700 int first = 1;
02701 int percentDone = 0;
02702 int update = 0;
02703
02704 const char *lop = NULL;
02705
02706 if (!pInData)
02707 {
02708 error = 1;
02709 fprintf(stderr, "Missing input data.\n");
02710 }
02711 else
02712 {
02713 char *result = NULL;
02714 arraylen_t index = 0;
02715
02716 for (; index < nElements; index++)
02717 {
02718 result = &(pOutData[index]);
02719 *result = DRMS_MISSING_CHAR;
02720
02721 if (!drms_ismissing_char(pInData[index]))
02722 {
02723 percentDone = index * 100/nElements;
02724
02725 if (first)
02726 {
02727 fprintf(stdout, "%03d%% done", percentDone);
02728 first = 0;
02729 }
02730 else if (percentDone == update)
02731 {
02732 update++;
02733 fprintf(stdout,
02734 "\b\b\b\b\b\b\b\b\b%03d%% done",
02735 percentDone);
02736 fflush(stdout);
02737 }
02738
02739 lop = &(pInData[index]);
02740 *result = log10(*lop);
02741 }
02742 }
02743
02744 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02745 fflush(stdout);
02746 }
02747
02748 return error;
02749 }
02750
02751 static int LogShort(const short *pInData, arraylen_t nElements, short *pOutData)
02752 {
02753 int error = 0;
02754
02755 int first = 1;
02756 int percentDone = 0;
02757 int update = 0;
02758
02759 const short *lop = NULL;
02760
02761 if (!pInData)
02762 {
02763 error = 1;
02764 fprintf(stderr, "Missing input data.\n");
02765 }
02766 else
02767 {
02768 short *result = NULL;
02769 arraylen_t index = 0;
02770
02771 for (; index < nElements; index++)
02772 {
02773 result = &(pOutData[index]);
02774 *result = DRMS_MISSING_SHORT;
02775
02776 if (!drms_ismissing_short(pInData[index]))
02777 {
02778 percentDone = index * 100/nElements;
02779
02780 if (first)
02781 {
02782 fprintf(stdout, "%03d%% done", percentDone);
02783 first = 0;
02784 }
02785 else if (percentDone == update)
02786 {
02787 update++;
02788 fprintf(stdout,
02789 "\b\b\b\b\b\b\b\b\b%03d%% done",
02790 percentDone);
02791 fflush(stdout);
02792 }
02793
02794 lop = &(pInData[index]);
02795 *result = log10(*lop);
02796 }
02797 }
02798
02799 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02800 fflush(stdout);
02801 }
02802
02803 return error;
02804 }
02805
02806 static int LogInt(const int *pInData, arraylen_t nElements, int *pOutData)
02807 {
02808 int error = 0;
02809
02810 int first = 1;
02811 int percentDone = 0;
02812 int update = 0;
02813
02814 const int *lop = NULL;
02815
02816 if (!pInData)
02817 {
02818 error = 1;
02819 fprintf(stderr, "Missing input data.\n");
02820 }
02821 else
02822 {
02823 int *result = NULL;
02824 arraylen_t index = 0;
02825
02826 for (; index < nElements; index++)
02827 {
02828 result = &(pOutData[index]);
02829 *result = DRMS_MISSING_INT;
02830
02831 if (!drms_ismissing_int(pInData[index]))
02832 {
02833 percentDone = index * 100/nElements;
02834
02835 if (first)
02836 {
02837 fprintf(stdout, "%03d%% done", percentDone);
02838 first = 0;
02839 }
02840 else if (percentDone == update)
02841 {
02842 update++;
02843 fprintf(stdout,
02844 "\b\b\b\b\b\b\b\b\b%03d%% done",
02845 percentDone);
02846 fflush(stdout);
02847 }
02848
02849 lop = &(pInData[index]);
02850 *result = log10(*lop);
02851 }
02852 }
02853
02854 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02855 fflush(stdout);
02856 }
02857
02858 return error;
02859 }
02860
02861 static int LogLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
02862 {
02863 int error = 0;
02864
02865 int first = 1;
02866 int percentDone = 0;
02867 int update = 0;
02868
02869 const long long *lop = NULL;
02870
02871 if (!pInData)
02872 {
02873 error = 1;
02874 fprintf(stderr, "Missing input data.\n");
02875 }
02876 else
02877 {
02878 long long *result = NULL;
02879 arraylen_t index = 0;
02880
02881 for (; index < nElements; index++)
02882 {
02883 result = &(pOutData[index]);
02884 *result = DRMS_MISSING_LONGLONG;
02885
02886 if (!drms_ismissing_longlong(pInData[index]))
02887 {
02888 percentDone = index * 100/nElements;
02889
02890 if (first)
02891 {
02892 fprintf(stdout, "%03d%% done", percentDone);
02893 first = 0;
02894 }
02895 else if (percentDone == update)
02896 {
02897 update++;
02898 fprintf(stdout,
02899 "\b\b\b\b\b\b\b\b\b%03d%% done",
02900 percentDone);
02901 fflush(stdout);
02902 }
02903
02904 lop = &(pInData[index]);
02905 *result = log10(*lop);
02906 }
02907 }
02908
02909 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02910 fflush(stdout);
02911 }
02912
02913 return error;
02914 }
02915
02916 static int LogFloat(const float *pInData, arraylen_t nElements, float *pOutData)
02917 {
02918 int error = 0;
02919
02920 int first = 1;
02921 int percentDone = 0;
02922 int update = 0;
02923
02924 const float *lop = NULL;
02925
02926 if (!pInData)
02927 {
02928 error = 1;
02929 fprintf(stderr, "Missing input data.\n");
02930 }
02931 else
02932 {
02933 float *result = NULL;
02934 arraylen_t index = 0;
02935
02936 for (; index < nElements; index++)
02937 {
02938 result = &(pOutData[index]);
02939 *result = DRMS_MISSING_FLOAT;
02940
02941 if (!drms_ismissing_float(pInData[index]))
02942 {
02943 percentDone = index * 100/nElements;
02944
02945 if (first)
02946 {
02947 fprintf(stdout, "%03d%% done", percentDone);
02948 first = 0;
02949 }
02950 else if (percentDone == update)
02951 {
02952 update++;
02953 fprintf(stdout,
02954 "\b\b\b\b\b\b\b\b\b%03d%% done",
02955 percentDone);
02956 fflush(stdout);
02957 }
02958
02959 lop = &(pInData[index]);
02960 *result = log10f(*lop);
02961 }
02962 }
02963
02964 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
02965 fflush(stdout);
02966 }
02967
02968 return error;
02969 }
02970
02971 static int LogDouble(const double *pInData, arraylen_t nElements, double *pOutData)
02972 {
02973 int error = 0;
02974
02975 int first = 1;
02976 int percentDone = 0;
02977 int update = 0;
02978
02979 const double *lop = NULL;
02980
02981 if (!pInData)
02982 {
02983 error = 1;
02984 fprintf(stderr, "Missing input data.\n");
02985 }
02986 else
02987 {
02988 double *result = NULL;
02989 arraylen_t index = 0;
02990
02991 for (; index < nElements; index++)
02992 {
02993 result = &(pOutData[index]);
02994 *result = DRMS_MISSING_DOUBLE;
02995
02996 if (!drms_ismissing_double(pInData[index]))
02997 {
02998 percentDone = index * 100/nElements;
02999
03000 if (first)
03001 {
03002 fprintf(stdout, "%03d%% done", percentDone);
03003 first = 0;
03004 }
03005 else if (percentDone == update)
03006 {
03007 update++;
03008 fprintf(stdout,
03009 "\b\b\b\b\b\b\b\b\b%03d%% done",
03010 percentDone);
03011 fflush(stdout);
03012 }
03013
03014 lop = &(pInData[index]);
03015 *result = log10(*lop);
03016 }
03017 }
03018
03019 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03020 fflush(stdout);
03021 }
03022
03023 return error;
03024 }
03025
03026 static int PowChar(const char *pInData, arraylen_t nElements, char *pOutData)
03027 {
03028 int error = 0;
03029
03030 int first = 1;
03031 int percentDone = 0;
03032 int update = 0;
03033
03034 const char *lop = NULL;
03035
03036 if (!pInData)
03037 {
03038 error = 1;
03039 fprintf(stderr, "Missing input data.\n");
03040 }
03041 else
03042 {
03043 char *result = NULL;
03044 arraylen_t index = 0;
03045
03046 for (; index < nElements; index++)
03047 {
03048 result = &(pOutData[index]);
03049 *result = DRMS_MISSING_CHAR;
03050
03051 if (!drms_ismissing_char(pInData[index]))
03052 {
03053 percentDone = index * 100/nElements;
03054
03055 if (first)
03056 {
03057 fprintf(stdout, "%03d%% done", percentDone);
03058 first = 0;
03059 }
03060 else if (percentDone == update)
03061 {
03062 update++;
03063 fprintf(stdout,
03064 "\b\b\b\b\b\b\b\b\b%03d%% done",
03065 percentDone);
03066 fflush(stdout);
03067 }
03068
03069 lop = &(pInData[index]);
03070 *result = pow(10.0, *lop);
03071 }
03072 }
03073
03074 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03075 fflush(stdout);
03076 }
03077
03078 return error;
03079 }
03080
03081 static int PowShort(const short *pInData, arraylen_t nElements, short *pOutData)
03082 {
03083 int error = 0;
03084
03085 int first = 1;
03086 int percentDone = 0;
03087 int update = 0;
03088
03089 const short *lop = NULL;
03090
03091 if (!pInData)
03092 {
03093 error = 1;
03094 fprintf(stderr, "Missing input data.\n");
03095 }
03096 else
03097 {
03098 short *result = NULL;
03099 arraylen_t index = 0;
03100
03101 for (; index < nElements; index++)
03102 {
03103 result = &(pOutData[index]);
03104 *result = DRMS_MISSING_SHORT;
03105
03106 if (!drms_ismissing_short(pInData[index]))
03107 {
03108 percentDone = index * 100/nElements;
03109
03110 if (first)
03111 {
03112 fprintf(stdout, "%03d%% done", percentDone);
03113 first = 0;
03114 }
03115 else if (percentDone == update)
03116 {
03117 update++;
03118 fprintf(stdout,
03119 "\b\b\b\b\b\b\b\b\b%03d%% done",
03120 percentDone);
03121 fflush(stdout);
03122 }
03123
03124 lop = &(pInData[index]);
03125 *result = pow(10.0, *lop);
03126 }
03127 }
03128
03129 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03130 fflush(stdout);
03131 }
03132
03133 return error;
03134 }
03135
03136 static int PowInt(const int *pInData, arraylen_t nElements, int *pOutData)
03137 {
03138 int error = 0;
03139
03140 int first = 1;
03141 int percentDone = 0;
03142 int update = 0;
03143
03144 const int *lop = NULL;
03145
03146 if (!pInData)
03147 {
03148 error = 1;
03149 fprintf(stderr, "Missing input data.\n");
03150 }
03151 else
03152 {
03153 int *result = NULL;
03154 arraylen_t index = 0;
03155
03156 for (; index < nElements; index++)
03157 {
03158 result = &(pOutData[index]);
03159 *result = DRMS_MISSING_INT;
03160
03161 if (!drms_ismissing_int(pInData[index]))
03162 {
03163 percentDone = index * 100/nElements;
03164
03165 if (first)
03166 {
03167 fprintf(stdout, "%03d%% done", percentDone);
03168 first = 0;
03169 }
03170 else if (percentDone == update)
03171 {
03172 update++;
03173 fprintf(stdout,
03174 "\b\b\b\b\b\b\b\b\b%03d%% done",
03175 percentDone);
03176 fflush(stdout);
03177 }
03178
03179 lop = &(pInData[index]);
03180 *result = pow(10.0, *lop);
03181 }
03182 }
03183
03184 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03185 fflush(stdout);
03186 }
03187
03188 return error;
03189 }
03190
03191 static int PowLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
03192 {
03193 int error = 0;
03194
03195 int first = 1;
03196 int percentDone = 0;
03197 int update = 0;
03198
03199 const long long *lop = NULL;
03200
03201 if (!pInData)
03202 {
03203 error = 1;
03204 fprintf(stderr, "Missing input data.\n");
03205 }
03206 else
03207 {
03208 long long *result = NULL;
03209 arraylen_t index = 0;
03210
03211 for (; index < nElements; index++)
03212 {
03213 result = &(pOutData[index]);
03214 *result = DRMS_MISSING_LONGLONG;
03215
03216 if (!drms_ismissing_longlong(pInData[index]))
03217 {
03218 percentDone = index * 100/nElements;
03219
03220 if (first)
03221 {
03222 fprintf(stdout, "%03d%% done", percentDone);
03223 first = 0;
03224 }
03225 else if (percentDone == update)
03226 {
03227 update++;
03228 fprintf(stdout,
03229 "\b\b\b\b\b\b\b\b\b%03d%% done",
03230 percentDone);
03231 fflush(stdout);
03232 }
03233
03234 lop = &(pInData[index]);
03235 *result = pow(10.0, *lop);
03236 }
03237 }
03238
03239 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03240 fflush(stdout);
03241 }
03242
03243 return error;
03244 }
03245
03246 static int PowFloat(const float *pInData, arraylen_t nElements, float *pOutData)
03247 {
03248 int error = 0;
03249
03250 int first = 1;
03251 int percentDone = 0;
03252 int update = 0;
03253
03254 const float *lop = NULL;
03255
03256 if (!pInData)
03257 {
03258 error = 1;
03259 fprintf(stderr, "Missing input data.\n");
03260 }
03261 else
03262 {
03263 float *result = NULL;
03264 arraylen_t index = 0;
03265
03266 for (; index < nElements; index++)
03267 {
03268 result = &(pOutData[index]);
03269 *result = DRMS_MISSING_FLOAT;
03270
03271 if (!drms_ismissing_float(pInData[index]))
03272 {
03273 percentDone = index * 100/nElements;
03274
03275 if (first)
03276 {
03277 fprintf(stdout, "%03d%% done", percentDone);
03278 first = 0;
03279 }
03280 else if (percentDone == update)
03281 {
03282 update++;
03283 fprintf(stdout,
03284 "\b\b\b\b\b\b\b\b\b%03d%% done",
03285 percentDone);
03286 fflush(stdout);
03287 }
03288
03289 lop = &(pInData[index]);
03290 *result = powf(10.0, *lop);
03291 }
03292 }
03293
03294 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03295 fflush(stdout);
03296 }
03297
03298 return error;
03299 }
03300
03301 static int PowDouble(const double *pInData, arraylen_t nElements, double *pOutData)
03302 {
03303 int error = 0;
03304
03305 int first = 1;
03306 int percentDone = 0;
03307 int update = 0;
03308
03309 const double *lop = NULL;
03310
03311 if (!pInData)
03312 {
03313 error = 1;
03314 fprintf(stderr, "Missing input data.\n");
03315 }
03316 else
03317 {
03318 double *result = NULL;
03319 arraylen_t index = 0;
03320
03321 for (; index < nElements; index++)
03322 {
03323 result = &(pOutData[index]);
03324 *result = DRMS_MISSING_DOUBLE;
03325
03326 if (!drms_ismissing_double(pInData[index]))
03327 {
03328 percentDone = index * 100/nElements;
03329
03330 if (first)
03331 {
03332 fprintf(stdout, "%03d%% done", percentDone);
03333 first = 0;
03334 }
03335 else if (percentDone == update)
03336 {
03337 update++;
03338 fprintf(stdout,
03339 "\b\b\b\b\b\b\b\b\b%03d%% done",
03340 percentDone);
03341 fflush(stdout);
03342 }
03343
03344 lop = &(pInData[index]);
03345 *result = pow(10.0, *lop);
03346 }
03347 }
03348
03349 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03350 fflush(stdout);
03351 }
03352
03353 return error;
03354 }
03355
03356 static int SqrChar(const char *pInData, arraylen_t nElements, char *pOutData)
03357 {
03358 int error = 0;
03359
03360 int first = 1;
03361 int percentDone = 0;
03362 int update = 0;
03363
03364 const char *lop = NULL;
03365
03366 if (!pInData)
03367 {
03368 error = 1;
03369 fprintf(stderr, "Missing input data.\n");
03370 }
03371 else
03372 {
03373 char *result = NULL;
03374 arraylen_t index = 0;
03375
03376 for (; index < nElements; index++)
03377 {
03378 result = &(pOutData[index]);
03379 *result = DRMS_MISSING_CHAR;
03380
03381 if (!drms_ismissing_char(pInData[index]))
03382 {
03383 percentDone = index * 100/nElements;
03384
03385 if (first)
03386 {
03387 fprintf(stdout, "%03d%% done", percentDone);
03388 first = 0;
03389 }
03390 else if (percentDone == update)
03391 {
03392 update++;
03393 fprintf(stdout,
03394 "\b\b\b\b\b\b\b\b\b%03d%% done",
03395 percentDone);
03396 fflush(stdout);
03397 }
03398
03399 lop = &(pInData[index]);
03400 *result = *lop * *lop;
03401 }
03402 }
03403
03404 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03405 fflush(stdout);
03406 }
03407
03408 return error;
03409 }
03410
03411 static int SqrShort(const short *pInData, arraylen_t nElements, short *pOutData)
03412 {
03413 int error = 0;
03414
03415 int first = 1;
03416 int percentDone = 0;
03417 int update = 0;
03418
03419 const short *lop = NULL;
03420
03421 if (!pInData)
03422 {
03423 error = 1;
03424 fprintf(stderr, "Missing input data.\n");
03425 }
03426 else
03427 {
03428 short *result = NULL;
03429 arraylen_t index = 0;
03430
03431 for (; index < nElements; index++)
03432 {
03433 result = &(pOutData[index]);
03434 *result = DRMS_MISSING_SHORT;
03435
03436 if (!drms_ismissing_short(pInData[index]))
03437 {
03438 percentDone = index * 100/nElements;
03439
03440 if (first)
03441 {
03442 fprintf(stdout, "%03d%% done", percentDone);
03443 first = 0;
03444 }
03445 else if (percentDone == update)
03446 {
03447 update++;
03448 fprintf(stdout,
03449 "\b\b\b\b\b\b\b\b\b%03d%% done",
03450 percentDone);
03451 fflush(stdout);
03452 }
03453
03454 lop = &(pInData[index]);
03455 *result = *lop * *lop;
03456 }
03457 }
03458
03459 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03460 fflush(stdout);
03461 }
03462
03463 return error;
03464 }
03465
03466 static int SqrInt(const int *pInData, arraylen_t nElements, int *pOutData)
03467 {
03468 int error = 0;
03469
03470 int first = 1;
03471 int percentDone = 0;
03472 int update = 0;
03473
03474 const int *lop = NULL;
03475
03476 if (!pInData)
03477 {
03478 error = 1;
03479 fprintf(stderr, "Missing input data.\n");
03480 }
03481 else
03482 {
03483 int *result = NULL;
03484 arraylen_t index = 0;
03485
03486 for (; index < nElements; index++)
03487 {
03488 result = &(pOutData[index]);
03489 *result = DRMS_MISSING_INT;
03490
03491 if (!drms_ismissing_int(pInData[index]))
03492 {
03493 percentDone = index * 100/nElements;
03494
03495 if (first)
03496 {
03497 fprintf(stdout, "%03d%% done", percentDone);
03498 first = 0;
03499 }
03500 else if (percentDone == update)
03501 {
03502 update++;
03503 fprintf(stdout,
03504 "\b\b\b\b\b\b\b\b\b%03d%% done",
03505 percentDone);
03506 fflush(stdout);
03507 }
03508
03509 lop = &(pInData[index]);
03510 *result = *lop * *lop;
03511 }
03512 }
03513
03514 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03515 fflush(stdout);
03516 }
03517
03518 return error;
03519 }
03520
03521 static int SqrLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
03522 {
03523 int error = 0;
03524
03525 int first = 1;
03526 int percentDone = 0;
03527 int update = 0;
03528
03529 const long long *lop = NULL;
03530
03531 if (!pInData)
03532 {
03533 error = 1;
03534 fprintf(stderr, "Missing input data.\n");
03535 }
03536 else
03537 {
03538 long long *result = NULL;
03539 arraylen_t index = 0;
03540
03541 for (; index < nElements; index++)
03542 {
03543 result = &(pOutData[index]);
03544 *result = DRMS_MISSING_LONGLONG;
03545
03546 if (!drms_ismissing_longlong(pInData[index]))
03547 {
03548 percentDone = index * 100/nElements;
03549
03550 if (first)
03551 {
03552 fprintf(stdout, "%03d%% done", percentDone);
03553 first = 0;
03554 }
03555 else if (percentDone == update)
03556 {
03557 update++;
03558 fprintf(stdout,
03559 "\b\b\b\b\b\b\b\b\b%03d%% done",
03560 percentDone);
03561 fflush(stdout);
03562 }
03563
03564 lop = &(pInData[index]);
03565 *result = *lop * *lop;
03566 }
03567 }
03568
03569 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03570 fflush(stdout);
03571 }
03572
03573 return error;
03574 }
03575
03576 static int SqrFloat(const float *pInData, arraylen_t nElements, float *pOutData)
03577 {
03578 int error = 0;
03579
03580 int first = 1;
03581 int percentDone = 0;
03582 int update = 0;
03583
03584 const float *lop = NULL;
03585
03586 if (!pInData)
03587 {
03588 error = 1;
03589 fprintf(stderr, "Missing input data.\n");
03590 }
03591 else
03592 {
03593 float *result = NULL;
03594 arraylen_t index = 0;
03595
03596 for (; index < nElements; index++)
03597 {
03598 result = &(pOutData[index]);
03599 *result = DRMS_MISSING_FLOAT;
03600
03601 if (!drms_ismissing_float(pInData[index]))
03602 {
03603 percentDone = index * 100/nElements;
03604
03605 if (first)
03606 {
03607 fprintf(stdout, "%03d%% done", percentDone);
03608 first = 0;
03609 }
03610 else if (percentDone == update)
03611 {
03612 update++;
03613 fprintf(stdout,
03614 "\b\b\b\b\b\b\b\b\b%03d%% done",
03615 percentDone);
03616 fflush(stdout);
03617 }
03618
03619 lop = &(pInData[index]);
03620 *result = *lop * *lop;
03621 }
03622 }
03623
03624 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03625 fflush(stdout);
03626 }
03627
03628 return error;
03629 }
03630
03631 static int SqrDouble(const double *pInData, arraylen_t nElements, double *pOutData)
03632 {
03633 int error = 0;
03634
03635 int first = 1;
03636 int percentDone = 0;
03637 int update = 0;
03638
03639 const double *lop = NULL;
03640
03641 if (!pInData)
03642 {
03643 error = 1;
03644 fprintf(stderr, "Missing input data.\n");
03645 }
03646 else
03647 {
03648 double *result = NULL;
03649 arraylen_t index = 0;
03650
03651 for (; index < nElements; index++)
03652 {
03653 result = &(pOutData[index]);
03654 *result = DRMS_MISSING_DOUBLE;
03655
03656 if (!drms_ismissing_double(pInData[index]))
03657 {
03658 percentDone = index * 100/nElements;
03659
03660 if (first)
03661 {
03662 fprintf(stdout, "%03d%% done", percentDone);
03663 first = 0;
03664 }
03665 else if (percentDone == update)
03666 {
03667 update++;
03668 fprintf(stdout,
03669 "\b\b\b\b\b\b\b\b\b%03d%% done",
03670 percentDone);
03671 fflush(stdout);
03672 }
03673
03674 lop = &(pInData[index]);
03675 *result = *lop * *lop;
03676 }
03677 }
03678
03679 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03680 fflush(stdout);
03681 }
03682
03683 return error;
03684 }
03685
03686 static int RecipChar(const char *pInData, arraylen_t nElements, char *pOutData)
03687 {
03688 int error = 0;
03689
03690 int first = 1;
03691 int percentDone = 0;
03692 int update = 0;
03693
03694 const char *lop = NULL;
03695
03696 if (!pInData)
03697 {
03698 error = 1;
03699 fprintf(stderr, "Missing input data.\n");
03700 }
03701 else
03702 {
03703 char *result = NULL;
03704 arraylen_t index = 0;
03705
03706 for (; index < nElements; index++)
03707 {
03708 result = &(pOutData[index]);
03709 *result = DRMS_MISSING_CHAR;
03710
03711 if (!drms_ismissing_char(pInData[index]))
03712 {
03713 percentDone = index * 100/nElements;
03714
03715 if (first)
03716 {
03717 fprintf(stdout, "%03d%% done", percentDone);
03718 first = 0;
03719 }
03720 else if (percentDone == update)
03721 {
03722 update++;
03723 fprintf(stdout,
03724 "\b\b\b\b\b\b\b\b\b%03d%% done",
03725 percentDone);
03726 fflush(stdout);
03727 }
03728
03729 lop = &(pInData[index]);
03730 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_CHAR);
03731 }
03732 }
03733
03734 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03735 fflush(stdout);
03736 }
03737
03738 return error;
03739 }
03740
03741 static int RecipShort(const short *pInData, arraylen_t nElements, short *pOutData)
03742 {
03743 int error = 0;
03744
03745 int first = 1;
03746 int percentDone = 0;
03747 int update = 0;
03748
03749 const short *lop = NULL;
03750
03751 if (!pInData)
03752 {
03753 error = 1;
03754 fprintf(stderr, "Missing input data.\n");
03755 }
03756 else
03757 {
03758 short *result = NULL;
03759 arraylen_t index = 0;
03760
03761 for (; index < nElements; index++)
03762 {
03763 result = &(pOutData[index]);
03764 *result = DRMS_MISSING_SHORT;
03765
03766 if (!drms_ismissing_short(pInData[index]))
03767 {
03768 percentDone = index * 100/nElements;
03769
03770 if (first)
03771 {
03772 fprintf(stdout, "%03d%% done", percentDone);
03773 first = 0;
03774 }
03775 else if (percentDone == update)
03776 {
03777 update++;
03778 fprintf(stdout,
03779 "\b\b\b\b\b\b\b\b\b%03d%% done",
03780 percentDone);
03781 fflush(stdout);
03782 }
03783
03784 lop = &(pInData[index]);
03785 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_SHORT);
03786 }
03787 }
03788
03789 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03790 fflush(stdout);
03791 }
03792
03793 return error;
03794 }
03795
03796 static int RecipInt(const int *pInData, arraylen_t nElements, int *pOutData)
03797 {
03798 int error = 0;
03799
03800 int first = 1;
03801 int percentDone = 0;
03802 int update = 0;
03803
03804 const int *lop = NULL;
03805
03806 if (!pInData)
03807 {
03808 error = 1;
03809 fprintf(stderr, "Missing input data.\n");
03810 }
03811 else
03812 {
03813 int *result = NULL;
03814 arraylen_t index = 0;
03815
03816 for (; index < nElements; index++)
03817 {
03818 result = &(pOutData[index]);
03819 *result = DRMS_MISSING_INT;
03820
03821 if (!drms_ismissing_int(pInData[index]))
03822 {
03823 percentDone = index * 100/nElements;
03824
03825 if (first)
03826 {
03827 fprintf(stdout, "%03d%% done", percentDone);
03828 first = 0;
03829 }
03830 else if (percentDone == update)
03831 {
03832 update++;
03833 fprintf(stdout,
03834 "\b\b\b\b\b\b\b\b\b%03d%% done",
03835 percentDone);
03836 fflush(stdout);
03837 }
03838
03839 lop = &(pInData[index]);
03840 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_INT);
03841 }
03842 }
03843
03844 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03845 fflush(stdout);
03846 }
03847
03848 return error;
03849 }
03850
03851 static int RecipLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
03852 {
03853 int error = 0;
03854
03855 int first = 1;
03856 int percentDone = 0;
03857 int update = 0;
03858
03859 const long long *lop = NULL;
03860
03861 if (!pInData)
03862 {
03863 error = 1;
03864 fprintf(stderr, "Missing input data.\n");
03865 }
03866 else
03867 {
03868 long long *result = NULL;
03869 arraylen_t index = 0;
03870
03871 for (; index < nElements; index++)
03872 {
03873 result = &(pOutData[index]);
03874 *result = DRMS_MISSING_LONGLONG;
03875
03876 if (!drms_ismissing_longlong(pInData[index]))
03877 {
03878 percentDone = index * 100/nElements;
03879
03880 if (first)
03881 {
03882 fprintf(stdout, "%03d%% done", percentDone);
03883 first = 0;
03884 }
03885 else if (percentDone == update)
03886 {
03887 update++;
03888 fprintf(stdout,
03889 "\b\b\b\b\b\b\b\b\b%03d%% done",
03890 percentDone);
03891 fflush(stdout);
03892 }
03893
03894 lop = &(pInData[index]);
03895 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_LONGLONG);
03896 }
03897 }
03898
03899 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03900 fflush(stdout);
03901 }
03902
03903 return error;
03904 }
03905
03906 static int RecipFloat(const float *pInData, arraylen_t nElements, float *pOutData)
03907 {
03908 int error = 0;
03909
03910 int first = 1;
03911 int percentDone = 0;
03912 int update = 0;
03913
03914 const float *lop = NULL;
03915
03916 if (!pInData)
03917 {
03918 error = 1;
03919 fprintf(stderr, "Missing input data.\n");
03920 }
03921 else
03922 {
03923 float *result = NULL;
03924 arraylen_t index = 0;
03925
03926 for (; index < nElements; index++)
03927 {
03928 result = &(pOutData[index]);
03929 *result = DRMS_MISSING_FLOAT;
03930
03931 if (!drms_ismissing_float(pInData[index]))
03932 {
03933 percentDone = index * 100/nElements;
03934
03935 if (first)
03936 {
03937 fprintf(stdout, "%03d%% done", percentDone);
03938 first = 0;
03939 }
03940 else if (percentDone == update)
03941 {
03942 update++;
03943 fprintf(stdout,
03944 "\b\b\b\b\b\b\b\b\b%03d%% done",
03945 percentDone);
03946 fflush(stdout);
03947 }
03948
03949 lop = &(pInData[index]);
03950 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_FLOAT);
03951 }
03952 }
03953
03954 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
03955 fflush(stdout);
03956 }
03957
03958 return error;
03959 }
03960
03961 static int RecipDouble(const double *pInData, arraylen_t nElements, double *pOutData)
03962 {
03963 int error = 0;
03964
03965 int first = 1;
03966 int percentDone = 0;
03967 int update = 0;
03968
03969 const double *lop = NULL;
03970
03971 if (!pInData)
03972 {
03973 error = 1;
03974 fprintf(stderr, "Missing input data.\n");
03975 }
03976 else
03977 {
03978 double *result = NULL;
03979 arraylen_t index = 0;
03980
03981 for (; index < nElements; index++)
03982 {
03983 result = &(pOutData[index]);
03984 *result = DRMS_MISSING_DOUBLE;
03985
03986 if (!drms_ismissing_double(pInData[index]))
03987 {
03988 percentDone = index * 100/nElements;
03989
03990 if (first)
03991 {
03992 fprintf(stdout, "%03d%% done", percentDone);
03993 first = 0;
03994 }
03995 else if (percentDone == update)
03996 {
03997 update++;
03998 fprintf(stdout,
03999 "\b\b\b\b\b\b\b\b\b%03d%% done",
04000 percentDone);
04001 fflush(stdout);
04002 }
04003
04004 lop = &(pInData[index]);
04005 *result = ((*lop != 0.0) ? 1.0 / *lop : DRMS_MISSING_DOUBLE);
04006 }
04007 }
04008
04009 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04010 fflush(stdout);
04011 }
04012
04013 return error;
04014 }
04015
04016 static int SubmeanChar(const char *pInData, arraylen_t nElements, char *pOutData, double mean)
04017 {
04018 int error = 0;
04019
04020 int first = 1;
04021 int percentDone = 0;
04022 int update = 0;
04023
04024 const char *lop = NULL;
04025
04026 if (!pInData)
04027 {
04028 error = 1;
04029 fprintf(stderr, "Missing input data.\n");
04030 }
04031 else
04032 {
04033 char *result = NULL;
04034 arraylen_t index = 0;
04035
04036 for (; index < nElements; index++)
04037 {
04038 result = &(pOutData[index]);
04039 *result = DRMS_MISSING_CHAR;
04040
04041 if (!drms_ismissing_char(pInData[index]))
04042 {
04043 percentDone = index * 100/nElements;
04044
04045 if (first)
04046 {
04047 fprintf(stdout, "%03d%% done", percentDone);
04048 first = 0;
04049 }
04050 else if (percentDone == update)
04051 {
04052 update++;
04053 fprintf(stdout,
04054 "\b\b\b\b\b\b\b\b\b%03d%% done",
04055 percentDone);
04056 fflush(stdout);
04057 }
04058
04059 lop = &(pInData[index]);
04060 *result = *lop - mean;
04061 }
04062 }
04063
04064 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04065 fflush(stdout);
04066 }
04067
04068 return error;
04069 }
04070
04071 static int SubmeanShort(const short *pInData, arraylen_t nElements, short *pOutData, double mean)
04072 {
04073 int error = 0;
04074
04075 int first = 1;
04076 int percentDone = 0;
04077 int update = 0;
04078
04079 const short *lop = NULL;
04080
04081 if (!pInData)
04082 {
04083 error = 1;
04084 fprintf(stderr, "Missing input data.\n");
04085 }
04086 else
04087 {
04088 short *result = NULL;
04089 arraylen_t index = 0;
04090
04091 for (; index < nElements; index++)
04092 {
04093 result = &(pOutData[index]);
04094 *result = DRMS_MISSING_SHORT;
04095
04096 if (!drms_ismissing_short(pInData[index]))
04097 {
04098 percentDone = index * 100/nElements;
04099
04100 if (first)
04101 {
04102 fprintf(stdout, "%03d%% done", percentDone);
04103 first = 0;
04104 }
04105 else if (percentDone == update)
04106 {
04107 update++;
04108 fprintf(stdout,
04109 "\b\b\b\b\b\b\b\b\b%03d%% done",
04110 percentDone);
04111 fflush(stdout);
04112 }
04113
04114 lop = &(pInData[index]);
04115 *result = *lop - mean;
04116 }
04117 }
04118
04119 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04120 fflush(stdout);
04121 }
04122
04123 return error;
04124 }
04125
04126 static int SubmeanInt(const int *pInData, arraylen_t nElements, int *pOutData, double mean)
04127 {
04128 int error = 0;
04129
04130 int first = 1;
04131 int percentDone = 0;
04132 int update = 0;
04133
04134 const int *lop = NULL;
04135
04136 if (!pInData)
04137 {
04138 error = 1;
04139 fprintf(stderr, "Missing input data.\n");
04140 }
04141 else
04142 {
04143 int *result = NULL;
04144 arraylen_t index = 0;
04145
04146 for (; index < nElements; index++)
04147 {
04148 result = &(pOutData[index]);
04149 *result = DRMS_MISSING_INT;
04150
04151 if (!drms_ismissing_int(pInData[index]))
04152 {
04153 percentDone = index * 100/nElements;
04154
04155 if (first)
04156 {
04157 fprintf(stdout, "%03d%% done", percentDone);
04158 first = 0;
04159 }
04160 else if (percentDone == update)
04161 {
04162 update++;
04163 fprintf(stdout,
04164 "\b\b\b\b\b\b\b\b\b%03d%% done",
04165 percentDone);
04166 fflush(stdout);
04167 }
04168
04169 lop = &(pInData[index]);
04170 *result = *lop - mean;
04171 }
04172 }
04173
04174 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04175 fflush(stdout);
04176 }
04177
04178 return error;
04179 }
04180
04181 static int SubmeanLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData, double mean)
04182 {
04183 int error = 0;
04184
04185 int first = 1;
04186 int percentDone = 0;
04187 int update = 0;
04188
04189 const long long *lop = NULL;
04190
04191 if (!pInData)
04192 {
04193 error = 1;
04194 fprintf(stderr, "Missing input data.\n");
04195 }
04196 else
04197 {
04198 long long *result = NULL;
04199 arraylen_t index = 0;
04200
04201 for (; index < nElements; index++)
04202 {
04203 result = &(pOutData[index]);
04204 *result = DRMS_MISSING_LONGLONG;
04205
04206 if (!drms_ismissing_longlong(pInData[index]))
04207 {
04208 percentDone = index * 100/nElements;
04209
04210 if (first)
04211 {
04212 fprintf(stdout, "%03d%% done", percentDone);
04213 first = 0;
04214 }
04215 else if (percentDone == update)
04216 {
04217 update++;
04218 fprintf(stdout,
04219 "\b\b\b\b\b\b\b\b\b%03d%% done",
04220 percentDone);
04221 fflush(stdout);
04222 }
04223
04224 lop = &(pInData[index]);
04225 *result = *lop - mean;
04226 }
04227 }
04228
04229 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04230 fflush(stdout);
04231 }
04232
04233 return error;
04234 }
04235
04236 static int SubmeanFloat(const float *pInData, arraylen_t nElements, float *pOutData, double mean)
04237 {
04238 int error = 0;
04239
04240 int first = 1;
04241 int percentDone = 0;
04242 int update = 0;
04243
04244 const float *lop = NULL;
04245
04246 if (!pInData)
04247 {
04248 error = 1;
04249 fprintf(stderr, "Missing input data.\n");
04250 }
04251 else
04252 {
04253 float *result = NULL;
04254 arraylen_t index = 0;
04255
04256 for (; index < nElements; index++)
04257 {
04258 result = &(pOutData[index]);
04259 *result = DRMS_MISSING_FLOAT;
04260
04261 if (!drms_ismissing_float(pInData[index]))
04262 {
04263 percentDone = index * 100/nElements;
04264
04265 if (first)
04266 {
04267 fprintf(stdout, "%03d%% done", percentDone);
04268 first = 0;
04269 }
04270 else if (percentDone == update)
04271 {
04272 update++;
04273 fprintf(stdout,
04274 "\b\b\b\b\b\b\b\b\b%03d%% done",
04275 percentDone);
04276 fflush(stdout);
04277 }
04278
04279 lop = &(pInData[index]);
04280 *result = *lop - mean;
04281 }
04282 }
04283
04284 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04285 fflush(stdout);
04286 }
04287
04288 return error;
04289 }
04290
04291 static int SubmeanDouble(const double *pInData, arraylen_t nElements, double *pOutData, double mean)
04292 {
04293 int error = 0;
04294
04295 int first = 1;
04296 int percentDone = 0;
04297 int update = 0;
04298
04299 const double *lop = NULL;
04300
04301 if (!pInData)
04302 {
04303 error = 1;
04304 fprintf(stderr, "Missing input data.\n");
04305 }
04306 else
04307 {
04308 double *result = NULL;
04309 arraylen_t index = 0;
04310
04311 for (; index < nElements; index++)
04312 {
04313 result = &(pOutData[index]);
04314 *result = DRMS_MISSING_DOUBLE;
04315
04316 if (!drms_ismissing_double(pInData[index]))
04317 {
04318 percentDone = index * 100/nElements;
04319
04320 if (first)
04321 {
04322 fprintf(stdout, "%03d%% done", percentDone);
04323 first = 0;
04324 }
04325 else if (percentDone == update)
04326 {
04327 update++;
04328 fprintf(stdout,
04329 "\b\b\b\b\b\b\b\b\b%03d%% done",
04330 percentDone);
04331 fflush(stdout);
04332 }
04333
04334 lop = &(pInData[index]);
04335 *result = *lop - mean;
04336 }
04337 }
04338
04339 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04340 fflush(stdout);
04341 }
04342
04343 return error;
04344 }
04345
04346 static int NopChar(const char *pInData, arraylen_t nElements, char *pOutData)
04347 {
04348 int error = 0;
04349
04350 int first = 1;
04351 int percentDone = 0;
04352 int update = 0;
04353
04354 const char *lop = NULL;
04355
04356 if (!pInData)
04357 {
04358 error = 1;
04359 fprintf(stderr, "Missing input data.\n");
04360 }
04361 else
04362 {
04363 char *result = NULL;
04364 arraylen_t index = 0;
04365
04366 for (; index < nElements; index++)
04367 {
04368 result = &(pOutData[index]);
04369 *result = DRMS_MISSING_CHAR;
04370
04371 if (!drms_ismissing_char(pInData[index]))
04372 {
04373 percentDone = index * 100/nElements;
04374
04375 if (first)
04376 {
04377 fprintf(stdout, "%03d%% done", percentDone);
04378 first = 0;
04379 }
04380 else if (percentDone == update)
04381 {
04382 update++;
04383 fprintf(stdout,
04384 "\b\b\b\b\b\b\b\b\b%03d%% done",
04385 percentDone);
04386 fflush(stdout);
04387 }
04388
04389 lop = &(pInData[index]);
04390 *result = *lop;
04391 }
04392 }
04393
04394 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04395 fflush(stdout);
04396 }
04397
04398 return error;
04399 }
04400
04401 static int NopShort(const short *pInData, arraylen_t nElements, short *pOutData)
04402 {
04403 int error = 0;
04404
04405 int first = 1;
04406 int percentDone = 0;
04407 int update = 0;
04408
04409 const short *lop = NULL;
04410
04411 if (!pInData)
04412 {
04413 error = 1;
04414 fprintf(stderr, "Missing input data.\n");
04415 }
04416 else
04417 {
04418 short *result = NULL;
04419 arraylen_t index = 0;
04420
04421 for (; index < nElements; index++)
04422 {
04423 result = &(pOutData[index]);
04424 *result = DRMS_MISSING_SHORT;
04425
04426 if (!drms_ismissing_short(pInData[index]))
04427 {
04428 percentDone = index * 100/nElements;
04429
04430 if (first)
04431 {
04432 fprintf(stdout, "%03d%% done", percentDone);
04433 first = 0;
04434 }
04435 else if (percentDone == update)
04436 {
04437 update++;
04438 fprintf(stdout,
04439 "\b\b\b\b\b\b\b\b\b%03d%% done",
04440 percentDone);
04441 fflush(stdout);
04442 }
04443
04444 lop = &(pInData[index]);
04445 *result = *lop;
04446 }
04447 }
04448
04449 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04450 fflush(stdout);
04451 }
04452
04453 return error;
04454 }
04455
04456 static int NopInt(const int *pInData, arraylen_t nElements, int *pOutData)
04457 {
04458 int error = 0;
04459
04460 int first = 1;
04461 int percentDone = 0;
04462 int update = 0;
04463
04464 const int *lop = NULL;
04465
04466 if (!pInData)
04467 {
04468 error = 1;
04469 fprintf(stderr, "Missing input data.\n");
04470 }
04471 else
04472 {
04473 int *result = NULL;
04474 arraylen_t index = 0;
04475
04476 for (; index < nElements; index++)
04477 {
04478 result = &(pOutData[index]);
04479 *result = DRMS_MISSING_INT;
04480
04481 if (!drms_ismissing_int(pInData[index]))
04482 {
04483 percentDone = index * 100/nElements;
04484
04485 if (first)
04486 {
04487 fprintf(stdout, "%03d%% done", percentDone);
04488 first = 0;
04489 }
04490 else if (percentDone == update)
04491 {
04492 update++;
04493 fprintf(stdout,
04494 "\b\b\b\b\b\b\b\b\b%03d%% done",
04495 percentDone);
04496 fflush(stdout);
04497 }
04498
04499 lop = &(pInData[index]);
04500 *result = *lop;
04501 }
04502 }
04503
04504 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04505 fflush(stdout);
04506 }
04507
04508 return error;
04509 }
04510
04511 static int NopLongLong(const long long *pInData, arraylen_t nElements, long long *pOutData)
04512 {
04513 int error = 0;
04514
04515 int first = 1;
04516 int percentDone = 0;
04517 int update = 0;
04518
04519 const long long *lop = NULL;
04520
04521 if (!pInData)
04522 {
04523 error = 1;
04524 fprintf(stderr, "Missing input data.\n");
04525 }
04526 else
04527 {
04528 long long *result = NULL;
04529 arraylen_t index = 0;
04530
04531 for (; index < nElements; index++)
04532 {
04533 result = &(pOutData[index]);
04534 *result = DRMS_MISSING_LONGLONG;
04535
04536 if (!drms_ismissing_longlong(pInData[index]))
04537 {
04538 percentDone = index * 100/nElements;
04539
04540 if (first)
04541 {
04542 fprintf(stdout, "%03d%% done", percentDone);
04543 first = 0;
04544 }
04545 else if (percentDone == update)
04546 {
04547 update++;
04548 fprintf(stdout,
04549 "\b\b\b\b\b\b\b\b\b%03d%% done",
04550 percentDone);
04551 fflush(stdout);
04552 }
04553
04554 lop = &(pInData[index]);
04555 *result = *lop;
04556 }
04557 }
04558
04559 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04560 fflush(stdout);
04561 }
04562
04563 return error;
04564 }
04565
04566 static int NopFloat(const float *pInData, arraylen_t nElements, float *pOutData)
04567 {
04568 int error = 0;
04569
04570 int first = 1;
04571 int percentDone = 0;
04572 int update = 0;
04573
04574 const float *lop = NULL;
04575
04576 if (!pInData)
04577 {
04578 error = 1;
04579 fprintf(stderr, "Missing input data.\n");
04580 }
04581 else
04582 {
04583 float *result = NULL;
04584 arraylen_t index = 0;
04585
04586 for (; index < nElements; index++)
04587 {
04588 result = &(pOutData[index]);
04589 *result = DRMS_MISSING_FLOAT;
04590
04591 if (!drms_ismissing_float(pInData[index]))
04592 {
04593 percentDone = index * 100/nElements;
04594
04595 if (first)
04596 {
04597 fprintf(stdout, "%03d%% done", percentDone);
04598 first = 0;
04599 }
04600 else if (percentDone == update)
04601 {
04602 update++;
04603 fprintf(stdout,
04604 "\b\b\b\b\b\b\b\b\b%03d%% done",
04605 percentDone);
04606 fflush(stdout);
04607 }
04608
04609 lop = &(pInData[index]);
04610 *result = *lop;
04611 }
04612 }
04613
04614 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04615 fflush(stdout);
04616 }
04617
04618 return error;
04619 }
04620
04621 static int NopDouble(const double *pInData, arraylen_t nElements, double *pOutData)
04622 {
04623 int error = 0;
04624
04625 int first = 1;
04626 int percentDone = 0;
04627 int update = 0;
04628
04629 const double *lop = NULL;
04630
04631 if (!pInData)
04632 {
04633 error = 1;
04634 fprintf(stderr, "Missing input data.\n");
04635 }
04636 else
04637 {
04638 double *result = NULL;
04639 arraylen_t index = 0;
04640
04641 for (; index < nElements; index++)
04642 {
04643 result = &(pOutData[index]);
04644 *result = DRMS_MISSING_DOUBLE;
04645
04646 if (!drms_ismissing_double(pInData[index]))
04647 {
04648 percentDone = index * 100/nElements;
04649
04650 if (first)
04651 {
04652 fprintf(stdout, "%03d%% done", percentDone);
04653 first = 0;
04654 }
04655 else if (percentDone == update)
04656 {
04657 update++;
04658 fprintf(stdout,
04659 "\b\b\b\b\b\b\b\b\b%03d%% done",
04660 percentDone);
04661 fflush(stdout);
04662 }
04663
04664 lop = &(pInData[index]);
04665 *result = *lop;
04666 }
04667 }
04668
04669 fprintf(stdout, "\b\b\b\b\b\b\b\b\b100%% done\n");
04670 fflush(stdout);
04671 }
04672
04673 return error;
04674 }
04675
04676
04677
04678 static int PerformOperation(ArithOp_t op, DRMS_Type_t dtype,
04679 const void *pInData, const void *pWithData,
04680 arraylen_t nElements, void *pOutData, double mean)
04681 {
04682 int error = 0;
04683
04684 if (!pInData)
04685 {
04686 error = 1;
04687 fprintf(stderr, "Missing input data.\n");
04688 }
04689 else if (IsBinaryOp(op) && !pWithData)
04690 {
04691 error = 1;
04692 fprintf(stderr, "Missing input data.\n");
04693 }
04694 else
04695 {
04696 if (IsBinaryOp(op))
04697 {
04698 switch (op)
04699 {
04700 case kArithOpMul:
04701 switch (dtype)
04702 {
04703 case DRMS_TYPE_CHAR:
04704 return MultChar(pInData, pWithData, nElements, pOutData);
04705 case DRMS_TYPE_SHORT:
04706 return MultShort(pInData, pWithData, nElements, pOutData);
04707 case DRMS_TYPE_INT:
04708 return MultInt(pInData, pWithData, nElements, pOutData);
04709 case DRMS_TYPE_LONGLONG:
04710 return MultLongLong(pInData, pWithData, nElements, pOutData);
04711 case DRMS_TYPE_FLOAT:
04712 return MultFloat(pInData, pWithData, nElements, pOutData);
04713 case DRMS_TYPE_DOUBLE:
04714 return MultDouble(pInData, pWithData, nElements, pOutData);
04715 }
04716 break;
04717 case kArithOpDiv:
04718 switch (dtype)
04719 {
04720 case DRMS_TYPE_CHAR:
04721 return DivChar(pInData, pWithData, nElements, pOutData);
04722 case DRMS_TYPE_SHORT:
04723 return DivShort(pInData, pWithData, nElements, pOutData);
04724 case DRMS_TYPE_INT:
04725 return DivInt(pInData, pWithData, nElements, pOutData);
04726 case DRMS_TYPE_LONGLONG:
04727 return DivLongLong(pInData, pWithData, nElements, pOutData);
04728 case DRMS_TYPE_FLOAT:
04729 return DivFloat(pInData, pWithData, nElements, pOutData);
04730 case DRMS_TYPE_DOUBLE:
04731 return DivDouble(pInData, pWithData, nElements, pOutData);
04732 }
04733 break;
04734 case kArithOpAdd:
04735 switch (dtype)
04736 {
04737 case DRMS_TYPE_CHAR:
04738 return AddChar(pInData, pWithData, nElements, pOutData);
04739 case DRMS_TYPE_SHORT:
04740 return AddShort(pInData, pWithData, nElements, pOutData);
04741 case DRMS_TYPE_INT:
04742 return AddInt(pInData, pWithData, nElements, pOutData);
04743 case DRMS_TYPE_LONGLONG:
04744 return AddLongLong(pInData, pWithData, nElements, pOutData);
04745 case DRMS_TYPE_FLOAT:
04746 return AddFloat(pInData, pWithData, nElements, pOutData);
04747 case DRMS_TYPE_DOUBLE:
04748 return AddDouble(pInData, pWithData, nElements, pOutData);
04749 }
04750 break;
04751 case kArithOpSub:
04752 switch (dtype)
04753 {
04754 case DRMS_TYPE_CHAR:
04755 return SubChar(pInData, pWithData, nElements, pOutData);
04756 case DRMS_TYPE_SHORT:
04757 return SubShort(pInData, pWithData, nElements, pOutData);
04758 case DRMS_TYPE_INT:
04759 return SubInt(pInData, pWithData, nElements, pOutData);
04760 case DRMS_TYPE_LONGLONG:
04761 return SubLongLong(pInData, pWithData, nElements, pOutData);
04762 case DRMS_TYPE_FLOAT:
04763 return SubFloat(pInData, pWithData, nElements, pOutData);
04764 case DRMS_TYPE_DOUBLE:
04765 return SubDouble(pInData, pWithData, nElements, pOutData);
04766 }
04767 break;
04768 default:
04769 error = 1;
04770 fprintf(stderr, "Expecting a binary operator, got %d instead.\n", (int)op);
04771 }
04772 }
04773 else
04774 {
04775 switch (op)
04776 {
04777 case kArithOpAbs:
04778 switch (dtype)
04779 {
04780 case DRMS_TYPE_CHAR:
04781 return AbsChar(pInData, nElements, pOutData);
04782 case DRMS_TYPE_SHORT:
04783 return AbsShort(pInData, nElements, pOutData);
04784 case DRMS_TYPE_INT:
04785 return AbsInt(pInData, nElements, pOutData);
04786 case DRMS_TYPE_LONGLONG:
04787 return AbsLongLong(pInData, nElements, pOutData);
04788 case DRMS_TYPE_FLOAT:
04789 return AbsFloat(pInData, nElements, pOutData);
04790 case DRMS_TYPE_DOUBLE:
04791 return AbsDouble(pInData, nElements, pOutData);
04792 }
04793 break;
04794 case kArithOpSqrt:
04795 switch (dtype)
04796 {
04797 case DRMS_TYPE_CHAR:
04798 return SqrtChar(pInData, nElements, pOutData);
04799 case DRMS_TYPE_SHORT:
04800 return SqrtShort(pInData, nElements, pOutData);
04801 case DRMS_TYPE_INT:
04802 return SqrtInt(pInData, nElements, pOutData);
04803 case DRMS_TYPE_LONGLONG:
04804 return SqrtLongLong(pInData, nElements, pOutData);
04805 case DRMS_TYPE_FLOAT:
04806 return SqrtFloat(pInData, nElements, pOutData);
04807 case DRMS_TYPE_DOUBLE:
04808 return SqrtDouble(pInData, nElements, pOutData);
04809 }
04810 break;
04811 case kArithOpLog:
04812 switch (dtype)
04813 {
04814 case DRMS_TYPE_CHAR:
04815 return LogChar(pInData, nElements, pOutData);
04816 case DRMS_TYPE_SHORT:
04817 return LogShort(pInData, nElements, pOutData);
04818 case DRMS_TYPE_INT:
04819 return LogInt(pInData, nElements, pOutData);
04820 case DRMS_TYPE_LONGLONG:
04821 return LogLongLong(pInData, nElements, pOutData);
04822 case DRMS_TYPE_FLOAT:
04823 return LogFloat(pInData, nElements, pOutData);
04824 case DRMS_TYPE_DOUBLE:
04825 return LogDouble(pInData, nElements, pOutData);
04826 }
04827 break;
04828 case kArithOpPow:
04829 switch (dtype)
04830 {
04831 case DRMS_TYPE_CHAR:
04832 return PowChar(pInData, nElements, pOutData);
04833 case DRMS_TYPE_SHORT:
04834 return PowShort(pInData, nElements, pOutData);
04835 case DRMS_TYPE_INT:
04836 return PowInt(pInData, nElements, pOutData);
04837 case DRMS_TYPE_LONGLONG:
04838 return PowLongLong(pInData, nElements, pOutData);
04839 case DRMS_TYPE_FLOAT:
04840 return PowFloat(pInData, nElements, pOutData);
04841 case DRMS_TYPE_DOUBLE:
04842 return PowDouble(pInData, nElements, pOutData);
04843 }
04844 break;
04845 case kArithOpSqr:
04846 switch (dtype)
04847 {
04848 case DRMS_TYPE_CHAR:
04849 return SqrChar(pInData, nElements, pOutData);
04850 case DRMS_TYPE_SHORT:
04851 return SqrShort(pInData, nElements, pOutData);
04852 case DRMS_TYPE_INT:
04853 return SqrInt(pInData, nElements, pOutData);
04854 case DRMS_TYPE_LONGLONG:
04855 return SqrLongLong(pInData, nElements, pOutData);
04856 case DRMS_TYPE_FLOAT:
04857 return SqrFloat(pInData, nElements, pOutData);
04858 case DRMS_TYPE_DOUBLE:
04859 return SqrDouble(pInData, nElements, pOutData);
04860 }
04861 break;
04862 case kArithOpRecip:
04863 switch (dtype)
04864 {
04865 case DRMS_TYPE_CHAR:
04866 return RecipChar(pInData, nElements, pOutData);
04867 case DRMS_TYPE_SHORT:
04868 return RecipShort(pInData, nElements, pOutData);
04869 case DRMS_TYPE_INT:
04870 return RecipInt(pInData, nElements, pOutData);
04871 case DRMS_TYPE_LONGLONG:
04872 return RecipLongLong(pInData, nElements, pOutData);
04873 case DRMS_TYPE_FLOAT:
04874 return RecipFloat(pInData, nElements, pOutData);
04875 case DRMS_TYPE_DOUBLE:
04876 return RecipDouble(pInData, nElements, pOutData);
04877 }
04878 break;
04879 case kArithOpSubmean:
04880 switch (dtype)
04881 {
04882 case DRMS_TYPE_CHAR:
04883 return SubmeanChar(pInData, nElements, pOutData, mean);
04884 case DRMS_TYPE_SHORT:
04885 return SubmeanShort(pInData, nElements, pOutData, mean);
04886 case DRMS_TYPE_INT:
04887 return SubmeanInt(pInData, nElements, pOutData, mean);
04888 case DRMS_TYPE_LONGLONG:
04889 return SubmeanLongLong(pInData, nElements, pOutData, mean);
04890 case DRMS_TYPE_FLOAT:
04891 return SubmeanFloat(pInData, nElements, pOutData, mean);
04892 case DRMS_TYPE_DOUBLE:
04893 return SubmeanDouble(pInData, nElements, pOutData, mean);
04894 }
04895 break;
04896 case kArithOpNop:
04897 switch (dtype)
04898 {
04899 case DRMS_TYPE_CHAR:
04900 return NopChar(pInData, nElements, pOutData);
04901 case DRMS_TYPE_SHORT:
04902 return NopShort(pInData, nElements, pOutData);
04903 case DRMS_TYPE_INT:
04904 return NopInt(pInData, nElements, pOutData);
04905 case DRMS_TYPE_LONGLONG:
04906 return NopLongLong(pInData, nElements, pOutData);
04907 case DRMS_TYPE_FLOAT:
04908 return NopFloat(pInData, nElements, pOutData);
04909 case DRMS_TYPE_DOUBLE:
04910 return NopDouble(pInData, nElements, pOutData);
04911 }
04912 break;
04913 default:
04914 error = 1;
04915 fprintf(stderr, "Expecting a unary operator, got %d instead.\n", (int)op);
04916 }
04917 }
04918 }
04919
04920 return error;
04921 }
04922
04923
04924 int DoBinaryOp(DRMS_Env_t *drmsEnv, ArithOp_t op, DRMS_Type_t dtype,
04925 DRMSContainer_t *inPrimeKeys, DRMSContainer_t *segsToProc,
04926 char *inSeriesQuery,
04927 char *withSeriesName, char *withSeriesQuery,
04928 char *seriesOut, double bzero, double bscale)
04929 {
04930 int error = 0;
04931 int status = 0;
04932 int nWithRecs = 0;
04933 int nInRecs = 0;
04934 double **pOutData = NULL;
04935 char **outSegNames = NULL;
04936
04937
04938 DRMS_RecordSet_t *inRecSet = drms_open_records(drmsEnv, inSeriesQuery, &status);
04939 error = (status != DRMS_SUCCESS);
04940 DRMS_RecordSet_t *withRecSet = NULL;
04941
04942 DRMS_Record_t *inRec = NULL;
04943 DRMS_Record_t *withRec = NULL;
04944
04945 int nSegs = segsToProc->items->num_total;
04946
04947 if (!error)
04948 {
04949 nInRecs = inRecSet->n;
04950 withRecSet = drms_open_records(drmsEnv, withSeriesQuery, &status);
04951 error = (status != DRMS_SUCCESS);
04952 nWithRecs = withRecSet->n;
04953
04954 XASSERT(nWithRecs >= 1);
04955
04956 if (nWithRecs == 0)
04957 {
04958 error = 1;
04959 }
04960 else if (nWithRecs == 1)
04961 {
04962 withRec = withRecSet->records[0];
04963 }
04964 }
04965
04966 int iRec = 0;
04967 for (; !error && iRec < nInRecs; iRec++)
04968 {
04969 inRec = inRecSet->records[iRec];
04970
04971 fprintf(stdout, "Processing record %lld\n", inRec->recnum);
04972
04973 if (nWithRecs != 1)
04974 {
04975
04976
04977
04978
04979
04980
04981
04982
04983 drms_close_records(withRecSet, DRMS_FREE_RECORD);
04984 withRecSet = NULL;
04985
04986
04987
04988
04989 char query[kMaxQuery];
04990 char buf[kMaxQuery];
04991 char *pQuery = query;
04992 int maxQuery = kMaxQuery;
04993
04994 snprintf(buf, sizeof(buf), "%s", withSeriesName);
04995 snprintf(pQuery, maxQuery, "%s", buf);
04996 pQuery += strlen(buf);
04997 maxQuery -= strlen(buf);
04998
04999 hiter_rewind(&(inPrimeKeys->iter));
05000 DRMS_Keyword_t **primeKey = NULL;
05001
05002 while (maxQuery > 0 &&
05003 (primeKey = hiter_getnext(&(inPrimeKeys->iter))) != NULL)
05004 {
05005 char *val = CreateStrFromDRMSValue(inRec, (*primeKey)->info->name, &error);
05006 if (!error)
05007 {
05008 if (val != NULL)
05009 {
05010 snprintf(buf, sizeof(buf), "[%s=%s]",
05011 (*primeKey)->info->name,
05012 val);
05013 snprintf(pQuery, maxQuery, "%s", buf);
05014 pQuery += strlen(buf);
05015 maxQuery -= strlen(buf);
05016
05017 if (maxQuery <= 0)
05018 {
05019 error = 1;
05020 break;
05021 }
05022
05023 free(val);
05024 }
05025 else
05026 {
05027 error = 1;
05028 }
05029 }
05030 }
05031
05032 if (!error)
05033 {
05034 withRecSet = drms_open_records(drmsEnv, query, &status);
05035 error = (status != DRMS_SUCCESS);
05036
05037 if (!error && withRecSet != NULL)
05038 {
05039 if (withRecSet -> n != 1)
05040 {
05041 error = 1;
05042 }
05043 else
05044 {
05045 withRec = withRecSet->records[0];
05046 }
05047 }
05048 else
05049 {
05050 error = 1;
05051 }
05052 }
05053 }
05054
05055 if (!error)
05056 {
05057
05058
05059 hiter_rewind(&(segsToProc->iter));
05060 DRMS_Segment_t **seg = NULL;
05061 DRMS_Segment_t *inSeg = NULL;
05062 DRMS_Segment_t *withSeg = NULL;
05063 DRMS_Array_t *inSegArray = NULL;
05064 DRMS_Array_t *withSegArray = NULL;
05065
05066 pOutData = (double **)malloc(sizeof(double *) * nSegs);
05067 outSegNames = (char **)malloc(sizeof(char *) * nSegs);
05068
05069 unsigned int iSeg = 0;
05070 while(pOutData != NULL &&
05071 outSegNames != NULL &&
05072 !error &&
05073 (seg = (DRMS_Segment_t **)hiter_getnext(&(segsToProc->iter))) != NULL)
05074 {
05075 fprintf(stdout, " processing segment %s: ", (*seg)->info->name);
05076
05077 inSeg = drms_segment_lookup(inRec, (*seg)->info->name);
05078 withSeg = drms_segment_lookup(withRec, (*seg)->info->name);
05079
05080
05081 XASSERT(inSeg != NULL && withSeg != NULL);
05082 if (inSeg != NULL && withSeg != NULL)
05083 {
05084 inSegArray = drms_segment_read(inSeg, DRMS_TYPE_DOUBLE, &status);
05085 error = (status != DRMS_SUCCESS);
05086 if (!error)
05087 {
05088 withSegArray = drms_segment_read(withSeg, DRMS_TYPE_DOUBLE, &status);
05089 error = (status != DRMS_SUCCESS);
05090 }
05091 }
05092
05093 if (!error)
05094 {
05095
05096 arraylen_t nElementsIn = drms_array_count(inSegArray);
05097 arraylen_t nElementsWith = drms_array_count(withSegArray);
05098 double *pInData = inSegArray->data;
05099 double *pWithData = withSegArray->data;
05100
05101 if (nElementsIn == nElementsWith)
05102 {
05103 pOutData[iSeg] = (double *)malloc(sizeof(double) * nElementsIn);
05104 outSegNames[iSeg] = strdup((*seg)->info->name);
05105
05106 if (pOutData[iSeg] != NULL && outSegNames[iSeg] != NULL)
05107 {
05108
05109 PerformOperation(op,
05110 dtype,
05111 pInData,
05112 pWithData,
05113 nElementsIn,
05114 pOutData[iSeg],
05115 0.0);
05116 iSeg++;
05117 }
05118 else
05119 {
05120 error = 1;
05121 }
05122 }
05123 else
05124 {
05125 error = 1;
05126 }
05127 }
05128
05129 if (inSegArray)
05130 {
05131 drms_free_array(inSegArray);
05132 }
05133
05134 if (withSegArray)
05135 {
05136 drms_free_array(withSegArray);
05137 }
05138
05139 }
05140 }
05141
05142 if (!error)
05143 {
05144
05145
05146
05147
05148 DRMS_Record_t *rec = drms_create_record(drmsEnv, seriesOut, DRMS_PERMANENT, &status);
05149 error = (status != DRMS_SUCCESS);
05150 if (rec != NULL && !error)
05151 {
05152
05153 HIterator_t hit;
05154 hiter_new(&hit, &(rec->keywords));
05155 DRMS_Keyword_t *outKey = NULL;
05156 DRMS_Keyword_t *inKey = NULL;
05157
05158 while ((outKey = (DRMS_Keyword_t *)hiter_getnext(&hit)) != NULL)
05159 {
05160 inKey = drms_keyword_lookup(inRec, outKey->info->name, 1);
05161 if (inKey != NULL && !drms_keyword_isindex(inKey))
05162 {
05163 status = drms_setkey(rec,
05164 outKey->info->name,
05165 outKey->info->type,
05166 &(inKey->value));
05167
05168 error = (status != DRMS_SUCCESS);
05169 }
05170 }
05171
05172
05173 unsigned int index = 0;
05174 for (; index < nSegs; index++)
05175 {
05176 if (pOutData != NULL && outSegNames != NULL)
05177 {
05178
05179 DRMS_Segment_t *inSeg = drms_segment_lookup(inRec,
05180 outSegNames[index]);
05181 DRMS_Segment_t *seg = drms_segment_lookup(rec, outSegNames[index]);
05182 if (inSeg != NULL && seg != NULL)
05183 {
05184
05185 DRMS_Array_t *segArray = drms_array_create(DRMS_TYPE_DOUBLE,
05186 inSeg->info->naxis,
05187 inSeg->axis,
05188 pOutData[index],
05189 &status);
05190 error = (status != DRMS_SUCCESS);
05191
05192 if (!error)
05193 {
05194 segArray->bzero = bzero;
05195 segArray->bscale = bscale;
05196 segArray->israw = 0;
05197 drms_segment_write(seg, segArray, 0);
05198 drms_free_array(segArray);
05199 }
05200 }
05201
05202 }
05203 }
05204
05205 if (!error)
05206 {
05207 drms_close_record(rec, DRMS_INSERT_RECORD);
05208 }
05209 else
05210 {
05211 drms_close_record(rec, DRMS_FREE_RECORD);
05212 }
05213 }
05214 else if (rec != NULL)
05215 {
05216 drms_close_record(rec, DRMS_FREE_RECORD);
05217 }
05218 }
05219
05220
05221
05222
05223 unsigned int index = 0;
05224 for (; index < nSegs; index++)
05225 {
05226 if (outSegNames[index] != NULL)
05227 {
05228 char *pName = outSegNames[index];
05229 free(pName);
05230 }
05231 }
05232
05233 if (outSegNames != NULL)
05234 {
05235 free(outSegNames);
05236 }
05237 }
05238
05239 if (inRecSet != NULL)
05240 {
05241 drms_close_records(inRecSet, DRMS_FREE_RECORD);
05242 }
05243
05244 if (withRecSet != NULL)
05245 {
05246 drms_close_records(withRecSet, DRMS_FREE_RECORD);
05247 }
05248
05249 return error;
05250 }
05251
05252 static int DoUnaryOp(DRMS_Env_t *drmsEnv, ArithOp_t op, DRMS_Type_t dtype,
05253 DRMSContainer_t *segsToProc,
05254 char *inSeriesQuery, int *slicelower, int *sliceupper,
05255 char *seriesOut, int *pout, double bzero, double bscale, int nosegs)
05256 {
05257 int error = 0;
05258 int status = 0;
05259 void *pOutData = NULL;
05260 char **outSegNames = NULL;
05261 int nSegs = 0;
05262 DRMS_Type_t actualtype;
05263 double *insegBZERO = NULL;
05264 double *insegBSCALE = NULL;
05265
05266
05267 DRMS_RecordSet_t *inRecSet = drms_open_recordset(drmsEnv, inSeriesQuery, &status);
05268 DRMS_Record_t *inRec = NULL;
05269
05270 DRMS_RecChunking_t cstat = kRecChunking_None;
05271 DRMS_Record_t *targetrec = NULL;
05272
05273 error = (status != DRMS_SUCCESS);
05274
05275 if (!error)
05276 {
05277 if (segsToProc && segsToProc->items)
05278 {
05279 nSegs = segsToProc->items->num_total;
05280 }
05281 else
05282 {
05283 nSegs = 0;
05284 }
05285 }
05286
05287 if (nSegs > 0)
05288 {
05289 insegBZERO = (double *)malloc(sizeof(double) * nSegs);
05290 insegBSCALE = (double *)malloc(sizeof(double) * nSegs);
05291 }
05292
05293 while ((inRec = drms_recordset_fetchnext(drmsEnv, inRecSet, &status, &cstat, NULL)) != NULL)
05294 {
05295 fprintf(stdout, "Processing record %lld\n", inRec->recnum);
05296
05297
05298 if (nosegs)
05299 {
05300 targetrec = drms_create_record(drmsEnv,
05301 seriesOut,
05302 DRMS_PERMANENT,
05303 &status);
05304 error = (status != DRMS_SUCCESS);
05305
05306 if (!error)
05307 {
05308 drms_copykeys(targetrec, inRec, 0, kDRMS_KeyClass_Explicit);
05309
05310
05311 drms_keyword_setdate(targetrec);
05312 drms_close_record(targetrec, DRMS_INSERT_RECORD);
05313 }
05314 else
05315 {
05316 drms_close_record(targetrec, DRMS_FREE_RECORD);
05317 }
05318
05319 continue;
05320 }
05321
05322 hiter_rewind(&(segsToProc->iter));
05323 DRMS_Segment_t **seg = NULL;
05324 DRMS_Segment_t *inSeg = NULL;
05325 DRMS_Array_t *inSegArray = NULL;
05326
05327 actualtype = dtype;
05328
05329 pOutData = malloc(sizeof(void *) * nSegs);
05330 outSegNames = (char **)malloc(sizeof(char *) * nSegs);
05331 memset(outSegNames, 0, sizeof(char *) * nSegs);
05332
05333 unsigned int iSeg = 0;
05334 while(pOutData != NULL &&
05335 outSegNames != NULL &&
05336 !error &&
05337 (seg = (DRMS_Segment_t **)hiter_getnext(&(segsToProc->iter))) != NULL)
05338 {
05339 fprintf(stdout, " processing segment %s: ", (*seg)->info->name);
05340 inSeg = drms_segment_lookup(inRec, (*seg)->info->name);
05341
05342 XASSERT(inSeg != NULL);
05343 if (inSeg != NULL)
05344 {
05345 if (slicelower && sliceupper)
05346 {
05347 inSegArray = drms_segment_readslice(inSeg,
05348 dtype,
05349 slicelower,
05350 sliceupper,
05351 &status);
05352 }
05353 else
05354 {
05355 inSegArray = drms_segment_read(inSeg, dtype, &status);
05356 }
05357
05358 if (dtype == DRMS_TYPE_RAW)
05359 {
05360 actualtype = inSeg->info->type;
05361 }
05362
05363 if (status != DRMS_SUCCESS)
05364 {
05365
05366 fprintf(stderr, "Error reading segment - skipping to the next segment.\n");
05367 continue;
05368 iSeg++;
05369 }
05370
05371
05372 arraylen_t nElementsIn = drms_array_count(inSegArray);
05373 void *pInData = inSegArray->data;
05374 void *pOut = NULL;
05375
05376 insegBZERO[iSeg] = inSegArray->bzero;
05377 insegBSCALE[iSeg] = inSegArray->bscale;
05378
05379 switch (actualtype)
05380 {
05381 case DRMS_TYPE_CHAR:
05382 ((char **)(pOutData))[iSeg] = (char *)malloc(sizeof(char) * nElementsIn);
05383 pOut = (void *)(((char **)(pOutData))[iSeg]);
05384 break;
05385 case DRMS_TYPE_SHORT:
05386 ((short **)(pOutData))[iSeg] = (short *)malloc(sizeof(short) * nElementsIn);
05387 pOut = (void *)(((short **)(pOutData))[iSeg]);
05388 break;
05389 case DRMS_TYPE_INT:
05390 ((int **)(pOutData))[iSeg] = (int *)malloc(sizeof(int) * nElementsIn);
05391 pOut = (void *)(((int **)(pOutData))[iSeg]);
05392 break;
05393 case DRMS_TYPE_LONGLONG:
05394 ((long long **)(pOutData))[iSeg] = (long long *)malloc(sizeof(long long) * nElementsIn);
05395 pOut = (void *)(((long long **)(pOutData))[iSeg]);
05396 break;
05397 case DRMS_TYPE_FLOAT:
05398 ((float **)(pOutData))[iSeg] = (float *)malloc(sizeof(float) * nElementsIn);
05399 pOut = (void *)(((float **)(pOutData))[iSeg]);
05400 break;
05401 case DRMS_TYPE_DOUBLE:
05402 ((double **)(pOutData))[iSeg] = (double *)malloc(sizeof(double) * nElementsIn);
05403 pOut = (void *)(((double **)(pOutData))[iSeg]);
05404 break;
05405 }
05406
05407 outSegNames[iSeg] = strdup((*seg)->info->name);
05408
05409 if (pOut != NULL && outSegNames[iSeg] != NULL)
05410 {
05411 double mean = 0.0;
05412
05413
05414 if (op == kArithOpSubmean)
05415 {
05416 int n = 0;
05417 arraylen_t iData = 0;
05418
05419 switch (actualtype)
05420 {
05421 case DRMS_TYPE_CHAR:
05422 {
05423 char *pData = pInData;
05424 for (; iData < nElementsIn; iData++, pData++)
05425 {
05426 if (!drms_ismissing_char(*pData))
05427 {
05428 mean += (double)*pData;
05429 n += 1;
05430 }
05431 }
05432 }
05433 break;
05434 case DRMS_TYPE_SHORT:
05435 {
05436 short *pData = pInData;
05437 for (; iData < nElementsIn; iData++, pData++)
05438 {
05439 if (!drms_ismissing_short(*pData))
05440 {
05441 mean += (double)*pData;
05442 n += 1;
05443 }
05444 }
05445 }
05446 break;
05447 case DRMS_TYPE_INT:
05448 {
05449 int *pData = pInData;
05450 for (; iData < nElementsIn; iData++, pData++)
05451 {
05452 if (!drms_ismissing_int(*pData))
05453 {
05454 mean += (double)*pData;
05455 n += 1;
05456 }
05457 }
05458 }
05459 break;
05460 case DRMS_TYPE_LONGLONG:
05461 {
05462 long long *pData = pInData;
05463 for (; iData < nElementsIn; iData++, pData++)
05464 {
05465 if (!drms_ismissing_longlong(*pData))
05466 {
05467 mean += (double)*pData;
05468 n += 1;
05469 }
05470 }
05471 }
05472 break;
05473 case DRMS_TYPE_FLOAT:
05474 {
05475 float *pData = pInData;
05476 for (; iData < nElementsIn; iData++, pData++)
05477 {
05478 if (!drms_ismissing_float(*pData))
05479 {
05480 mean += (double)*pData;
05481 n += 1;
05482 }
05483 }
05484 }
05485 break;
05486 case DRMS_TYPE_DOUBLE:
05487 {
05488 double *pData = pInData;
05489 for (; iData < nElementsIn; iData++, pData++)
05490 {
05491 if (!drms_ismissing_double(*pData))
05492 {
05493 mean += (double)*pData;
05494 n += 1;
05495 }
05496 }
05497 }
05498 break;
05499 }
05500
05501 if (n > 0)
05502 {
05503 mean /= n;
05504 }
05505 }
05506
05507 PerformOperation(op,
05508 actualtype,
05509 pInData,
05510 NULL,
05511 nElementsIn,
05512 pOut,
05513 mean);
05514 }
05515 else
05516 {
05517 error = 1;
05518 }
05519
05520
05521 drms_free_array(inSegArray);
05522 }
05523
05524 iSeg++;
05525 }
05526
05527 if (!error)
05528 {
05529 DRMS_Record_t *rec = NULL;
05530
05531
05532 if (drms_series_cancreaterecord(drmsEnv, seriesOut))
05533 {
05534
05535
05536
05537
05538 rec = drms_create_record(drmsEnv,
05539 seriesOut,
05540 DRMS_PERMANENT,
05541 &status);
05542 error = (status != DRMS_SUCCESS);
05543 }
05544 else
05545 {
05546 fprintf(stderr, "Can't create new records in '%s'; permission denied.\n", seriesOut);
05547 error = 1;
05548 }
05549
05550 if (rec != NULL && !error)
05551 {
05552
05553 HIterator_t hit;
05554 hiter_new(&hit, &(rec->keywords));
05555 DRMS_Keyword_t *outKey = NULL;
05556 DRMS_Keyword_t *inKey = NULL;
05557
05558 while ((outKey = (DRMS_Keyword_t *)hiter_getnext(&hit)) != NULL)
05559 {
05560 inKey = drms_keyword_lookup(inRec, outKey->info->name, 1);
05561 if (inKey != NULL && !drms_keyword_isindex(inKey))
05562 {
05563 status = drms_setkey(rec,
05564 outKey->info->name,
05565 outKey->info->type,
05566 &(inKey->value));
05567
05568 error = (status != DRMS_SUCCESS);
05569 }
05570 }
05571
05572 hiter_free(&hit);
05573
05574
05575 unsigned int index = 0;
05576 for (; index < nSegs; index++)
05577 {
05578 if (pOutData != NULL && outSegNames != NULL)
05579 {
05580 DRMS_Segment_t *inseg = NULL;
05581 DRMS_Segment_t *outseg = NULL;
05582
05583 if (outSegNames[index])
05584 {
05585
05586
05587
05588 inseg = drms_segment_lookup(inRec, outSegNames[index]);
05589 outseg = drms_segment_lookup(rec, outSegNames[index]);
05590
05591 if (nSegs == 1 && (inseg == NULL || outseg == NULL))
05592 {
05593
05594
05595
05596 inseg = drms_segment_lookupnum(inRec, 0);
05597 outseg = drms_segment_lookupnum(rec, 0);
05598 }
05599 }
05600
05601 if (inseg != NULL && outseg != NULL)
05602 {
05603
05604 void *pOut = NULL;
05605
05606 switch (actualtype)
05607 {
05608 case DRMS_TYPE_CHAR:
05609 pOut = (void *)(((char **)(pOutData))[index]);
05610 break;
05611 case DRMS_TYPE_SHORT:
05612 pOut = (void *)(((short **)(pOutData))[index]);
05613 break;
05614 case DRMS_TYPE_INT:
05615 pOut = (void *)(((int **)(pOutData))[index]);
05616 break;
05617 case DRMS_TYPE_LONGLONG:
05618 pOut = (void *)(((long long **)(pOutData))[index]);
05619 break;
05620 case DRMS_TYPE_FLOAT:
05621 pOut = (void *)(((float **)(pOutData))[index]);
05622 break;
05623 case DRMS_TYPE_DOUBLE:
05624 pOut = (void *)(((double **)(pOutData))[index]);
05625 break;
05626 }
05627
05628 DRMS_Array_t *segArray = NULL;
05629 int actaxis[DRMS_MAXRANK];
05630 int end[DRMS_MAXRANK];
05631 int iaxis;
05632
05633 if (slicelower && sliceupper)
05634 {
05635
05636 for (iaxis = 0; iaxis < inseg->info->naxis; iaxis++)
05637 {
05638 actaxis[iaxis] = sliceupper[iaxis] - slicelower[iaxis] + 1;
05639 }
05640 }
05641 else
05642 {
05643 memcpy(actaxis, inseg->axis, sizeof(int) * inseg->info->naxis);
05644 }
05645
05646 if (pout)
05647 {
05648 for (iaxis = 0; iaxis < inseg->info->naxis; iaxis++)
05649 {
05650 end[iaxis] = actaxis[iaxis] + pout[iaxis] - 1;
05651 }
05652 }
05653
05654 segArray = drms_array_create(actualtype,
05655 inseg->info->naxis,
05656 actaxis,
05657 pOut,
05658 &status);
05659
05660 error = (status != DRMS_SUCCESS);
05661
05662 if (!error)
05663 {
05664 if (dtype == DRMS_TYPE_RAW)
05665 {
05666
05667
05668
05669
05670 segArray->bzero = insegBZERO[index];
05671 segArray->bscale = insegBSCALE[index];
05672 segArray->israw = 1;
05673 }
05674 else
05675 {
05676
05677
05678
05679
05680 segArray->bzero = bzero;
05681 segArray->bscale = bscale;
05682 segArray->israw = 0;
05683 }
05684
05685 if (pout == NULL)
05686 {
05687 drms_segment_write(outseg, segArray, 0);
05688 }
05689 else
05690 {
05691 drms_segment_writeslice(outseg, segArray, pout, end, 0);
05692 }
05693
05694 drms_free_array(segArray);
05695 }
05696 }
05697 }
05698 }
05699
05700 if (!error)
05701 {
05702
05703 drms_keyword_setdate(rec);
05704 drms_close_record(rec, DRMS_INSERT_RECORD);
05705 }
05706 else
05707 {
05708 drms_close_record(rec, DRMS_FREE_RECORD);
05709 }
05710 }
05711 else if (rec != NULL)
05712 {
05713 drms_close_record(rec, DRMS_FREE_RECORD);
05714 }
05715 }
05716
05717
05718
05719
05720 unsigned int index = 0;
05721 for (; index < nSegs; index++)
05722 {
05723 if (outSegNames[index] != NULL)
05724 {
05725 char *pName = outSegNames[index];
05726 free(pName);
05727 }
05728 }
05729
05730 if (outSegNames != NULL)
05731 {
05732 free(outSegNames);
05733 }
05734
05735 if (pOutData)
05736 {
05737 free(pOutData);
05738 pOutData = NULL;
05739 }
05740 }
05741
05742 if (insegBZERO)
05743 {
05744 free(insegBZERO);
05745 }
05746
05747 if (insegBSCALE)
05748 {
05749 free(insegBSCALE);
05750 }
05751
05752 if (inRecSet != NULL)
05753 {
05754 drms_close_records(inRecSet, DRMS_FREE_RECORD);
05755 }
05756
05757 if (pOutData)
05758 {
05759 free(pOutData);
05760 }
05761
05762 return error;
05763 }
05764
05765 #if TESTER
05766 typedef struct yammer
05767 {
05768 int a;
05769 char *b;
05770 } yammer_t;
05771
05772 void FreeF(const void *v)
05773 {
05774 free(((yammer_t *)(v))->b);
05775 };
05776
05777 void CopyF(const void *dst, const void *src)
05778 {
05779 ((yammer_t *)dst)->b = strdup(((yammer_t *)src)->b);
05780 };
05781 #endif
05782
05783 int DoIt(void)
05784 {
05785
05786 #if TESTER
05787 char *nameArr[4] = {"name1", "name2", "name3", "name4"};
05788 char *strArr[4] = {"yammer1", "yammer2", "yammer3", "yammer4"};
05789 yammer_t valArr[4];
05790
05791 valArr[0].a = 1;
05792 valArr[0].b = strArr[0];
05793 valArr[1].a = 2;
05794 valArr[1].b = strArr[1];
05795 valArr[2].a = 3;
05796 valArr[2].b = strArr[2];
05797 valArr[3].a = 4;
05798 valArr[3].b = strArr[3];
05799
05800 yammer_t *valArrI[4] = {&valArr[0], &valArr[1], &valArr[2], &valArr[3]};
05801
05802 HContainer_t *cont = hcon_create(sizeof(yammer_t),
05803 128,
05804 FreeF,
05805 CopyF,
05806 (void **)valArrI,
05807 nameArr,
05808 4);
05809 if (cont)
05810 {
05811 HIterator_t *it = hiter_create(cont);
05812 if (it)
05813 {
05814 yammer_t *yp = NULL;
05815 while ((yp = (yammer_t *)hiter_getnext(it)) != NULL)
05816 {
05817 printf("int val %d, str val %s\n", yp->a, yp->b);
05818 }
05819
05820 hiter_destroy(&it);
05821 }
05822
05823 hcon_destroy(&cont);
05824 }
05825
05826 printf("Aok\n");
05827
05828 return 1;
05829 #endif
05830 int error = 0;
05831 int status = 0;
05832
05833 if (NiceIntro())
05834 {
05835 return 0;
05836 }
05837
05838 if (drms_env == NULL)
05839 {
05840 error = 1;
05841 }
05842 else
05843 {
05844
05845 int bBinaryOp = 0;
05846 int bSeriesOut = 0;
05847 int bWithRecSet = 0;
05848 int bSeriesOutExists = 0;
05849
05850
05851 int bSeriesOutEqSeriesIn = 0;
05852 ArithOp_t op = kArithOpUnknown;
05853 char inSeriesName[DRMS_MAXSERIESNAMELEN];
05854 char withSeriesName[DRMS_MAXSERIESNAMELEN];
05855
05856 const char *recSetIn = cmdparams_get_str(&cmdparams, kRecSetIn, NULL);
05857 int *slicelower = NULL;
05858 int *sliceupper = NULL;
05859 int *posout = NULL;
05860
05861 int slicedim = cmdparams_get_intarr(&cmdparams, kInSliceLower, &slicelower, NULL);
05862 if (cmdparams_get_intarr(&cmdparams, kInSliceUpper, &sliceupper, NULL) != slicedim)
05863 {
05864 error = 1;
05865 fprintf(stderr, "Slice dimension mismatch.\n");
05866 }
05867
05868 if (cmdparams_get_intarr(&cmdparams, kPosOut, &posout, NULL) != slicedim)
05869 {
05870 error = 1;
05871 fprintf(stderr, "Slice dimension mismatch.\n");
05872 }
05873
05874 if (!error && slicedim > 0)
05875 {
05876 if (slicelower[0] == -1 || sliceupper[0] == -1)
05877 {
05878 slicedim = 0;
05879 free(slicelower);
05880 slicelower = NULL;
05881 free(sliceupper);
05882 sliceupper = NULL;
05883 }
05884
05885 if (posout[0] == -1)
05886 {
05887 free(posout);
05888 posout = NULL;
05889 }
05890 }
05891
05892 const char *withRecSet = cmdparams_get_str(&cmdparams, kWithRecSet, NULL);
05893 const char *seriesOut = cmdparams_get_str(&cmdparams,
05894 kSeriesOut,
05895 NULL);
05896
05897 int pfile = 0;
05898
05899 const char *segList = cmdparams_get_str(&cmdparams, kSegList, NULL);
05900 const char *opStr = cmdparams_get_str(&cmdparams, kOp, NULL);
05901
05902 double bzerov = cmdparams_get_double(&cmdparams, kBzero, NULL);
05903 double bscalev = cmdparams_get_double(&cmdparams, kBscale, NULL);
05904 DRMS_Type_t dtype = (DRMS_Type_t)cmdparams_get_int(&cmdparams, kDatatype, NULL);
05905 if (dtype > DRMS_TYPE_DOUBLE)
05906 {
05907 dtype = DRMS_TYPE_RAW;
05908 }
05909
05910 int nosegs = cmdparams_isflagset(&cmdparams, kNoSegsFlag);
05911
05912 char actualOutputSeries[DRMS_MAXSERIESNAMELEN];
05913
05914
05915 char *segNameArr[kMaxSegs];
05916 bzero(segNameArr, sizeof(segNameArr));
05917
05918 int nSegs = 0;
05919
05920 DRMS_Record_t *inRecTemplate = NULL;
05921 DRMS_Record_t *outRecTemplate = NULL;
05922
05923
05924 if (strcmp(opStr, kNotSpecified) == 0)
05925 {
05926 error = 1;
05927 fprintf(stderr, "Operation parameters is required.\n");
05928 }
05929 else
05930 {
05931 op = MapOp(opStr);
05932
05933 if (op == kArithOpUnknown)
05934 {
05935 error = 1;
05936 fprintf(stderr, "Invalid op %s.\n", opStr);
05937 }
05938
05939 bBinaryOp = IsBinaryOp(op);
05940 }
05941
05942
05943 if (!error && strcmp(recSetIn, kNotSpecified) == 0)
05944 {
05945 error = 1;
05946 fprintf(stderr, "Input record set required.\n");
05947 }
05948
05949 if (!error)
05950 {
05951 if (drms_record_getquerytype(recSetIn) == kRecordSetType_PlainFile)
05952 {
05953 pfile = 1;
05954 }
05955 else
05956 {
05957 snprintf(inSeriesName, sizeof(inSeriesName), recSetIn);
05958 char *pChar = strchr(inSeriesName, '[');
05959 if (pChar != NULL)
05960 {
05961 *pChar = '\0';
05962 }
05963 }
05964 }
05965
05966 if (!error)
05967 {
05968
05969 if (!pfile)
05970 {
05971 inRecTemplate = drms_template_record(drms_env, inSeriesName, &status);
05972 error = (status != 0);
05973 if (error)
05974 {
05975 fprintf(stderr, "BAILING: inSeries does not exist\n");
05976 }
05977 }
05978 else
05979 {
05980 DRMS_RecordSet_t *pfileRS = drms_open_records(drms_env, recSetIn, &status);
05981 if (pfileRS && pfileRS->n > 0)
05982 {
05983 const char *pfileSeries = pfileRS->records[0]->seriesinfo->seriesname;
05984 inRecTemplate = drms_template_record(drms_env, pfileSeries, &status);
05985 }
05986 else
05987 {
05988 error = 1;
05989 fprintf(stderr, "BAILING: plain file query does not resolve into any fits files.\n");
05990 }
05991 }
05992 }
05993
05994 if (!error && strcmp(seriesOut, kNotSpecified) != 0)
05995 {
05996 bSeriesOut = 1;
05997
05998
05999 if (strcmp(inSeriesName, seriesOut) == 0)
06000 {
06001 bSeriesOutExists = 1;
06002 bSeriesOutEqSeriesIn = 1;
06003 }
06004 else
06005 {
06006 outRecTemplate = drms_template_record(drms_env,
06007 seriesOut,
06008 &status);
06009
06010 if (status == DRMS_SUCCESS)
06011 {
06012 bSeriesOutExists = 1;
06013 }
06014 }
06015 }
06016
06017 if (!error && strcmp(withRecSet, kNotSpecified) != 0)
06018 {
06019 bWithRecSet = 1;
06020 snprintf(withSeriesName, sizeof(withSeriesName), withRecSet);
06021 char *pChar = strchr(withSeriesName, '[');
06022 if (pChar != NULL)
06023 {
06024 *pChar = '\0';
06025 }
06026 }
06027
06028 if (!error && strcmp(segList, kNotSpecified) != 0)
06029 {
06030 char *aSeg;
06031
06032 for (aSeg = strtok(segList, ","); aSeg && nSegs < kMaxSegs; aSeg = strtok(NULL, ","))
06033 {
06034 segNameArr[nSegs++] = strdup(aSeg);
06035 }
06036 }
06037
06038 if (!error)
06039 {
06040
06041 DRMSContainer_t inSeriesPrimeKeys;
06042 DRMSContainer_t inSeriesSegs;
06043 DRMSContainer_t segsToProc;
06044 DRMSContainer_t outSeriesPrimeKeys;
06045 DRMSContainer_t outSeriesSegs;
06046
06047 inSeriesPrimeKeys.items = NULL;
06048 inSeriesSegs.items = NULL;
06049 segsToProc.items = NULL;
06050 outSeriesPrimeKeys.items = NULL;
06051 outSeriesSegs.items = NULL;
06052 outSeriesSegs.Free = NULL;
06053
06054 if (!error)
06055 {
06056
06057 error = CreateDRMSPrimeKeyContainer(inRecTemplate,
06058 &inSeriesPrimeKeys,
06059 ReleaseHContainer);
06060 }
06061
06062 if (!error)
06063 {
06064 CreateDRMSSegmentContainer(inRecTemplate, &inSeriesSegs, NULL);
06065 }
06066
06067 if (!error && bSeriesOut && bSeriesOutExists && !bSeriesOutEqSeriesIn)
06068 {
06069 error = CreateDRMSPrimeKeyContainer(outRecTemplate,
06070 &outSeriesPrimeKeys,
06071 ReleaseHContainer);
06072
06073 if (!error)
06074 {
06075 CreateDRMSSegmentContainer(outRecTemplate,
06076 &outSeriesSegs,
06077 NULL);
06078 }
06079 }
06080
06081
06082 if (!error && bBinaryOp)
06083 {
06084
06085 error = (bWithRecSet != 1);
06086
06087 DRMSContainer_t withSeriesPrimeKeys;
06088 DRMSContainer_t withSeriesSegs;
06089 DRMS_Record_t *withRecTemplate = NULL;
06090
06091 if (!error)
06092 {
06093 withRecTemplate = drms_template_record(drms_env,
06094 withSeriesName,
06095 &status);
06096 error = (status != DRMS_SUCCESS);
06097 }
06098
06099 if (!error)
06100 {
06101 error = CreateDRMSPrimeKeyContainer(withRecTemplate,
06102 &withSeriesPrimeKeys,
06103 ReleaseHContainer);
06104 }
06105
06106 if (!error)
06107 {
06108 CreateDRMSSegmentContainer(withRecTemplate,
06109 &withSeriesSegs,
06110 NULL);
06111 }
06112
06113 if (!error)
06114 {
06115 error = ValidateBinaryOperands(recSetIn,
06116 segNameArr,
06117 nSegs,
06118 &inSeriesPrimeKeys,
06119 &inSeriesSegs,
06120 &withSeriesPrimeKeys,
06121 &withSeriesSegs,
06122 &segsToProc);
06123 }
06124
06125 DestroyDRMSContainer(&withSeriesPrimeKeys);
06126 DestroyDRMSContainer(&withSeriesSegs);
06127 free(withSeriesSegs.items);
06128 }
06129 else if (!error)
06130 {
06131
06132
06133 int nSegsToProc = CreateMatchingSegs(&inSeriesSegs,
06134 &inSeriesSegs,
06135 &segsToProc);
06136
06137 if (nSegsToProc == -1)
06138 {
06139 error = 1;
06140 }
06141 }
06142
06143
06144 if (!error)
06145 {
06146 if (pfile)
06147 {
06148 if (!bSeriesOut)
06149 {
06150
06151 error = 1;
06152 }
06153 else
06154 {
06155 strncpy(actualOutputSeries, seriesOut, sizeof(actualOutputSeries));
06156 }
06157 }
06158 else if (bSeriesOut && bSeriesOutExists)
06159 {
06160 if(!bSeriesOutEqSeriesIn)
06161 {
06162
06163
06164 if (!KeysEqual(&inSeriesPrimeKeys, &outSeriesPrimeKeys))
06165 {
06166 error = 1;
06167 }
06168
06169
06170
06171
06172 if (!error)
06173 {
06174 int nSegsToProc = CreateMatchingSegs(&outSeriesSegs,
06175 &segsToProc,
06176 NULL);
06177
06178 if (nSegsToProc == -1)
06179 {
06180 error = 1;
06181 }
06182 else if (nSegsToProc > 0 && nSegsToProc != segsToProc.items->num_total)
06183 {
06184 error = 1;
06185 fprintf(stderr, "Target series is missing one or more required segments.\n");
06186 }
06187 }
06188 }
06189
06190 strncpy(actualOutputSeries, seriesOut, sizeof(actualOutputSeries));
06191 }
06192 else if (bSeriesOut && !bSeriesOutExists)
06193 {
06194
06195
06196
06197
06198
06199
06200
06201
06202
06203 error = 1;
06204 fprintf(stdout, "Need to call drms_create_seriesfromtemplate()!!!\n");
06205 XASSERT(0);
06206
06207 if (!error)
06208 {
06209 strncpy(actualOutputSeries, seriesOut, sizeof(actualOutputSeries));
06210 }
06211 }
06212 else
06213 {
06214
06215 strncpy(actualOutputSeries, inSeriesName, sizeof(actualOutputSeries));
06216 }
06217 }
06218
06219
06220 if (!error)
06221 {
06222 if (bBinaryOp == 1)
06223 {
06224 error = DoBinaryOp(drms_env,
06225 op,
06226 dtype,
06227 &inSeriesPrimeKeys,
06228 &segsToProc,
06229 recSetIn,
06230 withSeriesName,
06231 withRecSet,
06232 actualOutputSeries,
06233 bzerov,
06234 bscalev);
06235 }
06236 else
06237 {
06238
06239
06240
06241
06242 error = DoUnaryOp(drms_env,
06243 op,
06244 dtype,
06245 &segsToProc,
06246 recSetIn,
06247 slicelower,
06248 sliceupper,
06249 actualOutputSeries,
06250 posout,
06251 bzerov,
06252 bscalev,
06253 nosegs);
06254 }
06255
06256 }
06257
06258 DestroyDRMSContainer(&inSeriesPrimeKeys);
06259 DestroyDRMSContainer(&outSeriesPrimeKeys);
06260 DestroyDRMSContainer(&inSeriesSegs);
06261 DestroyDRMSContainer(&outSeriesSegs);
06262 free(inSeriesSegs.items);
06263 DestroyDRMSContainer(&segsToProc);
06264 }
06265
06266 if (slicelower)
06267 {
06268 free(slicelower);
06269 }
06270
06271 if (sliceupper)
06272 {
06273 free(sliceupper);
06274 }
06275
06276 if (posout)
06277 {
06278 free(posout);
06279 }
06280 }
06281
06282 return error;
06283 }