IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 7, 2008, 3:31:01 PM (18 years ago)
Author:
eugene
Message:

big update from eam_branch_20081124 with updates to Opihi math

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/histogram.c

    r18251 r20936  
    44 
    55  int i, bin, Nbins;
    6   float *V, start, end, delta;
     6  opihi_int *OUT;
     7  opihi_flt start, end, delta;
    78  Vector *xvec, *yvec;
    89
     
    3031  if ((xvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    3132  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    }     
    3853  }
    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   }     
    4654
    4755  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.