Changeset 42516
- Timestamp:
- Aug 17, 2023, 4:28:02 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/Ohana/src/opihi/cmd.data/reindex.c
r42389 r42516 13 13 remove_argument (N, &argc, argv); 14 14 KEEP_UNMATCH = TRUE; 15 } 16 17 // BLANKVAL is the name of the value to use for unmatched elements 18 char *BLANKVAL = NULL; 19 if ((N = get_argument (argc, argv, "-blank")) || (N = get_argument (argc, argv, "-blank-value"))) { 20 remove_argument (N, &argc, argv); 21 BLANKVAL = strcreate (argv[N]); 22 remove_argument (N, &argc, argv); 15 23 } 16 24 … … 35 43 opihi_flt *vi = ivec[0].elements.Flt; 36 44 opihi_int *vx = xvec[0].elements.Int; 45 opihi_flt myBlank = (BLANKVAL == NULL) ? NAN : atof(BLANKVAL); 37 46 for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) { 38 47 if (Npts >= NPTS) { … … 42 51 if (*vx < 0) { 43 52 if (KEEP_UNMATCH) { 44 ovec[0].elements.Flt[Npts] = NAN;53 ovec[0].elements.Flt[Npts] = myBlank; 45 54 Npts++; 46 55 } … … 55 64 opihi_int *vi = ivec[0].elements.Int; 56 65 opihi_int *vx = xvec[0].elements.Int; 66 opihi_int myBlank = (BLANKVAL == NULL) ? -4096 : atoi(BLANKVAL); 57 67 for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) { 58 68 if (Npts >= NPTS) { … … 62 72 if (*vx < 0) { 63 73 if (KEEP_UNMATCH) { 64 ovec[0].elements.Int[Npts] = -4096; // XXX use a different or a specified value?74 ovec[0].elements.Int[Npts] = myBlank; 65 75 Npts++; 66 76 } … … 74 84 if (ivec->type == OPIHI_STR) { 75 85 opihi_int *vx = xvec[0].elements.Int; 86 char *myBlank = (BLANKVAL == NULL) ? strcreate ("") : strcreate(BLANKVAL); 76 87 for (Npts = i = 0; i < xvec[0].Nelements; i++, vx++) { 77 88 if (Npts >= NPTS) { … … 90 101 Npts++; 91 102 } 103 FREE (myBlank); 92 104 } 93 105 94 106 // free up unused memory 95 107 ResetVector (ovec, ivec->type, Npts); 108 FREE (BLANKVAL); 96 109 return (TRUE); 97 110 98 111 error: 99 112 DeleteVector (ovec); 113 FREE (BLANKVAL); 100 114 return (FALSE); 101 115 … … 104 118 gprint (GP_ERR, " Creates a new vector (out) from (in) based on sequence in (index)\n"); 105 119 gprint (GP_ERR, " output[i] = input[index[i]]\n"); 106 gprint (GP_ERR, " If -keep-unmatched is provided, elements of index with negative values will be set to NaN / - 1,\n");120 gprint (GP_ERR, " If -keep-unmatched is provided, elements of index with negative values will be set to NaN / -4096 (or specific value)\n"); 107 121 gprint (GP_ERR, " otherwise they will be skipped in the output.\n"); 122 gprint (GP_ERR, " If -blank-value is provided, this supplied value will be used for unmatched elements\n"); 108 123 gprint (GP_ERR, " The output vector has the type of the input vector and the length of the index (if -keep-unmatched).\n"); 109 124 gprint (GP_ERR, " The index vector may have duplicates\n"); 125 FREE (BLANKVAL); 110 126 return (FALSE); 111 127 }
Note:
See TracChangeset
for help on using the changeset viewer.
