IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2008, 11:13:15 AM (18 years ago)
Author:
eugene
Message:

allow functions to use FLT or INT vectors as appropriate; document valid types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/cumulative.c

    r20839 r20859  
    44 
    55  int i;
    6   opihi_flt *Vi, *Vo;
     6  opihi_flt *Vo;
    77  Vector *ivec, *ovec;
    88
     
    1414  if ((ivec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    1515  if ((ovec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    16   ovec[0].Nelements = ivec[0].Nelements;
    17    
    18   REALLOCATE (ovec[0].elements.Flt, opihi_flt, ovec[0].Nelements);
     16
     17  ResetVector (ovec, OPIHI_FLT, ivec[0].Nelements);
    1918  bzero (ovec[0].elements.Flt, sizeof(opihi_flt)*ovec[0].Nelements);
    2019
    21   Vi = ivec[0].elements.Flt;
    2220  Vo = ovec[0].elements.Flt;
    23   *Vo = *Vi;
    24   for (i = 1; i < ivec[0].Nelements; i++, Vi++, Vo++) {
    25     *Vo = Vo[-1] + *Vi;
    26   }     
     21
     22  if (ivec[0].type == OPIHI_FLT) {
     23    opihi_flt *Vi = ivec[0].elements.Flt;
     24    *Vo = *Vi;
     25    for (i = 1; i < ivec[0].Nelements; i++, Vi++, Vo++) {
     26      *Vo = Vo[-1] + *Vi;
     27    }     
     28  } else {
     29    opihi_int *Vi = ivec[0].elements.Int;
     30    *Vo = *Vi;
     31    for (i = 1; i < ivec[0].Nelements; i++, Vi++, Vo++) {
     32      *Vo = Vo[-1] + *Vi;
     33    }     
     34  }
    2735  return (TRUE);
    2836}
Note: See TracChangeset for help on using the changeset viewer.