Changeset 20936 for trunk/Ohana/src/opihi/cmd.data/histogram.c
- Timestamp:
- Dec 7, 2008, 3:31:01 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/histogram.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/histogram.c
r18251 r20936 4 4 5 5 int i, bin, Nbins; 6 float *V, start, end, delta; 6 opihi_int *OUT; 7 opihi_flt start, end, delta; 7 8 Vector *xvec, *yvec; 8 9 … … 30 31 if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 31 32 if ((yvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) return (FALSE); 32 yvec[0].Nelements = Nbins; 33 34 REALLOCATE (yvec[0].elements, float, yvec[0].Nelements); 35 bzero (yvec[0].elements, sizeof(float)*yvec[0].Nelements); 36 if (Nbins < 1) { 37 return (TRUE); 33 34 ResetVector (yvec, OPIHI_INT, Nbins); 35 bzero (yvec[0].elements.Int, sizeof(opihi_int)*yvec[0].Nelements); 36 if (Nbins < 1) return (TRUE); 37 OUT = yvec[0].elements.Int; 38 39 if (xvec[0].type == OPIHI_FLT) { 40 opihi_flt *V = xvec[0].elements.Flt; 41 for (i = 0; i < xvec[0].Nelements; i++, V++) { 42 if (isnan(*V)) continue; 43 bin = MIN (MAX (0, (*V - start) / delta), Nbins - 1); 44 OUT[bin]++; 45 } 46 } else { 47 opihi_int *V = xvec[0].elements.Int; 48 for (i = 0; i < xvec[0].Nelements; i++, V++) { 49 if (isnan(*V)) continue; 50 bin = MIN (MAX (0, (*V - start) / delta), Nbins - 1); 51 OUT[bin]++; 52 } 38 53 } 39 40 V = xvec[0].elements;41 for (i = 0; i < xvec[0].Nelements; i++, V++) {42 if (isnan(*V)) continue;43 bin = MIN (MAX (0, (*V - start) / delta), Nbins - 1);44 yvec[0].elements[bin] += 1.0;45 }46 54 47 55 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
