Ejemplo n.º 1
0
  THREADABLE_FUNCTION_7ARG(compute_tensorial_density, complex*,dens, complex**,loc_dens, theory_pars_t*,tp, quad_su3 **,conf, int,dir, int,nhits, double,residue)
  {
    //allocate noise and solution
    color *rnd[2]={nissa_malloc("rnd_EVN",loc_volh+bord_volh,color),nissa_malloc("rnd_ODD",loc_volh+bord_volh,color)};
    color *chi[2]={nissa_malloc("chi_EVN",loc_volh+bord_volh,color),nissa_malloc("chi_ODD",loc_volh+bord_volh,color)};
    
    for(int iflav=0;iflav<tp->nflavs();iflav++)
      {
	if(tp->quarks[iflav].discretiz!=ferm_discretiz::ROOT_STAG) crash("not defined for non-staggered quarks");
	    
	//reset the local density
	vector_reset(loc_dens[iflav]);
	for(int ihit=0;ihit<nhits;ihit++)
	  {
	  }
	//final normalization and collapse
	double_vector_prod_double((double*)(loc_dens[iflav]),(double*)(loc_dens[iflav]),1.0/nhits,loc_vol*2);
	complex_vector_glb_collapse(dens[iflav],loc_dens[iflav],loc_vol);
      }
    
    //free
    for(int par=0;par<2;par++)
      {
	nissa_free(rnd[par]);
	nissa_free(chi[par]);
      }
  }
Ejemplo n.º 2
0
void* vector_remove_last(Vector vector){
    void* ret = NULL;
    vector_set_end(vector);
    ret = vector_remove_current(vector);
    vector_reset(vector);
    return ret;
}
Ejemplo n.º 3
0
void* vector_end(Vector vector){
    void* ret = NULL;
    void* tmp = NULL;

    while(tmp = vector_next(vector))
        ret = tmp;
    vector_reset(vector);
    return ret;
}
Ejemplo n.º 4
0
void kill_shell(){
    // mata todos os seus jobs e termina a execucao
    Job job;
    int pid;
    vector_reset(job_list);
    while((job = vector_next(job_list))){
        pid = string_to_int(job->pid);
        kill(pid, SIGKILL);
    }
    printf("\n");
    exit(0);
}
Ejemplo n.º 5
0
//handler para tratar CTRL + Z
static void ctrlz_hand(int signo, siginfo_t *info, void *data) {

    if(background == 0){
        vector_reset(job_list);
        Job job = (Job) vector_end(job_list);
        if(job){
            background = 1; 
            job->status = STOPPED;
            kill(-getpid(), SIGTSTP);
        }
    }
}
Ejemplo n.º 6
0
Archivo: Oauth.c Proyecto: bomma/io
static void init_signature_seed(struct signctx *senv, const char *reqMethod, const struct url_props *url)
{
	const char *e = url->path + url->pathLen, *p = url->path;

	string_reset(&senv->signatureParamsBuf);
	vector_reset(&senv->signatureParams);

	while (p != e && *p != '?')
		++p;
	
	if (p != e)
		append_signature_params(senv, p + 1, e);

	string_reset(&senv->signatureSeed);
	string_appendfmt(&senv->signatureSeed, "%s&%s%%3A%%2F%%2F%.*s", reqMethod, url->port == 443 ? "https": "http", url->hostNameLen, url->hostName);
	string_append_urlencoded_rfc3986(&senv->signatureSeed, url->path, p - url->path);
}
Ejemplo n.º 7
0
static void aztarac_process_vector_list()
{
	INT32 x, y, c, intensity, xoffset, yoffset, color;
	INT32 defaddr, objaddr, ndefs;

	vector_reset();

	for (objaddr = 0; objaddr < 0x800; objaddr++)
	{
		read_vectorram (objaddr * 2, &xoffset, &yoffset, &c);

		if (c & 0x4000)	break;

		if ((c & 0x2000) == 0)
		{
			defaddr = (c >> 1) & 0x7ff;

			vector_add_point((xcenter + (xoffset << 16)), (ycenter - (yoffset << 16)), 0, 0);

			read_vectorram (defaddr * 2, &x, &ndefs, &c);
			ndefs++;

			if (c & 0xff00)
			{
				intensity = (c >> 8);
				color = c & 0x3f;

				while (ndefs--)
				{
					defaddr++;
					read_vectorram (defaddr * 2, &x, &y, &c);

					if ((c & 0xff00) == 0)
						vector_add_point((xcenter + ((x + xoffset) << 16)), (ycenter - ((y + yoffset) << 16)), 0, 0);
					else
						vector_add_point((xcenter + ((x + xoffset) << 16)), (ycenter - ((y + yoffset) << 16)), color, intensity);
				}
			}
			else
			{
				while (ndefs--)
  THREADABLE_FUNCTION_END
  
  //same but with acceleration
  THREADABLE_FUNCTION_8ARG(evolve_momenta_and_FACC_momenta, quad_su3*,H, su3**,pi, quad_su3*,conf, su3**,phi, theory_pars_t*,theory_pars, pure_gauge_evol_pars_t*,simul, double,dt, quad_su3*,ext_F)
  {
    verbosity_lv2_master_printf("Evolving momenta and FACC momenta, dt=%lg\n",dt);
    
    quad_su3 *F=(ext_F==NULL)?nissa_malloc("F",loc_vol,quad_su3):ext_F;
    
#ifdef DEBUG
    vector_reset(F);
    double eps=1e-5;
    
    //store initial link and compute action
    su3 sto;
    su3_copy(sto,conf[0][0]);
    double act_ori=pure_gauge_action(conf,*theory_pars,*simul,H,phi,pi);
    
    //store derivative
    su3 nu_plus,nu_minus;
    su3_put_to_zero(nu_plus);
    su3_put_to_zero(nu_minus);
    
    for(int igen=0;igen<NCOL*NCOL-1;igen++)
      {
	//prepare increment and change
	su3 ba;
	su3_prod_double(ba,gell_mann_matr[igen],eps/2);
	
	su3 exp_mod;
	safe_hermitian_exact_i_exponentiate(exp_mod,ba);
	
	//change -, compute action
	unsafe_su3_dag_prod_su3(conf[0][0],exp_mod,sto);
	double act_minus=pure_gauge_action(conf,*theory_pars,*simul,H,phi,pi);
	
	//change +, compute action
	unsafe_su3_prod_su3(conf[0][0],exp_mod,sto);
	double act_plus=pure_gauge_action(conf,*theory_pars,*simul,H,phi,pi);
	
	//set back everything
	su3_copy(conf[0][0],sto);
	
	//printf("plus: %+016.016le, ori: %+016.016le, minus: %+016.016le, eps: %lg\n",act_plus,act_ori,act_minus,eps);
	double gr_plus=-(act_plus-act_ori)/eps;
	double gr_minus=-(act_ori-act_minus)/eps;
	su3_summ_the_prod_idouble(nu_plus,gell_mann_matr[igen],gr_plus);
	su3_summ_the_prod_idouble(nu_minus,gell_mann_matr[igen],gr_minus);
      }
    
    //take the average
    su3 nu;
    su3_summ(nu,nu_plus,nu_minus);
    su3_prodassign_double(nu,0.5);
    
    vector_reset(F);
#endif
    
    //compute the various contribution to the QCD force
    if(evolve_SU3)
      {
	//compute without TA
	vector_reset(F);
	compute_gluonic_force_lx_conf_do_not_finish(F,conf,theory_pars);
	summ_the_MFACC_momenta_QCD_force(F,conf,simul->kappa,pi,simul->naux_fields);
	summ_the_MFACC_QCD_momenta_QCD_force(F,conf,simul->kappa,100000,simul->residue,H);
	
	//finish the calculation
	gluonic_force_finish_computation(F,conf);
	
	evolve_lx_momenta_with_force(H,F,dt);
      }
    
#ifdef DEBUG
    master_printf("checking TOTAL gauge force\n");
    master_printf("an\n");
    su3_print(F[0][0]);
    master_printf("nu\n");
    su3_print(nu);
    master_printf("nu_plus\n");
    su3_print(nu_plus);
    master_printf("nu_minus\n");
    su3_print(nu_minus);
    //crash("anna");
#endif
    
    //evolve FACC momenta
    if(evolve_FACC) evolve_MFACC_momenta(pi,phi,simul->naux_fields,dt);
    
    if(ext_F==NULL) nissa_free(F);
  }
Ejemplo n.º 9
0
/* Parse the line. */
enum cparse_result
cparse(char *line, struct cnode *top, struct cparam *param, int exec) {
  uint32_t i;
  uint32_t j;
  char *arg;
  struct cnode *cnode;
  enum match_type current;

  struct vector *args;
  struct vector *matched;
  struct vector *candidate;
  struct vector *argv;

  /* Arguments, matched and candidate. */
  args = param->args;
  matched = param->matched;
  candidate = param->candidate;
  argv = param->argv;

  /* Lexical analysis. */
  clex(line, args);

  /* Set top candidate. */
  vector_reset(candidate);
  vector_append(candidate, top->v);

  /* Empty line. */
  if (vector_max(args) == 0) {
    return CPARSE_EMPTY_LINE;
  }

  /* Parse user input arguments. */
  for (i = 0; i < vector_max(args); i++) {
    /* Set current word to arg. */
    arg = vector_slot(args, i);

    /* Empty tail space. */
    if (strcmp(arg, "") == 0) {
      if (param->index > 0) {
        param->index--;
      }
      if (args->max > 0) {
        args->max--;
      }
      param->tail = 1;
      break;
    }

    /* Remember index. */
    param->index = i;

    /* Starting from no match. */
    current = NONE_MATCH;

    /* Rest matched vector. */
    vector_reset(matched);

    /* Match with schema. */
    for (j = 0; j < vector_max(candidate); j++) {
      enum match_type match = NONE_MATCH;

      cnode = vector_slot(candidate, j);

      if (exec == CPARSE_EXEC_MODE || exec == CPARSE_CONFIG_EXEC_MODE) {
        cnode_schema_match(cnode, arg, &match);
      }

      if (exec == CPARSE_CONFIG_MODE ||
          (exec == CPARSE_CONFIG_EXEC_MODE && match == NONE_MATCH)) {
        if (strcmp(arg, cnode->name) == 0) {
          match = KEYWORD_MATCH;
        }
      }

      if (match == NONE_MATCH) {
        continue;
      }

      if (match > current) {
        vector_reset(matched);
        current = match;
        vector_set(matched, cnode);
      } else if (match == current) {
        vector_set(matched, cnode);
      }

      if (CHECK_FLAG(cnode->flags, CNODE_FLAG_SET_NODE)) {
        SET32_FLAG(param->flags, CNODE_FLAG_SET_NODE);
      }

      if (CHECK_FLAG(cnode->flags, CNODE_FLAG_DELETE_NODE)) {
        SET32_FLAG(param->flags, CNODE_FLAG_DELETE_NODE);
      }
    }

    /* There is no match. */
    if (vector_max(matched) == 0) {
      break;
    }

    /* Update next level schema. */
    vector_reset(candidate);
    for (j = 0; j < vector_max(matched); j++) {
      cnode = vector_slot(matched, j);
      vector_append(candidate, cnode->v);
    }
  }

  /* Match result check. */
  if (vector_max(matched) == 0) {
    return CPARSE_NO_MATCH;
  } else if (vector_max(matched) > 1) {
    return CPARSE_AMBIGUOUS;
  }

  /* Parse success, set matched node. */
  param->exec = vector_first(matched);

  /* Return incomplete if the node is not leaf. */
  if (!cnode_is_leaf(param->exec)) {
    return CPARSE_INCOMPLETE;
  }

  /* Here we can build argc/argv.  This is only possible at this stage
   * since during parsing, we can't determine which node is actually
   * matched.  We allow user to abbreviate input so there could be
   * multiple candidate node during parsing.  */
  if (exec) {
    build_argv(param->exec, args, vector_max(args) - 1, argv);
  }

  /* Success. */
  return CPARSE_SUCCESS;
}
Ejemplo n.º 10
0
  //take also the TA
  THREADABLE_FUNCTION_3ARG(compute_gluonic_force_lx_conf, quad_su3*,F, quad_su3*,conf, theory_pars_t*,physics)
  {
    GET_THREAD_ID();
    
    START_TIMING(gluon_force_time,ngluon_force);
    
#ifdef DEBUG
    vector_reset(F);
    double eps=1e-5;
    
    //store initial link and compute action
    su3 sto;
    su3_copy(sto,conf[0][0]);
    double act_ori;
    gluonic_action(&act_ori,conf,physics->gauge_action_name,physics->beta);
    
    //store derivative
    su3 nu_plus,nu_minus;
    su3_put_to_zero(nu_plus);
    su3_put_to_zero(nu_minus);
    
    for(int igen=0;igen<NCOL*NCOL-1;igen++)
      {
	//prepare increment and change
	su3 ba;
	su3_prod_double(ba,gell_mann_matr[igen],eps/2);
	
	su3 exp_mod;
	safe_hermitian_exact_i_exponentiate(exp_mod,ba);
	
	//change -, compute action
	unsafe_su3_dag_prod_su3(conf[0][0],exp_mod,sto);
	double act_minus;
	gluonic_action(&act_minus,conf,physics->gauge_action_name,physics->beta);
	
	//change +, compute action
	unsafe_su3_prod_su3(conf[0][0],exp_mod,sto);
	double act_plus;
	gluonic_action(&act_plus,conf,physics->gauge_action_name,physics->beta);
	
	//set back everything
	su3_copy(conf[0][0],sto);
	
	//printf("plus: %+016.016le, ori: %+016.016le, minus: %+016.016le, eps: %lg\n",act_plus,act_ori,act_minus,eps);
	double gr_plus=-(act_plus-act_ori)/eps;
	double gr_minus=-(act_ori-act_minus)/eps;
	su3_summ_the_prod_idouble(nu_plus,gell_mann_matr[igen],gr_plus);
	su3_summ_the_prod_idouble(nu_minus,gell_mann_matr[igen],gr_minus);
      }
    
    //take the average
    su3 nu;
    su3_summ(nu,nu_plus,nu_minus);
    su3_prodassign_double(nu,0.5);
    
    vector_reset(F);
#endif
    
    compute_gluonic_force_lx_conf_do_not_finish(F,conf,physics);
    
    //finish the calculation
    gluonic_force_finish_computation(F,conf);
    
#ifdef DEBUG
    master_printf("checking pure gauge force\n");
    master_printf("an\n");
    su3_print(F[0][0]);
    master_printf("nu\n");
    su3_print(nu);
    master_printf("nu_plus\n");
    su3_print(nu_plus);
    master_printf("nu_minus\n");
    su3_print(nu_minus);
    //crash("anna");
#endif
    
    //print the intensity of the force
    if(VERBOSITY_LV2)
      {
	double norm=0;
	norm+=double_vector_glb_norm2(F,loc_vol);
	master_printf("  Gluonic force average norm: %lg\n",sqrt(norm/glb_vol));
      }
    
    STOP_TIMING(gluon_force_time);
  }