IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 18, 2019, 5:02:59 PM (7 years ago)
Author:
eugene
Message:

cleanup opihi sort functions; add deimos fitobj function

Location:
trunk/Ohana/src/opihi/cmd.data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/nnet_train.c

    r40371 r40642  
    33// these are local only
    44float nnet_sigmoid (float value);
    5 void  nnet_sortseq (float *X, int *Y, int N);
    65int   nnet_onelayer (Nnet *nnet, int L);
    76void  nnet_reset_Nabla (Nnet *nnet);
     
    191190    // generate a random sequence : used to select random mini batches
    192191    for (int i = 0; i < Ntrial; i++) { seq[i] = i; rnd[i] = drand48(); }
    193     nnet_sortseq (rnd, seq, Ntrial);
     192    sort_float_index (rnd, seq, Ntrial);
    194193
    195194    int Npass = Ntrial / Nmini;
     
    514513  return 1.0 / (1.0 + exp(-value));
    515514}
    516 
    517 void nnet_sortseq (float *X, int *Y, int N) {
    518 
    519 # define SWAPFUNC(A,B){ float ftmp; int itmp;   \
    520     ftmp = X[A]; X[A] = X[B]; X[B] = ftmp;      \
    521     itmp = Y[A]; Y[A] = Y[B]; Y[B] = itmp;      \
    522   }
    523 # define COMPARE(A,B)(X[A] < X[B])
    524 
    525   OHANA_SORT (N, COMPARE, SWAPFUNC);
    526 
    527 # undef SWAPFUNC
    528 # undef COMPARE
    529 
    530 }
    531 
  • trunk/Ohana/src/opihi/cmd.data/sort.c

    r40398 r40642  
    11# include "data.h"
    2 
    3 void fsortindex (opihi_flt *X, int *IDX, int N) {
    4 
    5 # define SWAPFUNC(A,B){ opihi_flt tmp; int itmp;        \
    6   tmp = X[A]; X[A] = X[B]; X[B] = tmp; \
    7   itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \
    8 }
    9 
    10 // # define COMPARE(A,B)(X[A] < X[B])
    11 # define COMPARE(A,B)((!isfinite(X[A]) && isfinite(X[B])) || (X[A] < X[B]))
    12 
    13   OHANA_SORT (N, COMPARE, SWAPFUNC);
    14 
    15 # undef SWAPFUNC
    16 # undef COMPARE
    17 
    18 }
    19 
    20 void isortindex (opihi_int *X, int *IDX, int N) {
    21 
    22 # define SWAPFUNC(A,B){ opihi_int tmp; int itmp;        \
    23   tmp = X[A]; X[A] = X[B]; X[B] = tmp; \
    24   itmp = IDX[A]; IDX[A] = IDX[B]; IDX[B] = itmp; \
    25 }
    26 
    27 # define COMPARE(A,B)(X[A] < X[B])
    28 // # define COMPARE(A,B)((!isfinite(X[A]) && isfinite(X[B])) || (X[A] < X[B]))
    29 
    30   OHANA_SORT (N, COMPARE, SWAPFUNC);
    31 
    32 # undef SWAPFUNC
    33 # undef COMPARE
    34 
    35 }
    362
    373// XXX add an option to NOT sort, but return an index instead?
     
    7844  /* sort key & index */
    7945  if (vec[0][0].type == OPIHI_FLT) {
    80     fsortindex (vec[0][0].elements.Flt, index, Nval);
     46    sort_opihi_flt_index (vec[0][0].elements.Flt, index, Nval);
    8147  } else {
    82     isortindex (vec[0][0].elements.Int, index, Nval);
     48    sort_int_index (vec[0][0].elements.Int, index, Nval);
    8349  }
    8450
Note: See TracChangeset for help on using the changeset viewer.