Changeset 20936 for trunk/Ohana/src/opihi/cmd.data/vbin.c
- Timestamp:
- Dec 7, 2008, 3:31:01 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/vbin.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/vbin.c
r7917 r20936 5 5 int i, j, n, N, Nin, Nout; 6 6 int Normalize, Ignore; 7 float *Vout, *Vin, IgnoreValue;7 opihi_flt *Vout, IgnoreValue; 8 8 double scale; 9 9 Vector *in, *out; … … 42 42 Nout = Nin / scale; 43 43 44 REALLOCATE (out[0].elements, float, Nout);45 out[0].Nelements = Nout;44 // re-binning creates a float vector 45 ResetVector (out, OPIHI_FLT, in[0].Nelements); 46 46 47 Vin = in[0].elements; 48 Vout = out[0].elements; 49 for (n = j = 0; j < Nout; j++, Vout++) { 50 *Vout = 0; 51 for (N = i = 0; (i < scale) && (n < Nin); n++, i++, Vin++) { 52 if (!finite (*Vin)) continue; 53 if (Ignore && (*Vin == IgnoreValue)) continue; 54 *Vout += *Vin; 55 N ++; 56 } 57 if (Normalize) { 58 if (N > 0) { 59 *Vout /= (float) N; 60 } else { 61 *Vout = 0; 47 Vout = out[0].elements.Flt; 48 49 if (in[0].type == OPIHI_FLT) { 50 opihi_flt *Vin = in[0].elements.Flt; 51 for (n = j = 0; j < Nout; j++, Vout++) { 52 *Vout = 0; 53 for (N = i = 0; (i < scale) && (n < Nin); n++, i++, Vin++) { 54 if (!finite (*Vin)) continue; 55 if (Ignore && (*Vin == IgnoreValue)) continue; 56 *Vout += *Vin; 57 N ++; 58 } 59 if (Normalize) { 60 if (N > 0) { 61 *Vout /= (opihi_flt) N; 62 } else { 63 *Vout = 0; 64 } 65 } 66 } 67 } else { 68 opihi_int *Vin = in[0].elements.Int; 69 for (n = j = 0; j < Nout; j++, Vout++) { 70 *Vout = 0; 71 for (N = i = 0; (i < scale) && (n < Nin); n++, i++, Vin++) { 72 if (!finite (*Vin)) continue; 73 if (Ignore && (*Vin == IgnoreValue)) continue; 74 *Vout += *Vin; 75 N ++; 76 } 77 if (Normalize) { 78 if (N > 0) { 79 *Vout /= (opihi_flt) N; 80 } else { 81 *Vout = 0; 82 } 62 83 } 63 84 }
Note:
See TracChangeset
for help on using the changeset viewer.
