Changeset 20936 for trunk/Ohana/src/opihi/cmd.data/subset.c
- Timestamp:
- Dec 7, 2008, 3:31:01 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/subset.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/subset.c
r7917 r20936 6 6 7 7 char *out; 8 int i, j, size;8 int i, Npts, size; 9 9 Vector *ivec, *ovec, *tvec; 10 10 … … 28 28 /* check size of ivec, tvec: must match */ 29 29 30 REALLOCATE (ovec[0].elements, float, MAX (tvec[0].Nelements, 1)); 31 for (j = i = 0; i < tvec[0].Nelements; i++) { 32 if (tvec[0].elements[i]) { 33 ovec[0].elements[j] = ivec[0].elements[i]; 34 j++; 30 // ovec matches ivec in type 31 ResetVector (ovec, ivec->type, MAX (tvec[0].Nelements, 1)); 32 33 // we have four cases: (ivec == flt or int) and (tvec == flt or int) 34 if ((ivec->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) { 35 opihi_flt *vi = ivec[0].elements.Flt; 36 opihi_flt *vt = tvec[0].elements.Flt; 37 for (Npts = i = 0; i < tvec[0].Nelements; i++, vi++, vt++) { 38 if (!*vt) continue; 39 ovec[0].elements.Flt[Npts] = *vi; 40 Npts++; 35 41 } 36 42 } 37 ovec[0].Nelements = j; 38 REALLOCATE (ovec[0].elements, float, MAX (ovec[0].Nelements, 1)); 43 if ((ivec->type == OPIHI_FLT) && (tvec->type == OPIHI_INT)) { 44 opihi_flt *vi = ivec[0].elements.Flt; 45 opihi_int *vt = tvec[0].elements.Int; 46 for (Npts = i = 0; i < tvec[0].Nelements; i++, vi++, vt++) { 47 if (!*vt) continue; 48 ovec[0].elements.Flt[Npts] = *vi; 49 Npts++; 50 } 51 } 52 if ((ivec->type == OPIHI_INT) && (tvec->type == OPIHI_FLT)) { 53 opihi_int *vi = ivec[0].elements.Int; 54 opihi_flt *vt = tvec[0].elements.Flt; 55 for (Npts = i = 0; i < tvec[0].Nelements; i++, vi++, vt++) { 56 if (!*vt) continue; 57 ovec[0].elements.Int[Npts] = *vi; 58 Npts++; 59 } 60 } 61 if ((ivec->type == OPIHI_INT) && (tvec->type == OPIHI_INT)) { 62 opihi_int *vi = ivec[0].elements.Int; 63 opihi_int *vt = tvec[0].elements.Int; 64 for (Npts = i = 0; i < tvec[0].Nelements; i++, vi++, vt++) { 65 if (!*vt) continue; 66 ovec[0].elements.Int[Npts] = *vi; 67 Npts++; 68 } 69 } 70 71 // free up unused memory 72 ResetVector (ovec, ivec->type, MAX (Npts, 1)); 39 73 40 74 DeleteVector (tvec);
Note:
See TracChangeset
for help on using the changeset viewer.
