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

    r7917 r20936  
    44 
    55  int Nnew, i, j, found;
    6   float *v1, *v2;
    76  Vector *ivec, *ovec;
    87
     
    1615
    1716  /* allocate the maximum possible needed */
    18   ALLOCATE (ovec[0].elements, float, ivec[0].Nelements);
     17  ResetVector (ovec, ivec->type, ivec->Nelements);
    1918
    2019  Nnew = 0;
    21   v1 = ivec[0].elements;
    22   for (i = 0; i < ivec[0].Nelements; i++, v1++) {
    23     v2 = ovec[0].elements;
    24     found = FALSE;
    25     for (j = 0; !found && (j < Nnew); j++, v2++) {
    26       if (*v1 == *v2) found = TRUE;
     20
     21  if (ivec->type == OPIHI_FLT) {
     22    opihi_flt *v1 = ivec[0].elements.Flt;
     23    for (i = 0; i < ivec[0].Nelements; i++, v1++) {
     24      opihi_flt *v2 = ovec[0].elements.Flt;
     25      found = FALSE;
     26      for (j = 0; !found && (j < Nnew); j++, v2++) {
     27        if (*v1 == *v2) found = TRUE;
     28      }
     29      if (!found) {
     30        ovec[0].elements.Flt[Nnew] = *v1;
     31        Nnew ++;
     32      }
    2733    }
    28     if (!found) {
    29       ovec[0].elements[Nnew] = *v1;
    30       Nnew ++;
     34  } else {
     35    opihi_int *v1 = ivec[0].elements.Int;
     36    for (i = 0; i < ivec[0].Nelements; i++, v1++) {
     37      opihi_int *v2 = ovec[0].elements.Int;
     38      found = FALSE;
     39      for (j = 0; !found && (j < Nnew); j++, v2++) {
     40        if (*v1 == *v2) found = TRUE;
     41      }
     42      if (!found) {
     43        ovec[0].elements.Int[Nnew] = *v1;
     44        Nnew ++;
     45      }
    3146    }
    3247  }
    3348
    34   ovec[0].Nelements = Nnew;
    35   REALLOCATE (ovec[0].elements, float, ovec[0].Nelements);
     49  // free up extra memory
     50  ResetVector (ovec, ivec->type, Nnew);
    3651
    3752  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.