Esempio n. 1
0
void calc_polys() {
  int begin_cycles = get_cc();
  int X=0,Y=0;

 

  //P1(X,Y) and S1(X0,Y0)
  float c10 = 6*a[3][0];
  float c01 = 2 * a[2][1];
  float c00 = 6 * a[3][0] + 2 * a[2][0];
  float P1 = c10 * X + c01 * Y + c00;
  //P2(X,Y) and R2(X0,Y0)
  float b20 = 3*a[3][0];
  float b11 = 2*a[2][1];
  float b02 = a[1][2];
  float b10 = 3 * a[3][0] + 2 * a[2][0];
  float b01 = a[2][1] + a[1][1];
  float b00 = a[3][0] + a[2][0] + a[1][0];
  float P2 = b20 * X * X + b11 * X * Y + b02 * Y * Y +\
           b10 * X + b01 * Y +\
           b00 ;
  //P3(X,Y) and Q3(X0,0)
  float P3 = a[3][0] * X * X * X + a[2][1] * X * X * Y + a[1][2] * X * Y * Y + a[0][3] * Y * Y * Y +\
           a[2][0] * X * X + a[1][1] * X * Y + a[0][2] * Y * Y +\
           a[1][0] * X + a[0][1] * Y +\
           a[0][0] ;


  float P0 = 6 * a[3][0];
  
  float Q0 = 6 * a[0][3];
  float Q1 = 6 * a[0][3] + 2 * a[0][2] +2 * a[1][2] * X + 6 * a[0][3] * Y ;
  float Q2 = a[0][3] + a[0][2]+ a[0][1] + a[2][1] * X * X + 2 * a[1][2] * X * Y \
           + 3* a[0][3] * Y * Y + (a[1][2] + a[1][1] ) * X + ( 3 * a[0][3] + 2 * a[0][2] ) * Y ;
  float Q3 = P3 ;

  float R0 = 2* a[1][2] ;
  float R1 = a[1][2] + a[2][1] + a[1][1] + 2 * a[1][2] * X + 2 * a[1][2] * Y ;
  float R2 = P2;

  float S0 = 2* a[2][1] ;
  float S1 = P1;

  int cycles = get_cc();
  my_printf("%x ",P0);
  my_printf("%x ",Q0);
  my_printf("%x ",Q1);
  my_printf("%x ",Q2);
  my_printf("%x ",Q3);
  my_printf("%x ",R0);
  my_printf("%x ",R1);
  my_printf("%x ",R2);
  my_printf("%x ",S0);
  my_printf("%x ",S1);
  my_printf("\n\r");
  my_printf("Time : %d\n\r",cycles - begin_cycles);


}
// entry point
void mexFunction(int nlhs,mxArray *plhs[], int nrhs,const mxArray *prhs[]) 
{
  char* str;
  str = mxArrayToString(prhs[0]);

  if ( 0 == strcmp(str,"train") ) {
    train(nlhs,plhs, nrhs,prhs);
  }
  else if ( 0 == strcmp(str,"get") ) {
    get(nlhs,plhs, nrhs,prhs);
  }
  else if ( 0 == strcmp(str,"get_cc") ) {
    get_cc(nlhs,plhs, nrhs,prhs);
  }
  else if ( 0 == strcmp(str,"get_sc") ) {
    get_sc(nlhs,plhs, nrhs,prhs);
  }
  else if ( 0 == strcmp(str,"get_is_leaf") ) {
    get_is_leaf(nlhs,plhs, nrhs,prhs);
  }
  else if ( 0 == strcmp(str,"predict") ) {
    predict(nlhs,plhs, nrhs,prhs);
  }
  else if ( 0 == strcmp(str,"delete") ) {
    del(nlhs,plhs, nrhs,prhs);
  }
  else if ( 0 == strcmp(str,"save") ) {
    save(nlhs,plhs, nrhs,prhs);
  }
  else {
    mexErrMsgTxt("pSampVTLogitBoost_mex::unknown option.");
  }
}
Esempio n. 3
0
action_result assert_cc_action(hypothesis_idx hidx) {
    if (!get_config().m_cc)
        return action_result::failed();
    congruence_closure & cc = get_cc();
    if (has_expr_metavar(curr_state().get_hypothesis_decl(hidx).get_type()))
        return action_result::failed();
    cc.add(hidx);
    // cc.display();
    if (cc.is_inconsistent()) {
        try {
            app_builder & b  = get_app_builder();
            expr false_proof = *cc.get_inconsistency_proof();
            trace_action("contradiction by congruence closure");
            return action_result(b.mk_false_rec(curr_state().get_target(), false_proof));
        } catch (app_builder_exception &) {
            return action_result::failed();
        }
    } else {
        expr const & target = curr_state().get_target();
        name R; expr lhs, rhs;
        if (is_relation_app(target, R, lhs, rhs) && cc.is_eqv(R, lhs, rhs)) {
            expr proof = *cc.get_eqv_proof(R, lhs, rhs);
            trace_action("equivalence by congruence closure");
            return action_result(proof);
        } else if (is_prop(target) && !is_false(target) && cc.proved(target)) {
            expr proof = *cc.get_proof(target);
            trace_action("equivalent to true by congruence closure");
            return action_result(proof);
        } else {
            return action_result::new_branch();
        }
    }
}
Esempio n. 4
0
void Mail::set_cc(const std::wstring& addrs)
{
	AddressHeaderPtr hd = get_cc();
	if (!hd)
	{
		AddressHeaderPtr new_hd(new AddressHeader(L"cc"));
		headers.add(new_hd);
		hd = new_hd;
	}
	hd->parse_value(addrs);
}
Esempio n. 5
0
static int detect_arch(const char *prefix, char *ret, CUresult *err) {
  CUdevice dev;
  int major, minor;
  int res;
  size_t sz = strlen(prefix) + 3;
  *err = cuCtxGetDevice(&dev);
  if (*err != CUDA_SUCCESS) return GA_IMPL_ERROR;
  *err = get_cc(dev, &major, &minor);
  if (*err != CUDA_SUCCESS) return GA_IMPL_ERROR;
  res = snprintf(ret, sz, "%s%d%d", prefix, major, minor);
  if (res == -1 || res > sz) return GA_UNSUPPORTED_ERROR;
  return GA_NO_ERROR;
}
Esempio n. 6
0
void do_M (void) {
    if (cilk_files) {
	/* Create dependencies for cilk programs . */
	MY_ARGV ma = make_my_argv();
	push_stringified_args(ma, get_cc());
	pusharg(ma, stop_at_m_arg);
	pusharg(ma, "-xc");
	pusharg(ma, "-include");
	pusharg(ma, CILK_H_LOCATION);
	{
	    PAIRLIST cf;
	    for (cf=cilk_files; cf; cf=cf->rest) {
		assert(cf->b==0);
		pusharg(ma, cf->a);
	    }
	}
	pushargs(ma, cpp1_args);
	push_stringified_args(ma, CILKC_PTHREAD_CFLAGS);
	VERBOSE(2, pusharg(ma, "-v"));
	VERBOSE(1, print_my_argv(stderr, ma, 0));
	if (my_system(ma, 0)!=0)
	    barf("creating dependencies for cilk files");
	free_my_argv(ma);
    }
    if (n_gcc_files>0) {
	MY_ARGV ma = make_my_argv();
	push_stringified_args(ma, get_cc());
	pusharg(ma, stop_at_m_arg);
	pushargs(ma, cc_args);
	push_stringified_args(ma, CILKC_PTHREAD_CFLAGS);
	VERBOSE(2, pusharg(ma, "-v"));
	VERBOSE(1, print_my_argv(stderr, ma, 0));
	if (my_system(ma, 0)!=0)
	    barf("creating dependencies for cilk files");
	free_my_argv(ma);
    }
}
Esempio n. 7
0
int main(void)
{
    //mfixed A,B,C,D;
    int i;
    int  fibov[N], fibot[N];
    fibot[0] = get_cc();
    for (i = 1; i < N; i++)
    {
        fibov[i] = fibo(i);fibot[i] = get_cc();
    }
    fibov [0]= get_cc();


    for (i = 1; i < 10; i++)
        printf(" Fibo %d : %d at %d\n",i,fibov[i],fibot[i]-fibot[i-1]);

    printf("End  time %d\n\n", fibov[0]);

    printf("Number of correct received requests: %d\n",*((volatile unsigned int*) WB_TARGET));
    printf("Number of correct received requests: %d\n",*((volatile unsigned int*) WB_TARGET));
    printf("\nSending write request to simple_slave...\n");
    *((volatile unsigned int*) WB_TARGET) = 123;
    printf("Number of correct received requests: %d\n",*((volatile unsigned int*) WB_TARGET));
    printf("\nSending write request to simple_slave...\n");
    *((volatile unsigned int*) WB_TARGET) = 123;
    printf("Number of correct received requests: %d\n",*((volatile unsigned int*) WB_TARGET));
    printf("Number of correct received requests: %d\n",*((volatile unsigned int*) WB_TARGET));
    printf("\nSending write request to simple_slave...\n");
    *((volatile unsigned int*) WB_TARGET) = 123;
    printf("Number of correct received requests: %d\n",*((volatile unsigned int*) WB_TARGET));

    printf("\nDone.\n");

    getchar();
    return 0;
}
Esempio n. 8
0
u8 ITC_GetCPUCC(void)
{
#ifdef _COSMIC_
    _asm("push cc");
    _asm("pop a");
    return; /* Ignore compiler warning, the returned value is in A register */
#endif

#ifdef __SDCC_stm8
	return get_cc();
#endif
    
#ifdef _RAISONANCE_
    return _getCC_();
#endif

#ifdef _IAR_SYSTEMS_
    __asm("push cc");
    __asm("pop a");
#endif
}
Esempio n. 9
0
void do_cpp1(void) {
    PAIRLIST cf;
    for (cf=cilk_files; cf; cf=cf->rest) {
	MY_ARGV ma = make_my_argv();
	push_stringified_args(ma, get_cc());
	pusharg(ma, "-E");
	pusharg(ma, "-xc");
	pusharg(ma, "-include");
	pusharg(ma, CILK_H_LOCATION);
	pusharg(ma, cf->a);

	assert(cf->b);
	pushargs(ma, cpp1_args);

	push_stringified_args(ma, CILKC_PTHREAD_CFLAGS);
	VERBOSE(2, pusharg(ma, "-v"));
	VERBOSE(1, print_my_argv(stderr, ma, cf->b));
	if (my_system(ma, cf->b)!=0)  barf("failed running cpp1");
	free_my_argv(ma);
    }
}
Esempio n. 10
0
void do_cpp2(void) {
    PAIRLIST cf;
    for (cf=cilkc_files; cf; cf=cf->rest) {
	MY_ARGV ma = make_my_argv();
	push_stringified_args(ma, get_cc());
	pusharg(ma, "-E");
	pusharg(ma, "-I" CILKHEADER_DIR);
#       ifdef CILK_RTSBUILD_DIR
	pusharg(cpp1_args, "-I" CILK_RTSBUILD_DIR );
#       endif
	pusharg(ma, "-D_REENTRANT");
	pusharg(ma, "-x");
	pusharg(ma, "c");
	pusharg(ma, cf->a);
	assert(cf->b);

	push_stringified_args(ma, CILKC_PTHREAD_CFLAGS);
	VERBOSE(2, pusharg(ma, "-v"));
	VERBOSE(1,print_my_argv(stderr, ma, cf->b));
	if (my_system(ma, cf->b)!=0) barf("failed running cpp2");
	free_my_argv(ma);
    }
}
Esempio n. 11
0
int cyclic_shift_cs(CS *d, int sign, const struct cyclic_work *w) {

    CC tmp_cc;
    tmp_cc.nharm = d->nharm;
    tmp_cc.npol = d->npol;
    tmp_cc.nlag = d->nchan;
    cyclic_alloc_cc(&tmp_cc);

    const double dtau = 1.0 / (d->bw*1e6);  // lag step, in seconds
    const double dalpha = d->ref_freq;  // harmonic step in Hz

    /* Move to cc domain */
    cyclic_cs2cc(d, &tmp_cc, w);

    /* Multiply by shift function */
    int iharm, ilag, ipol;
    for (ilag=0; ilag<tmp_cc.nlag; ilag++) {
        for (iharm=0; iharm<tmp_cc.nharm; iharm++) {
            // TODO check sign
            int lag = (ilag<=tmp_cc.nlag/2) ? ilag : ilag-tmp_cc.nlag;
            double phs = 2.0*M_PI*(dalpha*(double)iharm/2.0) * 
                (dtau*(double)lag);
            fftwf_complex fac = (cos(phs)+I*sin(phs))/(float)w->nchan;
            if (sign<0) fac = conj(fac);
            for (ipol=0; ipol<tmp_cc.npol; ipol++) {
                fftwf_complex *dat = get_cc(&tmp_cc,iharm,ipol,ilag);
                *dat *= fac;
            }
        } 
    }

    /* Back to orig domain */
    cyclic_cc2cs(&tmp_cc, d, w);

    cyclic_free_cc(&tmp_cc);
    return(0);
}
Esempio n. 12
0
void do_cc(void) {
    if (i_files) {
	PAIRLIST pl;
	/* The i_files variable was only filled in if we are stoping after -S or -c */
	assert(stop_at==STOP_AT_S || stop_at==STOP_AT_O);
	for (pl=i_files; pl; pl=pl->rest) {
	    MY_ARGV ma = make_my_argv();
	    push_stringified_args(ma, get_cc());
	    pusharg(ma, pl->a);
	    pusharg(ma, "-o");
	    pusharg(ma, pl->b);
	    pushargs(ma, cc_early_args);
	    if (stop_at==STOP_AT_S) pusharg(ma, "-S");
	    else if (stop_at==STOP_AT_O) pusharg(ma, "-c");
	    else abort(); /* This cannot happen.  See the assert() above. */
	    push_stringified_args(ma, CILKC_PTHREAD_CFLAGS);
	    if (save_temps) pusharg(ma, "-save-temps");
	    VERBOSE(2, pusharg(ma, "-v"));
	    VERBOSE(1, print_my_argv(stderr, ma, 0));
	    if (my_system(ma, 0)!=0) barf("failed running the final %s to produce %s", get_cc(), pl->b);
	    free_my_argv(ma);
	}
    }
    if (n_gcc_files>0) {
	MY_ARGV ma = make_my_argv();
	push_stringified_args(ma, get_cc());
	switch (stop_at) {
	case STOP_AT_M:     barf("I called final cc when I was supposed to do -M");
	case STOP_AT_CILKI:
	case STOP_AT_CILKC: barf("I called final cc when I was supposed to stop earlier");
	case STOP_AT_I: pusharg(ma, "-E"); break;
	case STOP_AT_S: pusharg(ma, "-S"); break;
	case STOP_AT_O: pusharg(ma, "-c"); break;
	case STOP_AT_END: break;
	}
	pushargs(ma, cc_args);
	if (stop_at==STOP_AT_END) {
	    pusharg(ma, "-L" LIBS_DIR);
	    pusharg(ma, "-L" LIBS2_DIR);
	    if (cilk_debug) {
	      if (cilk_profile) { pusharg(ma, "-lcilkrt0gp"); pusharg(ma, "-lcilk.g.p"); }
		else              { pusharg(ma, "-lcilkrt0g");  pusharg(ma, "-lcilk.g"); }
	    } else {
		if (cilk_profile) { pusharg(ma, "-lcilkrt0p");  pusharg(ma, "-lcilk.p"); }
		else              { pusharg(ma, "-lcilkrt0");   pusharg(ma, "-lcilk"); }
	    }
#           ifdef WITH_GNU_LD
	       pusharg(ma, "-Wl,-rpath," LIBS_DIR);
#           endif
	}
	push_stringified_args(ma, CILKC_PTHREAD_CFLAGS);
	push_stringified_args(ma, CILKC_PTHREAD_LIBS);
	if (output_name) {
	    pusharg(ma, "-o");
	    pusharg(ma, output_name);
	}
	VERBOSE(2, pusharg(ma, "-v"));
	VERBOSE(1, print_my_argv(stderr, ma, 0));
	if (my_system(ma, 0)!=0) barf("failed running the final %s", get_cc());
	free_my_argv(ma);
    }
}