예제 #1
0
파일: parser.c 프로젝트: palmerc/lab
int initializer_list(void) {
	if( initializer() ) {
	} else if( initializer_list() ) {
		match(COMMA);
		initializer();
	}
}
예제 #2
0
파일: main.cpp 프로젝트: CCJY/coliru
int main()
{
    using inner_vector = std::vector<std::uint8_t>;
    using initializer = std::initializer_list<inner_vector::value_type>;
    std::vector<std::shared_ptr<inner_vector>> R = {
        std::make_shared<inner_vector>(initializer({1, 2, 3})),
        std::make_shared<inner_vector>(initializer({4, 5, 6})),
    };
    
    std::cout << (int) R[0]->at(0) << " "         // checks boundaries
              << (int) R[0]->operator[](1) << " " // no boundary checking
              << (int) (*R[0])[2] << " "          // no boundary checking
              << std::endl;
}
예제 #3
0
파일: Opening.cpp 프로젝트: SouvickG/Chess
//assumes string length < 4*MAXMOVES
//calls movegenrator: must be freed
opening *algebraicopeningcreator(uint8_t *string) {
	opening *_opening=(opening *)malloc(sizeof(opening));
	uint8_t _position,__position,i=0,_count;
	uint32_t *move;
	initializer();
	Engine engine;
	while(string[i<<2]!='\0') {
		_position=__position=0;
		_position|=(string[i<<2|0]-'a');
		_position|=(string[i<<2|1]-'1')<<3;
		__position|=(string[i<<2|2]-'a');
		__position|=(string[i<<2|3]-'1')<<3;
		engine.piecepopulator();
		move=engine.movegenerator(_position,Squares[__position],_count);
		if(_count!=1) {
			free(move);
			free(_opening);
			engine.~Engine();
			return 0;
		}
		_opening->moves[i++]=move[0];
		engine.movemaker(move[0]);
		free(move);
	}
	for(;i<MAXMOVES;++i)
		_opening->moves[i]=0;
	for(i=0;i<MAXINFO;++i)
		_opening->info[i]=0;
	engine.~Engine();
	return _opening;
}
예제 #4
0
void CAipi_ExpParser::initializer_list()
{
	
	initializer();
	//getToken();
	//AfxMessageBox(_T("CLOSE BRACE"));

	//AfxMessageBox(_T("antes de coma"));
	//CString str;
	//str.Format(_T("Antes de coma Look Ahead...%d  " ), m_lookahead);
	//AfxMessageBox(str);
	
	
	if( m_lookahead == COMMA )
	{
		//AfxMessageBox(_T("Entro de coma"));
		while ( m_lookahead == COMMA )
		{
			//AfxMessageBox(_T("while coma"));
			getToken();
			initializer_list();
			
		}
	}

	
}
예제 #5
0
void up_cxxinitialize(void)
{
  initializer_t *initp;

  cxxdbg("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
         &_sinit, &_einit, &_stext, &_etext);

  /* Visit each entry in the initialzation table */

  for (initp = &_sinit; initp != &_einit; initp++)
    {
      initializer_t initializer = *initp;
      cxxdbg("initp: %p initializer: %p\n", initp, initializer);

      /* Make sure that the address is non-NULL and lies in the text region
       * defined by the linker script.  Some toolchains may put NULL values
       * or counts in the initialization table
       */

      if ((void*)initializer > (void*)&_stext && (void*)initializer < (void*)&_etext)
        {
          cxxdbg("Calling %p\n", initializer);
          initializer();
        }
    }
}
Application_Constraints::Application_Constraints()
   : equality_epsilon(),
     num_constraints()
{
   Privileged_Property _num_constraints
      ( &noop_set, 
        bind(&Application_Constraints::cb_get_num_constraints, this, _1, _2) );
   num_constraints = _num_constraints.set_readonly();

   Privileged_Property _equality_epsilon
      ( Property::Bind(std::numeric_limits<double>::epsilon() * 8.0) );
   equality_epsilon = _equality_epsilon;

   ObjectType type = ObjectType::get(this);
   register_application_component(type);
   properties.declare( "equality_epsilon", _equality_epsilon, type );
   properties.declare( "num_constraints", _num_constraints, type );


   request_expansion_signal.connect
      (boost::bind(&Application_Constraints::cb_expand_request, this, _1));
   request_transform_signal.connect
      (boost::bind(&Application_Constraints::cb_map_request, this, _1, _2));

   response_transform_signal.connect
      (boost::bind( &Application_Constraints::cb_map_response, this, 
                    _1, _2, _3, _4 ));

   initializer("Constraints").connect
      (boost::bind(&Application_Constraints::cb_initialize, this, _1));
}
예제 #7
0
int main() {
	int size, rank;
	MPI_Init(NULL, NULL);
	MPI_Comm_size(MPI_COMM_WORLD, &size);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	double startTime, endTime;
	startTime = MPI_Wtime();
	double *arrayA = (double *) malloc(sizeof(double) * 1000000);
	double *arrayB = (double *) malloc(sizeof(double) * 1000000);
	double pearsonCCoefficient = 0.0;
	long n = 1000000;
	double standardDeviationA, standardDeviationB;
	double meanA, meanB;
	initializer(arrayA, arrayB, n, &meanA, &meanB);
	standardDeviation(arrayA, arrayB, &standardDeviationA, &standardDeviationB,
			meanA, meanB, n);
	pearsonCoefficient(meanA, meanB, arrayA, arrayB, &pearsonCCoefficient,
			standardDeviationA, standardDeviationB, n);

	printf("Pearson Coefficient:%f\n", pearsonCCoefficient);
	endTime = MPI_Wtime();
	printf("Total Elapsed Time for Serial Version : %f \n",
			endTime - startTime);
//	system("pause");
}
예제 #8
0
IDevice* CDeviceList::AddDevice(voidinstancefunc InstanceFunction, const int ID, void* MainWindow)
{
    instancefunc initializer=(instancefunc)InstanceFunction;
    IDevice* D=initializer();
    D->Init(ID,MainWindow);
    return AddDevice(D);
}
예제 #9
0
/**
外部声明
<external_declaration>::=<type_specifier>(<TK_SEMICOLON>
                                         |<declarator><funcbody>
                                         |<declarator>[<TK_ASSIGN><initializer>]
                                         {TK_COMMA><declarator>[<TK_ASSIGN><initializer>]}<TK_SEMICOLON>
                                          )
DO:parse external statement
storage type:local | global
*/
void external_declaration(int l){
    if(!type_specifier())
        expect("<Type specifier>");
    if(token == TK_SEMICOLON){
        get_token();
        return;
    }
    while(1){
        declarator();
        if(token == TK_BEGIN){
            if(l == SC_LOCAL)
                error("don't support function nesting define");
            funcbody();
            break;
        }else {
            if(token == TK_ASSIGN){
                get_token();
                initializer();
            }
            if(token == TK_COMMA)
                get_token();
            else{
                syntax_state = SNTX_LF_HT;
                skip(TK_SEMICOLON);
                break;
            }
        }
    }
}
예제 #10
0
파일: parser.c 프로젝트: palmerc/lab
int init_declarator(void) {
	declarator();
	if( lookaheadT.type == EQUAL ) {
		match(EQUAL);
		initializer();
	}
}
예제 #11
0
int main() {
	int size, rank;
	double startTime, endTime;
	double *arrayA = (double *) malloc(sizeof(double) * 1000000);
	double *arrayB = (double *) malloc(sizeof(double) * 1000000);
	double pearsonCCoefficient = 0.0;
	long n = 1000000;

	double standardDeviationA, standardDeviationB;
	double meanA, meanB;
	// call to initializer function for initializing arrays with sin(i) and sin(i+1) values,
	//	and calculating mean for both the arrays
	initializer(arrayA, arrayB, n, &meanA, &meanB);
	// call to Standard Deviation function,with arrays and mean calculated previously
	standardDeviation(arrayA, arrayB, &standardDeviationA, &standardDeviationB,
			meanA, meanB, n);
	startTime = omp_get_wtime();
	// call to Pearson Correlation Coefficient with mean ,array and 
	//standard Deviation calculated previously
	pearsonCoefficient(meanA, meanB, arrayA, arrayB, &pearsonCCoefficient,
			standardDeviationA, standardDeviationB, n);
	;
	printf("Pearson Coefficient:%f\n", pearsonCCoefficient);
	endTime = omp_get_wtime();
	printf("Total Execution Time : \n %f Sec \n %f ms", endTime - startTime,
			(endTime - startTime) * 1000);
	printf("\n");
	return 0;
}
예제 #12
0
int main(void)
{
	char string[64];
	unsigned char count = 0;
	
	// run the initialization routines
	initializer();

   	 //Begin forever chatting with the PC
	 for(;;) 
	 {	
		// Check to see if a character is waiting
		if( isCharAvailable() == 1 )
		{
			// If a new character is received, get it
			string[count++] = receiveChar();
			
			// receive a packet up to 64 bytes long
			if(string[count-1] == '\n')// Hyperterminal string ends with \r\n
			{	
				string[count-2] = '\0'; //convert to a string
				parseInput(string);
				string[0] = '\0';
				count = 0;
			}
			else if(count > 64)
			{
				count = 0;
				string[0] = '\0';
				sendString("Error - received > 64 characters");			
			}		
		}
    }
	return 0;
}
예제 #13
0
void BrowserOperation::AddConstructorInitalizer()
{
    ConstructorInitializerDialog ciDialog;
    BrowserClass* container = static_cast<BrowserClass*>(get_container(UmlClass));
    QList<BrowserNode *> parents = container->parents();
    QString initializerDummy(" : ");
    for(BrowserNode* parent : parents)
    {
        BrowserClass* parentClass = static_cast<BrowserClass*>(parent);
        initializerDummy+=parentClass->get_name() + QString("(), ");
    }
    if(initializerDummy != " : ")
        initializerDummy.chop(2);

    QString constructorPrototype = static_cast<OperationData*>(this->get_data())->get_cppdef();

    QString constructorActual = TagManagers::Cpp::updated_def(static_cast<OperationData*>(this->get_data()));

    QString initializer(this->get_value("constructor-initializer"));
    if(initializer.trimmed().isEmpty())
        ciDialog.ui->edInitializer->setText(initializerDummy);
    else
        ciDialog.ui->edInitializer->setText(this->get_value("constructor-initializer"));
    ciDialog.ui->edConstructorPrototype->setText(constructorPrototype);
    ciDialog.ui->edActualConstructor->setText(constructorActual);
    ciDialog.Init(static_cast<OperationData*>(this->get_data()));
    ciDialog.resize(800, 400);
    if(ciDialog.exec() == QDialog::Accepted)
    {
        this->set_value("constructor-initializer", ciDialog.ui->edInitializer->toPlainText());
        this->modified();
        this->get_data()->get_browser_node()->modified();
        this->get_data()->get_browser_node()->package_modified();
    }
}
예제 #14
0
/**
	@brief 解析外部命令
	@param l 存储类型,局部的or全局的
*/
void external_declaration(int l){
	if(!type_specifier()){
		expect("<类型区分符>");
	}
	if(token == TK_SEMICOLON){
		get_token();
		return;
	}
	while(1){
		declarator();
		if(token == TK_BEGIN){
			if(l == SC_LOCAL){
				error("不支持函数嵌套定义");
			}
			funcbody();
			break;
		}else{
			if(token == TK_ASSIGN){
				get_token();
				initializer();
			}
			if(token == TK_COMMA){
				get_token();
			}else{
				syntax_state = SNTX_LE_HT;
				skip(TK_SEMICOLON);
				break;
			}
		}
	}
}
예제 #15
0
파일: irf.c 프로젝트: xcitech/Genesis.3.0
void	read_and_compress_data ()
 
{
 
	int   i, j, k;
 
	if (global_monitor)
		monitor_leaf(1, "read_and_compress_data");
/*
	printf("\n\n  IRF:  Initial Read Functions program \n\n\n");
*/
	initializer();

	if (input_files)
		initialize_pcv();

	initialize(1);
	read_climate_and_pc();
/*
	initialize(0);
	write_climate_and_pc();
 
	printf("\n\n  It is done !!!  \n\n\n ");
*/
	if (global_monitor)
		monitor_leaf(0, "read_and_compress_data");
 
}
예제 #16
0
void TCompiler::initializeGLPosition(TIntermNode* root)
{
    InitializeVariables::InitVariableInfoList variables;
    InitializeVariables::InitVariableInfo var(
        "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
    variables.push_back(var);
    InitializeVariables initializer(variables);
    root->traverse(&initializer);
}
예제 #17
0
void Matrix<double>::Initialize( double (*initializer)(size_t, size_t, size_t, size_t) )
{
    for (size_t r = 0; r < GetRowLength(); ++r)
    {
        for (size_t c = 0; c < GetColumnLength(); ++c)
        {
            (*this)[r][c] = initializer(r, GetRowLength(), c, GetColumnLength());
        }
    }
}
예제 #18
0
void initParms(SEXP Initfunc, SEXP Parms) {
  // ks: added this to prevent entering this if initfunc does not exist
  if (Initfunc == NA_STRING) return;
  if (inherits(Initfunc, "NativeSymbol"))  {
    init_func *initializer;

    PROTECT(bvp_gparms = Parms);     incr_N_Protect();
    initializer = (init_func *) R_ExternalPtrAddrFn_(Initfunc);
    initializer(Initbvpparms);
  }
}
template <> GA1DArrayAlleleGenome<char>::
GA1DArrayAlleleGenome(unsigned int length, const GAAlleleSet<char> & s,
		      GAGenome::Evaluator f, void * u) :
GA1DArrayGenome<char>(length, f, u){
  naset = 1;
  aset = new GAAlleleSet<char>[1];
  aset[0] = s;

  initializer(DEFAULT_STRING_INITIALIZER);
  mutator(DEFAULT_STRING_MUTATOR);
  comparator(DEFAULT_STRING_COMPARATOR);
  crossover(DEFAULT_STRING_CROSSOVER);
}
GA1DArrayAlleleGenome<T>::
GA1DArrayAlleleGenome(unsigned int length, const GAAlleleSet<T> & s,
                      GAGenome::Evaluator f, void * u) :
    GA1DArrayGenome<T>(length, f, u) {
    naset = 1;
    aset = new GAAlleleSet<T>[1];
    aset[0] = s;

    initializer(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_INITIALIZER);
    mutator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_MUTATOR);
    comparator(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_COMPARATOR);
    crossover(GA1DArrayAlleleGenome<T>::DEFAULT_1DARRAY_ALLELE_CROSSOVER);
}
예제 #21
0
GA1DArrayAlleleGenome<float>::
GA1DArrayAlleleGenome(unsigned int length, const GAAlleleSet<float> & s,
		      GAGenome::Evaluator f, void * u) :
GA1DArrayGenome<float>(length, f, u){
  naset = 1;
  aset = new GAAlleleSet<float>[1];
  aset[0] = s;

  initializer(DEFAULT_REAL_INITIALIZER);
  mutator(DEFAULT_REAL_MUTATOR);
  comparator(DEFAULT_REAL_COMPARATOR);
  crossover(DEFAULT_REAL_CROSSOVER);
}
예제 #22
0
extern void GPStartWhenGriPIsReady(void(*initializer)()) {
	CFMessagePortRef serverPort = CFMessagePortCreateRemote(NULL, CFSTR("hk.kennytm.GriP.server"));
	
	if (serverPort != NULL) {
		// GriP is already running. call the initializer directly.
		initializer();
		CFRelease(serverPort);
		
	} else {
		// GriP is not running. register for the notification and set the initializer as callback.
		CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), initializer, (CFNotificationCallback)&GPGriPIsReadyCallback, CFSTR("hk.kennytm.GriP.ready"), NULL, CFNotificationSuspensionBehaviorCoalesce);
	}
}
예제 #23
0
void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root)
{
    InitializeVariables::InitVariableInfoList variables;
    for (size_t ii = 0; ii < varyings.size(); ++ii)
    {
        const TVariableInfo& varying = varyings[ii];
        if (varying.staticUse)
            continue;
        unsigned char primarySize = 1, secondarySize = 1;
        switch (varying.type)
        {
          case SH_FLOAT:
            break;
          case SH_FLOAT_VEC2:
            primarySize = 2;
            break;
          case SH_FLOAT_VEC3:
            primarySize = 3;
            break;
          case SH_FLOAT_VEC4:
            primarySize = 4;
            break;
          case SH_FLOAT_MAT2:
            primarySize = 2;
            secondarySize = 2;
            break;
          case SH_FLOAT_MAT3:
            primarySize = 3;
            secondarySize = 3;
            break;
          case SH_FLOAT_MAT4:
            primarySize = 4;
            secondarySize = 4;
            break;
          default:
            ASSERT(false);
        }
        TType type(EbtFloat, EbpUndefined, EvqVaryingOut, primarySize, secondarySize, varying.isArray);
        TString name = varying.name.c_str();
        if (varying.isArray)
        {
            type.setArraySize(varying.size);
            name = name.substr(0, name.find_first_of('['));
        }

        InitializeVariables::InitVariableInfo var(name, type);
        variables.push_back(var);
    }
    InitializeVariables initializer(variables);
    root->traverse(&initializer);
}
예제 #24
0
			static typename fun_types_type::package_type const& package() {
				typedef typename fun_types_type::package_type result_type;
				typedef typename result_type::value_type value_type;
				static result_type v;
				struct initializer {
					int operator()() const {
						v.insert(value_type(work_false::name(), work_false()));
						v.insert(value_type(work_true::name(), work_true()));
						return 0;
					}
				};
				static int const init = initializer()();
				return v;
			}
예제 #25
0
GA1DArrayAlleleGenome<float>::
GA1DArrayAlleleGenome(const GAAlleleSetArray<float> & sa,
		      GAGenome::Evaluator f, void * u) :
GA1DArrayGenome<float>(sa.size(), f, u){
  naset = sa.size();
  aset = new GAAlleleSet<float>[naset];
  for(int i=0; i<naset; i++)
    aset[i] = sa.set(i);

  initializer(DEFAULT_REAL_INITIALIZER);
  mutator(DEFAULT_REAL_MUTATOR);
  comparator(DEFAULT_REAL_COMPARATOR);
  crossover(DEFAULT_REAL_CROSSOVER);
}
예제 #26
0
void CAipi_ExpParser::declarator_init()
{
	declarator_direct();
	
	if( m_lookahead == EQUAL )
	{
		getToken();
		initializer();
		emit_declaration(EQUAL);
	}
	
	

}
예제 #27
0
GA3DArrayAlleleGenome<T>::
GA3DArrayAlleleGenome(unsigned int w, unsigned int h, unsigned int d,
		      const GAAlleleSetArray<T> & sa,
		      GAGenome::Evaluator f, void * u) :
GA3DArrayGenome<T>(w,h,d, f, u) {
  naset = sa.size();
  aset = new GAAlleleSet<T>[naset];
  for(int i=0; i<naset; i++)
    aset[i] = sa.set(i);

  initializer(DEFAULT_3DARRAY_ALLELE_INITIALIZER);
  mutator(DEFAULT_3DARRAY_ALLELE_MUTATOR);
  comparator(DEFAULT_3DARRAY_ALLELE_COMPARATOR);
  crossover(DEFAULT_3DARRAY_ALLELE_CROSSOVER);
}
예제 #28
0
IEntityProxyPtr CreateScriptProxy( CEntity* pEntity,IEntityScript* pScript,SEntitySpawnParams* pSpawnParams )
{
	// Load script now (Will be ignored if already loaded).
	CEntityScript* pEntityScript = (CEntityScript*)pScript;
	if (pEntityScript->LoadScript())
	{
		IEntityProxyPtr                                pScriptProxy = ComponentCreate_DeleteWithRelease<CScriptProxy>();
		CScriptProxy::SComponentInitializerScriptProxy initializer( pEntity, pEntityScript, pSpawnParams );
		pEntity->RegisterComponent( pScriptProxy, IComponent::EComponentFlags_Enable | IComponent::EComponentFlags_LazyRegistration );
		pScriptProxy->Initialize( initializer );
		return pScriptProxy;
	}

	return IEntityProxyPtr();
}
Rgrid_ellips_neighborhood::
Rgrid_ellips_neighborhood( RGrid* grid,
			   Grid_continuous_property* property,
			   GsTLInt max_radius, GsTLInt mid_radius, GsTLInt min_radius,
			   double x_angle, double y_angle, double z_angle,
			   int max_neighbors, 
			   const Covariance<GsTLPoint>* cov,
         const Grid_region* region) 
  : Neighborhood(),
    grid_( grid ),
    property_( property ),
    max_neighbors_( max_neighbors ) {

  region_ = region;
  
  appli_assert( grid_ );

  cursor_ = *( grid_->cursor() );

  // use a geobody approach to find all the cells inside the ellipsoid.
  // Then sort them according to covariance.
  Ellipsoid_rasterizer initializer( 2*grid->nx()+1, 2*grid->ny()+1, 2*grid->nz()+1, 
			                              max_radius, mid_radius, min_radius,
			                              x_angle, y_angle, z_angle );

  std::vector< Ellipsoid_rasterizer::EuclideanVector >& templ = 
    initializer.rasterize();


  // We now sort the template according to covariance cov.
  // If no covariance was specified, create a default one
  if( !cov ) {
    Covariance<GsTLPoint> covar;
    int id = covar.add_structure( "Spherical" );
    
    covar.set_geometry( id, 
			max_radius, mid_radius, min_radius,
			x_angle, y_angle, z_angle );

    std::sort( templ.begin(), templ.end(), Evector_greater_than( covar ) );
  }
  else
    std::sort( templ.begin(), templ.end(), Evector_greater_than( *cov ) );
  
  geom_.init( templ.begin(), templ.end() );

}
int bounded_field_initialize(
  bounded_field_t *bounded_field,
  unsigned nx, unsigned ny,
  double x0, double x1,
  double y0, double y1,
  double (*f)(double, double),
  double (*initializer)(double,double)
){
  if(!f){
    return 0;
  }
  bounded_field->field = calloc((2+nx)*(2+ny), sizeof(double));
  if(!bounded_field->field){
    return 0;
  }
  if(!(bounded_field->f_field = malloc(nx*ny*sizeof(double)))){
    free(bounded_field->field);
    return 0;
  }
  bounded_field->f = f;
  bounded_field->nx = nx;
  bounded_field->ny = ny;
  bounded_field->x0 = x0;
  bounded_field->x1 = x1;
  bounded_field->y0 = y0;
  bounded_field->y1 = y1;
  bounded_field->dx = (x1-x0)/nx;
  bounded_field->dy = (y1-y0)/ny;
  if(initializer){
    double dx = (x1-x0)/nx;
    double dy = (y1-y0)/ny;
    for(unsigned u = 0; u < ny; u++){
      double y = y0 + (u+0.5)*dy;
      for(unsigned w = 0; w < nx; w++){
        double x = x0 + (w+0.5)*dx;
        bounded_field->field[(u+1)*(nx+2)+w+1] = initializer(x,y);
      }
    }
  }
  for(unsigned y = 0; y < ny; y++){
    for(unsigned x = 0; x < nx; x++){
      bounded_field->f_field[y*nx+x] = bounded_field_eval_f_at_index(bounded_field, x, y);
    }
  }
  return 1;
}