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/lib.shell/VectorOps.c

    r20856 r20859  
    187187}
    188188
     189// recast the vector to the specified type
     190int CastVector (Vector *vec, char type) {
     191
     192  // the trivial case
     193  if (vec[0].type == type) return TRUE;
     194
     195  if (type == OPIHI_FLT) {
     196    opihi_flt *temp;
     197    ALLOCATE (temp, opihi_flt, vec[0].Nelements);
     198    opihi_flt *vo = temp;
     199    opihi_int *vi = vec[0].elements.Int;
     200    for (i = 0; i < vec[0].Nelements; i++, vo++, vi++) {
     201      *vo = *vi;
     202    }
     203    free (vec[0].elements.Int);
     204    vec[0].elements.Flt = vo;
     205    vec[0].type = OPIHI_FLT;
     206  } else {
     207    opihi_int *temp;
     208    ALLOCATE (temp, opihi_int, vec[0].Nelements);
     209    opihi_int *vo = temp;
     210    opihi_flt *vi = vec[0].elements.Flt;
     211    for (i = 0; i < vec[0].Nelements; i++, vo++, vi++) {
     212      *vo = *vi;
     213    }
     214    free (vec[0].elements.Flt);
     215    vec[0].elements.Int = vo;
     216    vec[0].type = OPIHI_INT;
     217  }
     218  return TRUE;
     219}
     220
    189221/* move data from in to out - use old memory space */
    190222int MoveNamedVector (char *out, char *in) {
Note: See TracChangeset for help on using the changeset viewer.