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/peak.c

    r7917 r20936  
    55  int i, N, imax, QUIET;
    66  double start, end, xmax, ymax;
    7   float *X, *Y;
    87  Vector *vecx, *vecy;
    98
     
    2625    end   = atof (argv[4]);
    2726  } else {
    28     start = vecx[0].elements[0];
    29     end   = vecx[0].elements[vecx[0].Nelements - 1];
     27    start = (vecx[0].type == OPIHI_FLT) ? vecx[0].elements.Flt[0] : vecx[0].elements.Int[0];
     28    end   = (vecx[0].type == OPIHI_FLT) ? vecx[0].elements.Flt[vecx[0].Nelements - 1] : vecx[0].elements.Int[vecx[0].Nelements - 1];
    3029  }
    3130
    32   X = vecx[0].elements;
    33   Y = vecy[0].elements;
     31  imax = -1;
     32  xmax = -HUGE_VAL;
     33  ymax = -HUGE_VAL;
    3434
    35   imax = -1;
    36   xmax = *X;
    37   ymax = *Y;
    38   for (i = 1; i < vecx[0].Nelements-1; i++, X++, Y++) {
    39     if ((*X >= start) && (*X <= end)) {
    40       if ((imax == -1) || (*Y > ymax)) {
    41         xmax = *X;
    42         ymax = *Y;
    43         imax = i;
    44       }
    45     }
    46   }     
     35  if ((vecx[0].type == OPIHI_FLT) && (vecy[0].type == OPIHI_FLT)) {
     36    opihi_flt *X = vecx[0].elements.Flt;
     37    opihi_flt *Y = vecy[0].elements.Flt;
     38    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
     39      if (*X < start) continue;
     40      if (*X > end) continue;
     41      if (*Y < ymax) continue;
     42      xmax = *X;
     43      ymax = *Y;
     44      imax = i;
     45    }     
     46  }
     47  if ((vecx[0].type == OPIHI_FLT) && (vecy[0].type == OPIHI_INT)) {
     48    opihi_flt *X = vecx[0].elements.Flt;
     49    opihi_int *Y = vecy[0].elements.Int;
     50    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
     51      if (*X < start) continue;
     52      if (*X > end) continue;
     53      if (*Y < ymax) continue;
     54      xmax = *X;
     55      ymax = *Y;
     56      imax = i;
     57    }     
     58  }
     59  if ((vecx[0].type == OPIHI_INT) && (vecy[0].type == OPIHI_FLT)) {
     60    opihi_int *X = vecx[0].elements.Int;
     61    opihi_flt *Y = vecy[0].elements.Flt;
     62    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
     63      if (*X < start) continue;
     64      if (*X > end) continue;
     65      if (*Y < ymax) continue;
     66      xmax = *X;
     67      ymax = *Y;
     68      imax = i;
     69    }     
     70  }
     71  if ((vecx[0].type == OPIHI_INT) && (vecy[0].type == OPIHI_INT)) {
     72    opihi_int *X = vecx[0].elements.Int;
     73    opihi_int *Y = vecy[0].elements.Int;
     74    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
     75      if (*X < start) continue;
     76      if (*X > end) continue;
     77      if (*Y < ymax) continue;
     78      xmax = *X;
     79      ymax = *Y;
     80      imax = i;
     81    }     
     82  }
    4783
    4884  set_variable ("peakval", ymax);
Note: See TracChangeset for help on using the changeset viewer.