/* Function that does the quantization */
void quantize(unsigned int *codes, float *X, float *low, float step, int N){

  int i;
#ifdef CILK
  cilk_for(i=0; i<N; i++){
#else
  for(i=0; i<N; i++){
#endif
    int j;
    for(j=0; j<DIM; j++){
      codes[i*DIM + j] = compute_code(X[i*DIM + j], low[j], step); 
    }
  }

}

float max_range(float *x){

  float max = -FLT_MAX;
  int i;
  for(i=0; i<DIM; i++){
    if(max<x[i]){
      max = x[i];
    }
  }

  return max;
}
Example #2
0
int main()
{
    const char *secret = "123";

    //uint8_t binary_secret[sizeof(secret)];
    size_t secretLen = strlen(secret);
    //size_t secretLen = base32_decode(secret, binary_secret,
    //                                        sizeof(binary_secret));
    //printf("--------- %d\n", secretLen);

    //unsigned long value = get_timestamp();
    //value = 0;
    char *value;

    value = malloc(50);
    unsigned long ul_value = get_timestamp();
    snprintf(value, 50, "%d\n", ul_value);
    printf("&&&&&%s\n", value);
    //strcpy(value, "47782269");
    //printf("%s\n", value); 
    int hs_code;

    hs_code = compute_code(secret, secretLen, value);
    free(value);
    printf("%d\n", hs_code);
    return 0;
}
Example #3
0
/* Thread routine*/
void *pthread_quantize(void* pthread_data) {
  struct quantize_data *d = (struct quantize_data *) pthread_data;

  for(int i=0; i<d->N; i++){
    for(int j=0; j<DIM; j++){
      d->codes[i*DIM + j] = compute_code(d->X[i*DIM + j], d->low[j], d->step); 
    }
  }
  pthread_exit(0);
}
Example #4
0
void pat_wildexp(char *src, int i)
// Expand wildchar in src[i]
{
    char src1[10];
    int env8;
    if ( i==9 ) { // all the positions in src are processed -- end of recursion
        env8 = compute_code(src);
        nb++;
        int q = env8 >> 3, r = env8 & 7;
        pat3set[q] |= bit[r];              // set the bit corresponding to env8
        return;
    }
Example #5
0
void *pthread_quantize(void* pthread_data)
{
    //assign values to arguments
    struct quantize_data *data = (struct quantize_data *) pthread_data;
    unsigned int *codes = data->codes;
    float *X = data->X;
    float *low = data->low;
    float step = data->step;
    int N = data->N;

    //initialize stuff
    int i, j;
    for(i=0; i<N; i++)
    {
        for (j=0; j<DIM; j++)
        {
            codes[i*DIM+j] = compute_code(X[i*DIM + j], low[j], step);
        }
    }
    pthread_exit(0);
}