Example #1
0
/* SETUP ROUTINES */
static int initial_set(){
  int prompt,status;
#ifdef FIX_NODE_GEOM
  int i;
#endif
  /* On node zero, read lattice size and send to others */
  if(mynode()==0){
    /* print banner */
    printf("SU3 clover, staggered and naive valence fermions\n");
    printf("MIMD version %s\n",MILC_CODE_VERSION);
    printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());
    gethostname(hostname, 128);
    printf("Host(0) = %s\n",hostname);
    printf("Username = %s\n", getenv("USER"));
    time_stamp("start");
    
    status = get_prompt(stdin,  &prompt );
    
    IF_OK status += get_i(stdin,prompt,"nx", &param.nx );
    IF_OK status += get_i(stdin,prompt,"ny", &param.ny );
    IF_OK status += get_i(stdin,prompt,"nz", &param.nz );
    IF_OK status += get_i(stdin,prompt,"nt", &param.nt );
#ifdef FIX_NODE_GEOM
    IF_OK status += get_vi(stdin, prompt, "node_geometry", 
			   param.node_geometry, 4);
#ifdef FIX_IONODE_GEOM
    IF_OK status += get_vi(stdin, prompt, "ionode_geometry", 
			   param.ionode_geometry, 4);
#endif
#endif
    IF_OK status += get_s(stdin, prompt,"job_id",param.job_id);
    
    if(status>0) param.stopflag=1; else param.stopflag=0;
  } /* end if(mynode()==0) */

  /* Node 0 broadcasts parameter buffer to all other nodes */
  broadcast_bytes((char *)&param,sizeof(param));

  if( param.stopflag != 0 )
    normal_exit(0);

  nx=param.nx;
  ny=param.ny;
  nz=param.nz;
  nt=param.nt;
  iseed=param.iseed;
#ifdef FIX_NODE_GEOM
  for(i = 0; i < 4; i++)
    node_geometry[i] = param.node_geometry[i];
#ifdef FIX_IONODE_GEOM
  for(i = 0; i < 4; i++)
    ionode_geometry[i] = param.ionode_geometry[i];
#endif
#endif
  
  this_node = mynode();
  number_of_nodes = numnodes();
  volume=nx*ny*nz*nt;
  return(prompt);
}
Example #2
0
void sumtrian(int rows){
	int a[rows];
	int b[rows];
	int *old;
	old = a;
	int *curr;
	curr = b;
	old[0] = 0;
	int i = 0;
	int n;
	while(i<rows){
		int j = 1;
		n = get_i();curr[0] = old[0] + n;
		if(i){
			while(j<i){n = get_i(); curr[j] = n + max(old[j], old[j-1]);j++;}
			n = get_i();
			curr[j] = old[j-1] + n;
		}
		if(old == a){old = b; curr = a;}
		else {old = a; curr =b;}
		i++;
	}
	int mx = 0;
	for (i=0; i<rows; i++){
//		mx = max(mx, old[i]);
		if(old[i] > mx){mx = old[i]; }
//		printf("max value changing  = %d\n", mx);
	}
//	printf("max = %d\n", mx);
	put_i(mx);
	return;
}
Example #3
0
/* SETUP ROUTINES */
int initial_set(){
  int prompt,status;
  /* On node zero, read lattice size and send to others */
  if(mynode()==0){
    /* print banner */
    printf("SU3 Wilson valence fermion Schroedinger functional\n");
    printf("MIMD version 4\n");
    printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());
    
    status=get_prompt(stdin, &prompt);
  
    IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx );
    IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny );
    IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz );
    IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt );

    if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0;
  } /* end if(mynode()==0) */

  /* Node 0 broadcasts parameter buffer to all other nodes */
  broadcast_bytes((char *)&par_buf,sizeof(par_buf));

  if( par_buf.stopflag != 0 )
    normal_exit(0);

  nx=par_buf.nx;
  ny=par_buf.ny;
  nz=par_buf.nz;
  nt=par_buf.nt;

  this_node = mynode();
  number_of_nodes = numnodes();
  volume=nx*ny*nz*nt;
  return(prompt);
}
Example #4
0
/* SETUP ROUTINES */
int initial_set(){
int prompt,status;
    /* On node zero, read lattice size, seed, and send to others */
    if(mynode()==0){
	/* print banner */
	printf("SU3 with improved KS action\n");
	printf("Eigenvalues and eigenvectors\n");
	printf("MIMD version 6\n");
	printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());

	gethostname(hostname, 128);
	printf("Host(0) = %s\n",hostname);
	printf("Username = %s\n", getenv("USER"));
	time_stamp("start");
	get_utc_datetime(utc_date_time);
	
	/* Print list of options selected */
	node0_printf("Options selected...\n");
	show_generic_opts();
	show_generic_ks_opts();
	
#if FERM_ACTION == HISQ
	show_su3_mat_opts();
	show_hisq_links_opts();
#elif FERM_ACTION == HYPISQ
	show_su3_mat_opts();
	show_hypisq_links_opts();
#endif

	status=get_prompt(stdin, &prompt);

	IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx );
	IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny );
	IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz );
	IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt );
	IF_OK status += get_i(stdin, prompt,"iseed", &par_buf.iseed );

	if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0;
    } /* end if(mynode()==0) */

    /* Node 0 broadcasts parameter buffer to all other nodes */
    broadcast_bytes((char *)&par_buf,sizeof(par_buf));

    if( par_buf.stopflag != 0 )
      normal_exit(0);

    nx=par_buf.nx;
    ny=par_buf.ny;
    nz=par_buf.nz;
    nt=par_buf.nt;
    iseed=par_buf.iseed;
    
    this_node = mynode();
    number_of_nodes = numnodes();
    volume=nx*ny*nz*nt;
    total_iters=0;
    return(prompt);
}
Example #5
0
int main(){
	int iter = 0;
	int rows = 0; //number of rows
	iter = get_i();
//	int p = get_i();
//	printf("get_i() = %d\n", p);
//	put_i(567);
	while(iter){
		rows = get_i();
		sumtrian(rows);
		iter--;
		rows = 0;
	}
	return 0;
}
Example #6
0
    integer_type Number::to_i() const
    {
        switch (type())
        {
        case Number::INTEGER:
            return get_i();

        case Number::FLOATING:
            return f_to_i();

        case Number::RATIONAL:
            return r_to_i();

#ifndef PMP_DISABLE_VECTOR
        case Number::VECTOR:
            if (empty())
                return 0;
            else
                return get_v()[0].to_i();
#endif

        default:
            assert(0);
            return 0;
        }
    }
Example #7
0
    std::string Number::str(unsigned precision) const
    {
        switch (type())
        {
        case Number::INTEGER:
            return get_i().str(precision);

        case Number::FLOATING:
            return get_f().str(precision);

        case Number::RATIONAL:
            return get_r().str();

#ifndef PMP_DISABLE_VECTOR
        case Number::VECTOR:
            {
                std::string s;
                if (!empty())
                {
                    s += get_v()[0].str(precision);
                    for (size_t i = 1; i < size(); ++i)
                    {
                        s += ", ";
                        s += get_v()[i].str(precision);
                    }
                }
                return s;
            }
#endif

        default:
            assert(0);
            return "";
        }
    }
Example #8
0
    bool Number::is_zero() const
    {
        switch (type())
        {
        case Number::INTEGER:
            return get_i().is_zero();

        case Number::FLOATING:
            return get_f().is_zero();

        case Number::RATIONAL:
            return get_r().is_zero();

#ifndef PMP_DISABLE_VECTOR
        case Number::VECTOR:
            for (size_t i = 0; i < size(); ++i)
            {
                if (!get_v()[i].is_zero())
                    return false;
            }
            return true;
#endif

        default:
            assert(0);
            return false;
        }
    }
Example #9
0
 void setup_a(const Oracle *oracl)
 {
     vertex vtx(oracl->new_algo(this));
     vtx.ascend();
     a_ = oracl->get_by(vtx)->a_ |
         (word_t(1) << get_i()->height());
 }
Example #10
0
/* SETUP ROUTINES */
int initial_set(){
int prompt,status;
    /* On node zero, read lattice size, seed, nflavors and send to others */
    if(mynode()==0){
        /* print banner */
        printf("Schroedinger functional for pure gauge SU3\n");
#ifdef RMD_ALGORITHM
        printf("Microcanonical simulation with refreshing\n");
#endif
#ifdef HMC_ALGORITHM
        printf("Microcanonical simulation with refreshing\n");
#endif
        printf("MIMD version 6\n");
        printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());
#ifdef HMC_ALGORITHM
        printf("Hybrid Monte Carlo algorithm\n");
#endif
#ifdef ORA_ALGORITHM
        printf("Overrelaxed/quasi-heat bath algorithm\n");
#endif
        status=get_prompt(stdin, &prompt);
	IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx );
	IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny );
	IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz );
	IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt );
	IF_OK status += get_i(stdin, prompt,"iseed", &par_buf.iseed );

	if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0;
    } /* end if(mynode()==0) */

    /* Node 0 broadcasts parameter buffer to all other nodes */
    broadcast_bytes((char *)&par_buf,sizeof(par_buf));

    if( par_buf.stopflag != 0 )
      normal_exit(0);

    nx=par_buf.nx;
    ny=par_buf.ny;
    nz=par_buf.nz;
    nt=par_buf.nt;
    iseed=par_buf.iseed;
    
    this_node = mynode();
    number_of_nodes = numnodes();
    volume=nx*ny*nz*nt;
    return(prompt);
}
Example #11
0
// -----------------------------------------------------------------
// On node zero, read and distribute lattice size and random number seed
int initial_set() {
  int prompt, status;
  if (mynode() == 0) {
    // Print banner
    printf("SU3 Kogut--Susskind eigenvalue calculation\n");
    printf("Machine = %s, with %d nodes\n", machine_type(), numnodes());
    printf("nHYP links, reading alpha_smear parameters from infile\n");
    printf("  IR_STAB = %.4g\n", (Real)IR_STAB);
    printf("  EPS_SQ = %.4g\n", (Real)EPS_SQ);
#ifdef NHYP_DEBUG
    printf("NHYP_DEBUG turned on\n");
#endif
#ifdef NO_UNIT_CHECK
    printf("NOT checking unitarity when loading lattice\n");
#endif
    time_stamp("start");
    status = get_prompt(stdin, &prompt);

    IF_OK status += get_i(stdin, prompt, "nx", &par_buf.nx);
    IF_OK status += get_i(stdin, prompt, "ny", &par_buf.ny);
    IF_OK status += get_i(stdin, prompt, "nz", &par_buf.nz);
    IF_OK status += get_i(stdin, prompt, "nt", &par_buf.nt);
    IF_OK status += get_i(stdin, prompt, "iseed", &par_buf.iseed);

    if (status > 0)
      par_buf.stopflag = 1;
    else
      par_buf.stopflag = 0;
  }

  // Broadcast parameter buffer from node 0 to all other nodes
  broadcast_bytes((char *)&par_buf, sizeof(par_buf));
  if (par_buf.stopflag != 0)
    normal_exit(0);

  nx = par_buf.nx;
  ny = par_buf.ny;
  nz = par_buf.nz;
  nt = par_buf.nt;
  iseed = par_buf.iseed;

  this_node = mynode();
  number_of_nodes = numnodes();
  volume = nx * ny * nz * nt;
  total_iters = 0;
  return(prompt);
}
Example #12
0
/*!
 *  \brief  範囲指定による順序付きリスト
 *  \param[in]  line      行番号
 *  \param[in]  arg_list  マクロ実引数リスト
 *  \param[in]  p_ctx     マクロコンテキスト
 *  \retval     マクロ返却値
 *  第1マクロ実引数で最初の値を、第2マクロ実引数で最後の値を指定する。
 *  { 最初の値, 最初の値 + 1, ... 最後の値 }
 *  となる順序付きリストを生成する。
 *  引数が正しくない場合は空値を返す。
 */
var_t bf_range( text_line const& line, std::vector< var_t > const& arg_list, context const* p_ctx )
{
    var_t result;
    if ( macro_processor::check_arity( line, arg_list.size(), 2, "RANGE" ) )
    {
        std::tr1::int64_t arg1( get_i( arg_list[0], p_ctx ) );
        std::tr1::int64_t arg2( get_i( arg_list[1], p_ctx ) );

        for ( ; arg1 <= arg2; ++arg1 )
        {
            element e;
            e.i = arg1;
            result.push_back( e );
        }
    }
    return result;
}
Example #13
0
/* Read in configuration specific parameters */
int
readin(int prompt)
{
  int status;

  /* On node zero, read parameters and send to all other nodes */
  if(this_node==0) {
    
    printf("\n\n");
    status=0;

    /* Identify the starting configuration */
    IF_OK status += ask_starting_lattice(stdin,  prompt, &(par_buf.startflag), 
                                         par_buf.startfile);

    /* Get flow parameters */
    IF_OK {
      /* Get flow description */
      if (prompt==1)
        printf("enter 'wilson' or 'symanzik'\n");
      scanf("%s", par_buf.flow_description);
      printf("%s\n", par_buf.flow_description);

      /* Check flow description and set staple flag */
      if( strcmp("wilson", par_buf.flow_description) == 0 ) {
        par_buf.stapleflag = WILSON;
        printf("set staple to wilson\n");
      }
      else if( strcmp("symanzik", par_buf.flow_description) == 0 ) {
        par_buf.stapleflag = SYMANZIK;
        printf("set staple to symanzik\n");
      }
      else {
        printf("Error: flow_description %s is invalid\n", 
               par_buf.flow_description);
        status++;
      }
    } /*end: flow_description IF_OK */

    IF_OK status += get_i(stdin, prompt, "exp_order", &par_buf.exp_order);
    IF_OK status += get_f(stdin, prompt, "stepsize", &par_buf.stepsize);
    IF_OK status += get_f(stdin, prompt, "stoptime", &par_buf.stoptime);

    /* Determine what to do with the final configuration */
    IF_OK status += ask_ending_lattice(stdin,  prompt, &(par_buf.saveflag), 
                                       par_buf.savefile );
    IF_OK status += ask_ildg_LFN(stdin, prompt, par_buf.saveflag, 
                                 par_buf.stringLFN );

    if( status > 0) 
      par_buf.stopflag=1; 
    else
      par_buf.stopflag=0;

  } /* end if(this_node==0) */
Example #14
0
REAL d_dem::getMeanValue(REAL x_from, REAL x_to, REAL y_from, REAL y_to) const {
	
	size_t i_from, i_to;
	size_t j_from, j_to;
	
	i_from = get_i(x_from);
	i_from = MAX(0, i_from);
	
	i_to   = get_i(x_to);
	i_to   = MIN(i_to, getCountX()-1);
	
	j_from = get_j(y_from);
	j_from = MAX(0, j_from);
	
	j_to   = get_j(y_to);
	j_to   = MIN(j_to, getCountY()-1);

	size_t NN = getCountX();

	size_t i,j;
	size_t cnt = 0;
	REAL sum_value = 0;
	REAL value;
	for (j = j_from; j <= j_to; j++) {
		for (i = i_from; i <= i_to; i++) {
		
			size_t pos = i + j*NN;
			value = (*coeff)(pos);
			if (value == this->undef_value)
				continue;
			sum_value += value;
			cnt++;
		};
	};

	if (cnt == 0)
		return this->undef_value;

	REAL res = sum_value/REAL(cnt);
	return res;

};
Example #15
0
/* read in parameters and coupling constants	*/
int readin(int prompt) {
  /* read in parameters for su3 monte carlo	*/
  /* argument "prompt" is 1 if prompts are to be given for input	*/
  
  int status, jflav;

  /* On node zero, read parameters and send to all other nodes */
  if(this_node==0){
    
    printf("\n\n");
    status=0;

    IF_OK status += get_i(stdin, prompt, "number_of_random_sources",
			  &param.nrand);

   if(param.nrand < 2){
      fprintf(stderr, "ERROR: need more than 1 random source to compute correlations\n");
      status++;
    }

    IF_OK status += get_i(stdin, prompt, "number_of_flavors",
			  &param.nflav);

    for(jflav = 0; jflav < param.nflav; jflav++){
      IF_OK status += get_f(stdin, prompt, "charge", &param.charges[jflav]);
      IF_OK status += get_s(stdin, prompt, "file", param.fname[jflav]);
    }

    IF_OK status += get_s(stdin, prompt, "save_corr", param.corrfile);
    
    /* End of input fields */
    if( status > 0)param.stopflag=1; else param.stopflag=0;
  } /* end if(this_node==0) */
  
  
  broadcast_bytes((char *)&param,sizeof(param));

  if( param.stopflag != 0 )return param.stopflag;

  if(prompt==2)return 0;

} /* setup.c */
Example #16
0
/* SETUP ROUTINES */
int 
initial_set()
{
  int prompt, status;

  if(mynode()==0){
    /* print banner */
    printf("Wilson/Symanzik Flow application\n");
    printf("MIMD version 7\n");
    printf("Machine = %s, with %d nodes\n", machine_type(), numnodes());

    /* Read prompt type and lattice dimensions */
    status=get_prompt(stdin, &prompt);
    IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx );
    IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny );
    IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz );
    IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt );

    if(status>0) 
      par_buf.stopflag=1; 
    else 
      par_buf.stopflag=0;
  } /* end if(mynode()==0) */
  
  /* Node 0 broadcasts parameter buffer to all other nodes */
  broadcast_bytes((char *)&par_buf, sizeof(par_buf));
  
  if( par_buf.stopflag != 0 )
    normal_exit(0);
  
  /* Update global variables with parameters */
  nx=par_buf.nx;
  ny=par_buf.ny;
  nz=par_buf.nz;
  nt=par_buf.nt;
  
  this_node = mynode();
  number_of_nodes = numnodes();
  volume=nx*ny*nz*nt;
  
  return prompt;
}
Example #17
0
void
QtUtil :: Grid3DView :: paint (QPainter & p, int w, int h)
const
{
	const int SIZE = 2 * m_width + 1;

	// Background

	p .fillRect (0, 0, w, h, Qt :: gray);

	p .setWindow (QRect (0, SIZE, SIZE, -SIZE));

	for (int i = -m_width; i <= int (m_width); ++i)
	{
		for (int k = -m_width; k <= int (m_width); ++k)
		{
			int I = get_i (m_position) + i;
			int K = get_k (m_position) + k;

			const bool dark  = (0 == I % 10)  || (0 == K % 10);
			const bool light = (0 == I % 100) || (0 == K % 100);

			const auto & ODD  = dark ? BG_DARK_ODD  : BG_ODD;
			const auto & EVEN = dark ? BG_DARK_EVEN : BG_EVEN;

			p .fillRect (
				i + m_width,
				k + m_width,
				1,
				1,
				(I^K)&1
					? (light ? BG_LIGHT_ODD  : ODD)
					: (light ? BG_LIGHT_EVEN : EVEN));
		}
	}

	for (int i = -m_width; i <= int (m_width); ++i)
	{
		for (int k = -m_width; k <= int (m_width); ++k)
		{
			p .save ();

			p .translate (i + m_width, k + m_width);

			draw (p, m_position + to_global (i, k));

			p .restore ();
		}
	}

	draw_cursor (p, w, h);

	draw_axes (p, w, h);
}
Example #18
0
float PID::get_pid(float targetInput, float actualInput, float dt)
{
if (_active == DISABLED)
	return 0;

_error = targetInput - actualInput;
_p = get_p(_error);
_i = get_i(_error, dt);
_d = get_d(actualInput, dt);

return _p + _i + _d;			//, -_outLimit._value, _outLimit._value);
}
Example #19
0
/*-----------------------------------------------------------------------------*
| Bit2_map_col_major
|       Purpose:   maps the given function onto every element of the given Bit2 
|                  in col major order
|       Arguments: a pointer to the 2D bit array, a pointer to a void apply 
|                  function, the closure as a void *
|       Returns:   -
|       Fail cases:
|               - the pointer to the 2D bit array is null
|               - the pointer to the apply function is null
*-----------------------------------------------------------------------------*/
void Bit2_map_col_major(Bit2_T bit2, void apply(int i, int j, Bit2_T bit2, 
                        int value, void *cl), void *cl) {
        assert(bit2 != NULL);
        assert(apply != NULL);
        int index;
        int i;
        int j;
        for (index = 0; index < Bit_length(bit2->bitmap); index++) {
                i = get_i(index, Bit2_height(bit2));
                j = get_j(index, Bit2_height(bit2));
                apply(i, j, bit2, Bit2_get(bit2, i, j), cl);
        }
}
Example #20
0
/* SETUP ROUTINES */
int initial_set(){
int prompt,status;
    /* On node zero, read lattice size, seed, and send to others */
    if(mynode()==0){
	/* print banner */
	printf("U1 with improved KS action\n");
	printf("Eigenvalues and eigenvectors\n");
	printf("MIMD version 6\n");
	printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());

	status=get_prompt(stdin, &prompt);

	IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx );
	IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny );
	IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz );
	IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt );
	IF_OK status += get_i(stdin, prompt,"iseed", &par_buf.iseed );

	if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0;
    } /* end if(mynode()==0) */

    /* Node 0 broadcasts parameter buffer to all other nodes */
    broadcast_bytes((char *)&par_buf,sizeof(par_buf));

    if( par_buf.stopflag != 0 )
      normal_exit(0);

    nx=par_buf.nx;
    ny=par_buf.ny;
    nz=par_buf.nz;
    nt=par_buf.nt;
    iseed=par_buf.iseed;
    
    this_node = mynode();
    number_of_nodes = numnodes();
    volume=nx*ny*nz*nt;
    total_iters=0;
    return(prompt);
}
Example #21
0
/* SETUP ROUTINES */
int initial_set() {
    int prompt,status;
    /* On node zero, read lattice size, seed, nflavors and send to others */
    if(mynode()==0) {
        /* print banner */
        printf("SU3 with Wilson fermions\n");
        printf("Microcanonical simulation with refreshing\n");
        printf("MIMD version 6\n");
        printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());
#ifdef HMC_ALGORITHM
        printf("Hybrid Monte Carlo algorithm\n");
#endif
#ifdef PHI_ALGORITHM
        printf("PHI algorithm\n");
#else
        printf("R algorithm\n");
#endif
#ifdef SPECTRUM
        printf("With spectrum measurements\n");
#endif
        time_stamp("start");
        status = get_prompt(stdin, &prompt);
        IF_OK status += get_i(stdin,  prompt, "nflavors", &par_buf.nflavors );
#ifdef PHI_ALGORITHM
        if( par_buf.nflavors != 2) {
            printf("Dummy! Use phi algorithm only for two flavors\n");
            terminate(-1);
        }
#endif
        IF_OK status += get_i(stdin,  prompt, "nx", &par_buf.nx );
        IF_OK status += get_i(stdin,  prompt, "ny", &par_buf.ny );
        IF_OK status += get_i(stdin,  prompt, "nz", &par_buf.nz );
        IF_OK status += get_i(stdin,  prompt, "nt", &par_buf.nt );
        IF_OK status += get_i(stdin,  prompt, "iseed", &par_buf.iseed );
        if(status>0) par_buf.stopflag=1;
        else par_buf.stopflag=0;

    } /* end if(mynode()==0) */

    /* Node 0 broadcasts parameter buffer to all other nodes */
    broadcast_bytes((char *)&par_buf,sizeof(par_buf));

    if( par_buf.stopflag != 0 )
        normal_exit(0);


    nx=par_buf.nx;
    ny=par_buf.ny;
    nz=par_buf.nz;
    nt=par_buf.nt;
    iseed=par_buf.iseed;
    nflavors=par_buf.nflavors;

    this_node = mynode();
    number_of_nodes = numnodes();
    volume=nx*ny*nz*nt;
    total_iters=0;
    return(prompt);
}
Example #22
0
/*-----------------------------------------------------------------------------*
| UArray2_map_col_major
|       Purpose:   maps the given function onto every element of the given 
|                  UArray2 in col major order
|       Arguments: a pointer to the 2D array, a pointer to a void apply 
|                  function, the closure as a void *
|       Returns:   -
|       Fail cases:
|               - the pointer to the 2D array is null
|               - the pointer to the apply function is null
*-----------------------------------------------------------------------------*/
void UArray2_map_col_major(UArray2_T uarray2, void apply(int i, int j, 
                           UArray2_T uarray2, void *value, void *cl), 
                           void *cl) {
        assert(uarray2 != NULL);
        assert(apply != NULL);
        int index;
        int i;
        int j;
        for (index = 0; index < UArray_length(uarray2->uarray); index ++) {
                i = get_i(index, UArray2_height(uarray2));
                j = get_j(index, UArray2_height(uarray2));
                apply(i, j, uarray2, UArray2_at(uarray2, i, j), cl);
        };
}
Example #23
0
/* SETUP ROUTINES */
int initial_set(){
  int prompt,status;
  /* On node zero, read lattice size, seed, and send to others */
  if(mynode()==0){
    /* print banner */
    printf("Heavy-light spectroscpy with Kogut-Susskind light fermions\n");
    printf("MIMD version 7\n");
    printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());
    time_stamp("start");
    status = get_prompt(stdin,  &prompt );
    IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx );
    IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny );
    IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz );
    IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt );
    IF_OK status += get_s(stdin, prompt,"job_id",par_buf.job_id);
    
    if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0;
  } /* end if(mynode()==0) */
  
  /* Node 0 broadcasts parameter buffer to all other nodes */
  broadcast_bytes((char *)&par_buf,sizeof(par_buf));
  
  if( par_buf.stopflag != 0 )
    normal_exit(0);
  
  nx=par_buf.nx;
  ny=par_buf.ny;
  nz=par_buf.nz;
  nt=par_buf.nt;
  strcpy(job_id,par_buf.job_id);
  
  this_node = mynode();
  number_of_nodes = numnodes();
  volume=nx*ny*nz*nt;
  total_iters=0;
  return(prompt);
}
Example #24
0
/* SETUP ROUTINES */
int initial_set(void)
{
   int prompt,status;
   /* On node zero, read lattice size, seed, nflavors and send to others */
   if(mynode()==0)
   {
      /* print banner */
      printf("SU3 Smoothing for Instantons\n");
      printf("MIMD version 7\n");
      printf("Machine = %s, with %d nodes\n", machine_type(), numnodes());
      time_stamp("start");
      status=get_prompt(stdin, &prompt);
      IF_OK status += get_i(stdin,  prompt,"nx", &par_buf.nx );
      IF_OK status += get_i(stdin,  prompt,"ny", &par_buf.ny );
      IF_OK status += get_i(stdin,  prompt,"nz", &par_buf.nz );
      IF_OK status += get_i(stdin,  prompt,"nt", &par_buf.nt );

      if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0;
   } /* end if(mynode()==0) */

   /* Node 0 broadcasts parameter buffer to all other nodes */
   broadcast_bytes((char *)&par_buf, sizeof(par_buf));

   if( par_buf.stopflag != 0 )
       normal_exit(0);

   nx=par_buf.nx;
   ny=par_buf.ny;
   nz=par_buf.nz;
   nt=par_buf.nt;

   this_node = mynode();
   number_of_nodes = numnodes();
   volume=nx*ny*nz*nt;
   return prompt;
}
Example #25
0
// returns the masking effect of the noise (non-tonal) components around u, 
// I_Nu
double get_noise_mask(double *amp_dB, int *tonal_indices, int num_tonal, int u)
{ //{{{
	// Sum all the frequency components within .5 barks of u, skipping the five
	// central samples of each tonal component (if i is tonal, no i-2...i+2)
	double u_hz = get_freq(u);
	double u_bark = hz_to_bark(u_hz);
	double cb_width = cb_limits[(int)(u_bark+1)]; // upper bound on freq width

	int lo = get_i(u_hz - (cb_width/2));
	while(u_bark - hz_to_bark(get_freq(lo)) > .5) lo++;

	int hi = get_i(u_hz + (cb_width/2));
	while(hz_to_bark(get_freq(hi)) - u_bark > .5) hi--;

	int i_i = 0;
	double sum = 0;
	for(int i = lo; i <= hi; i++){
		// ensure tonal_indices[i_i] >= i-2 now
		while(i+i < num_tonal && tonal_indices[i_i] < i-2){
			i_i++;
		}

		// no tonal components above i-2
		if(i_i >= num_tonal){
			sum += amp_dB[i];
			continue;
		}

		if(tonal_indices[i_i] > i+2){
			sum += amp_dB[i];
		}
		// otherwise tonal_indices[i_i] <= i+2, and we're in a tonal component
	}

	return sum;
} //}}}
Example #26
0
/*!
 *  \brief  値の生成
 *  \param[in]  line      行番号
 *  \param[in]  arg_list  マクロ実引数リスト
 *  \param[in]  p_ctx     マクロコンテキスト
 *  \retval     マクロ返却値
 *  第1マクロ実引数をテキスト、第2マクロ実引数を数値として、値を生成する。
 */
var_t bf_value( text_line const& line, std::vector< var_t > const& arg_list, context const* p_ctx )
{
    element e;
    if ( macro_processor::check_arity( line, arg_list.size(), 2, "VALUE" ) )
    {
        if ( !arg_list[0].empty() )
        {
            e.s = get_s( arg_list[0], p_ctx );
        }
        if ( !arg_list[1].empty() )
        {
            e.i = get_i( arg_list[1], p_ctx );
        }
    }
    return var_t( 1, e );
}
Example #27
0
/*!
 *  \brief  順序リストの指定要素の参照
 *  \param[in]  line      行番号
 *  \param[in]  arg_list  マクロ実引数リスト
 *  \param[in]  p_ctx     マクロコンテキスト
 *  \retval     マクロ返却値
 *  第1マクロ実引数で指定した順序リストの、第2マクロ実引数で指定した要素を返す。
 */
var_t bf_at( text_line const& line, std::vector< var_t > const& arg_list, context const* p_ctx )
{
    element e;
    if ( macro_processor::check_arity( line, arg_list.size(), 2, "CAT" ) )
    {
        try
        {
            e = arg_list[0].at( static_cast< std::vector< var_t >::size_type >( get_i( arg_list[1], p_ctx ) ) );
        }
        catch ( std::out_of_range& )
        {
            // 添え字が不正
            // 特に何もしない → この時点で e が空値であることを期待
        }
    }
    return var_t( 1, e );
}
Example #28
0
    int Number::sign() const
    {
        switch (type())
        {
        case Number::INTEGER:
            return get_i().sign();

        case Number::FLOATING:
            return get_f().sign();;

        case Number::RATIONAL:
            return get_r().sign();

        default:
            assert(0);
            return 0;
        }
    }
    /*!
     *  \brief  指定した連想配列群に静的APIを追加する
     *  \param[in]  line      行番号
     *  \param[in]  arg_list  マクロ実引数リスト
     *  \param[in]  p_ctx     マクロコンテキスト
     *  \retval     マクロ返却値
     *  API.で始まる連想配列群を、必要に応じて適切に変換を行った上で、別のプレフィックスで始まる
     *  連想配列群に追加する。想定する使用方法としては、特定のソフトウェア部品で理解可能な静的API
     *  に関しては、追加を行わないか、他の静的APIに置き換えて追加を行う。理解できない静的APIに関して
     *  はそのまま追加を行う。
     *  この関数の第一引数にはAPI.で始まる連想配列の連番を、第二引数には追加先に連想配列群の
     *  プレフィックスを、第三引数には対象とする静的API名を、第四引数には追加するパラメータシンボルの
     *  並びを、第五引数にはパラメータの並びを指定する。     
     */
    var_t bf_addapi( text_line const& line, std::vector< var_t > const& arg_list, context* p_ctx )
    {
      element e;
      if ( macro_processor::check_arity( line, arg_list.size(), 5, "ADDAPI" ) )
      {
        itronx::factory* factory = get_global< itronx::factory* >( "factory" );
        std::map< std::string, itronx::static_api::info > const* info_map = factory->get_static_api_info_map();

        std::tr1::int64_t order = get_i( arg_list[ 0 ], p_ctx );  // 元の静的APIの連番
        std::string list_name = get_s( arg_list[ 1 ], p_ctx );    // 出力先リストの識別名
        std::string api_name = get_s( arg_list[ 2 ], p_ctx );     // 静的API名
        var_t params = arg_list[ 3 ]; // パラメータシンボルの並び
        var_t args = arg_list[ 4 ];   // パラメータの並び

        std::map< std::string, itronx::static_api::info >::const_iterator it = info_map->find( api_name );
        if ( it != info_map->end() )
        {
          itronx::static_api::info info = it->second;
          std::string str_order = boost::lexical_cast< std::string >( order );
          p_ctx->var_map[ list_name + ".TEXT_LINE[" + str_order + "]" ] = p_ctx->var_map[ "API.TEXT_LINE[" + str_order + "]" ]; 
          e.s = api_name;
          p_ctx->var_map[ list_name + ".NAME[" + str_order + "]" ] = var_t( 1, e );
          e.s = info.type;
          p_ctx->var_map[ list_name + ".TYPE[" + str_order + "]" ] = var_t( 1, e );
          p_ctx->var_map[ list_name + ".PARAMS[" + str_order + "]" ] = params;
          p_ctx->var_map[ list_name + ".ARGS[" + str_order + "]" ] = args;

          e.s.clear();
          if ( !p_ctx->var_map[ list_name + ".ORDER_LIST" ].empty() )
          {
            e.i = *p_ctx->var_map[ list_name + ".ORDER_LIST" ].back().i + 1;
          }
          else
          {
            e.i = 1;
          }
          p_ctx->var_map[ list_name + ".ORDER_LIST" ].push_back( e );

          e.s.clear();
          e.i = 1;
        }
      }
      return var_t( 1, e );
    }
Example #30
0
/*!
 *  \brief  順序付きリスト内の探索
 *  \param[in]  line      行番号
 *  \param[in]  arg_list  マクロ実引数リスト
 *  \param[in]  p_ctx     マクロコンテキスト
 *  \retval     マクロ返却値
 *  第1マクロ実引数で指定した順序付きリストに含まれる第2マクロ実引数で指定した値に等しい要素を、
 *  先頭から順に探索する。
 *  等しい要素が見つかればその要素へのインデックスを、そうでなければ空値を返す。
 */
var_t bf_find( text_line const& line, std::vector< var_t > const& arg_list, context const* p_ctx )
{
    element e;
    if ( macro_processor::check_arity( line, arg_list.size(), 2, "FIND" ) )
    {
        var_t list( arg_list[0] );
        std::tr1::int64_t value( get_i( arg_list[1], p_ctx ) );

        for ( var_t::const_iterator iter( list.begin() ), last( list.end() ); iter != last; ++iter )
        {
            if ( iter->i.get() == value ) // 発見!
            {
                e.i = iter - list.begin();  // iter は RandomAccessIterator
                return var_t( 1, e );
            }
        }
    }
    return var_t();
}