- Timestamp:
- Nov 30, 2008, 11:13:15 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/histogram.c
r20839 r20859 4 4 5 5 int i, bin, Nbins; 6 opihi_int *OUT; 6 7 opihi_flt start, end, delta; 7 opihi_flt *V;8 8 Vector *xvec, *yvec; 9 9 … … 31 31 if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 32 32 if ((yvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) return (FALSE); 33 yvec[0].Nelements = Nbins; 34 35 REALLOCATE (yvec[0].elements.Flt, opihi_flt, yvec[0].Nelements); 36 bzero (yvec[0].elements.Flt, sizeof(opihi_flt)*yvec[0].Nelements); 37 if (Nbins < 1) { 38 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 } 39 53 } 40 41 V = xvec[0].elements.Flt;42 for (i = 0; i < xvec[0].Nelements; i++, V++) {43 if (isnan(*V)) continue;44 bin = MIN (MAX (0, (*V - start) / delta), Nbins - 1);45 yvec[0].elements.Flt[bin] += 1.0;46 }47 54 48 55 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
