IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2008, 7:45:21 AM (18 years ago)
Author:
eugene
Message:

modify functions to use both int and flt vectors

File:
1 edited

Legend:

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

    r20839 r20857  
    2727  /* check size of in1, in2, tvec: must match */
    2828
    29   REALLOCATE (ovec[0].elements.Flt, opihi_flt, MAX (tvec[0].Nelements, 1));
    30   for (i = 0; i < tvec[0].Nelements; i++) {
    31     ovec[0].elements.Flt[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Flt[i] : in2[0].elements.Flt[i];
     29  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_INT)) {
     30    ResetVector (ovec, OPIHI_INT, MAX (tvec[0].Nelements, 1));
     31  } else {
     32    ResetVector (ovec, OPIHI_FLT, MAX (tvec[0].Nelements, 1));
    3233  }
    33   ovec[0].Nelements = tvec[0].Nelements;
    34   REALLOCATE (ovec[0].elements.Flt, opihi_flt, MAX (ovec[0].Nelements, 1));
     34
     35  // (in1 and in2) == (flt or int) and tvec == (flt or int)
     36  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) {
     37    for (i = 0; i < tvec[0].Nelements; i++) {
     38      ovec[0].elements.Flt[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Flt[i] : in2[0].elements.Flt[i];
     39    }
     40  }
     41  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_INT)) {
     42    for (i = 0; i < tvec[0].Nelements; i++) {
     43      ovec[0].elements.Flt[i] = tvec[0].elements.Int[i] ? in1[0].elements.Flt[i] : in2[0].elements.Flt[i];
     44    }
     45  }
     46  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) {
     47    for (i = 0; i < tvec[0].Nelements; i++) {
     48      ovec[0].elements.Flt[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Int[i] : in2[0].elements.Flt[i];
     49    }
     50  }
     51  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_INT)) {
     52    for (i = 0; i < tvec[0].Nelements; i++) {
     53      ovec[0].elements.Flt[i] = tvec[0].elements.Int[i] ? in1[0].elements.Int[i] : in2[0].elements.Flt[i];
     54    }
     55  }
     56  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_FLT)) {
     57    for (i = 0; i < tvec[0].Nelements; i++) {
     58      ovec[0].elements.Flt[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Flt[i] : in2[0].elements.Int[i];
     59    }
     60  }
     61  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_INT)) {
     62    for (i = 0; i < tvec[0].Nelements; i++) {
     63      ovec[0].elements.Flt[i] = tvec[0].elements.Int[i] ? in1[0].elements.Flt[i] : in2[0].elements.Int[i];
     64    }
     65  }
     66  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_FLT)) {
     67    for (i = 0; i < tvec[0].Nelements; i++) {
     68      ovec[0].elements.Int[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Int[i] : in2[0].elements.Int[i];
     69    }
     70  }
     71  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_INT)) {
     72    for (i = 0; i < tvec[0].Nelements; i++) {
     73      ovec[0].elements.Int[i] = tvec[0].elements.Int[i] ? in1[0].elements.Int[i] : in2[0].elements.Int[i];
     74    }
     75  }
    3576 
    3677  DeleteVector (tvec);
Note: See TracChangeset for help on using the changeset viewer.