コード例 #1
0
    std::unique_ptr<Layer> LayerFactory::makeLayer(
            const LayerFactory::LayerSetting* prev_setting,
            const LayerFactory::LayerSetting* cur_setting)
    {
        auto prev_t = whatType(prev_setting);
        auto cur_t = whatType(cur_setting);

        auto creator = m_creators.find(std::make_pair(prev_t, cur_t));
        if (creator != m_creators.end())
        {
            return creator->second->create(*(prev_setting), *(cur_setting));
        }
        return std::unique_ptr<Layer>();
    }
コード例 #2
0
ファイル: variables1.c プロジェクト: DanIverson/OpenVnmrJ
void RshowVar(FILE *f, varInfo *v)
{   
    double maxv, minv, stepv;
    int i,pindex;
    unsigned int p;

    (void) f;
    if (v)
    {	
	RshowRvals(v->T.basicType,v->R);
	RshowTval(&(v->T));
	if(v->ET.size) /* if there are enums */
	{   Wscrprintf("Enumerals\n");
	    RshowRvals(v->T.basicType,v->E);
	}
	Wscrprintf("subtype = %s   ",whatType(v->subtype));
	Wscrprintf("active = %s  ",whatActive(v->active));
	Wscrprintf("group = %s   ",whatGroup(v->Ggroup));
	Wscrprintf("Dgroup = %d\n",v->Dgroup);
	Wscrprintf("protection = ");
	p = v->prot;
	for (i=15; i >= 0; i--)
	  Wscrprintf("%1d%c",(p >> i) & 1,(i != 0) ? ' ' : '\n');

/*  If P_MMS bit set, use maxVal, minVal, etc. fields as indicies
    into system global paramters "parmax", "parmin", etc. extracting
    the desired value from the appropriate array.                       */

        if (v->prot & P_MMS)
        {
           pindex = (int) (v->minVal+0.1);
           if (P_getreal( SYSTEMGLOBAL, "parmin", &minv, pindex ))
            minv = -1.0e+30;
           pindex = (int) (v->maxVal+0.1);
           if (P_getreal( SYSTEMGLOBAL, "parmax", &maxv, pindex ))
            maxv = 1.0e+30;
           pindex = (int) (v->step+0.1);
           if (P_getreal( SYSTEMGLOBAL, "parstep", &stepv, pindex ))
            stepv = 0.0;
	   Wscrprintf("maxVal[%d] = %1.12g   ",(int)(v->maxVal+0.1),maxv);
	   Wscrprintf("minVal[%d] = %1.12g   ",(int)(v->minVal+0.1),minv);
	   Wscrprintf("step[%d] = %1.12g\n\n",
		(int)(v->step+0.1),stepv);
	}
	else
	{
	   Wscrprintf("maxVal = %1.12g   ",v->maxVal);
	   Wscrprintf("minVal = %1.12g   ",v->minVal);
	   Wscrprintf("step = %1.12g\n\n",v->step);
	}
    }
    else
コード例 #3
0
ファイル: triangle.c プロジェクト: N-Thomas/cs5959-f15-shared
/*
 * This program can only accept 6 numbers as arguments.  The 6 numbers will represent the
 * x and y coordinates of six points ( x1, y1,...).  The points may be in decimal notation
 * but the decimal will be truncated.  If the points do not make a triangle 'not a triangle'
 * is printed, otherwise the classification of the triangle (in lower case) is printed.
 * If the input is not valid, 'error' is printed. +/-1073741823 are the largest acceptable 
 * numbers.
 */
int main (int argc, char **argv)
{

	long points[6];
	long long sides[3];
	
	if ( parseInput( argc, argv, points ) == 1) {
    printf("error\n");
		return 1;
	}
  if ( checkColinear( points[0], points[1], points[2], points[3], points[4], points[5]) ) {
    printf("not a triangle\n");
    return 1;
  }

	getSidesAndSort( points, sides);
  printResult( whatClass( sides ), whatType( sides ) );
	
  return(0);
}
コード例 #4
0
 size_t LayerFactory::getMapNum(const LayerSetting* set)
 {
     size_t num = 0;
     auto set_t = whatType(set);
     if (set_t == LayerType::IMAGE)
     {
         auto ils = static_cast<const ImageLayerSetting&>(*(set));
         num = ils.channel_num;
     }
     else if (set_t == LayerType::CONVOLUTION)
     {
         auto cs = static_cast<const ConvLayerSetting&>(*(set));
         num = cs.map_num;
     }
     else if (set_t == LayerType::MAXPOOL)
     {
         auto mps = static_cast<const MaxPoolLayerSetting&>(*(set));
         num = mps.map_num;
     }
     return num;
 }
コード例 #5
0
 void LayerFactory::getOutputDimension(const LayerSetting* set,
         size_t& width, size_t& height)
 {
     auto set_t = whatType(set);
     if (set_t == LayerType::IMAGE)
     {
         auto ils = static_cast<const ImageLayerSetting&>(*(set));
         width = ils.image_w;
         height = ils.image_h;
     }
     else if (set_t == LayerType::CONVOLUTION)
     {
         auto cs = static_cast<const ConvLayerSetting&>(*(set));
         width = cs.output_w;
         height = cs.output_h;
     }
     else if (set_t == LayerType::MAXPOOL)
     {
         auto mps = static_cast<const MaxPoolLayerSetting&>(*(set));
         width = mps.output_w;
         height = mps.output_h;
     }
 }
コード例 #6
0
ファイル: main.c プロジェクト: lalalaStalker/dbQuery
int main( int argc, char const *argv[] ){

	FILE *configFile;  /*Pointer to config file*/
	FILE *queryFile;  /*Poiner to query file*/
	char command[COMMAND_LENGTH];  /*A temp string for the query command*/
	char relName[MAX_STRING];  /*A temp string for the relation name*/
	char attrName[MAX_STRING];  /*A temp string for attribute name*/
	char relop[RELOP_LENGTH];  /*Array to hold relational operator*/
	char value[MAX_STRING];  /*Array to hold string to compare*/
	int numericValue;  /*Int to hold integer value to compare*/


	/*If the wrong number of arguments is given, print an error message and 
	exit.
	*/
	if( argc != NUM_ARGS){
		fprintf( stderr, "Incorrect number of arguments\n" );
		exit(1);
	}

	/*If the config file cannot be opened for reading, print an error message 
	and exit.
	*/
	if( (configFile = ( fopen( argv[CONFIG_FILE_ARG], "r"))) == NULL){
		fprintf( stderr, "There was an error trying to open config file %s\n",
				argv[CONFIG_FILE_ARG]);
		exit(1);
	}

	/*If the query file cannot be opened for reading, print an error message 
	and exit.
	*/
	if( (queryFile = ( fopen( argv[QUERY_FILE_ARG], "r"))) == NULL){
		fprintf( stderr, "There was an error trying to open query file %s\n",
				argv[QUERY_FILE_ARG]);
		exit(1);
	}


	/*Keep checking query file for another command
	*/
	while( fscanf( queryFile, "%s", command) == 1){

		/*If command entered is "nattr", get the relation name after the cmd, 
		and check to see if it is in the db. If so, call function to get the
		number of attributes for the specified relation. If not, print an 
		error message and move to the next query.
		*/
		if( strcmp( command, "nattr") == 0){
			fscanf( queryFile, "%s", relName);
			if( checkRelation( configFile, relName) == 1){
				nattr( relName);
			}
			else{
				printf(" Error: %s relation is not in the database.\n\n", 
						relName);
				fflush( stdout);
				continue;
			}
		}

		/*If command entered is "tuplen", get the relation name after the 
		cmd and check to see if it is in the db. If so, call the function to
		get the length of each tuple in this relation. If the relation is 
		not in the db, print an error message and move to the next query.
		*/
		else if( strcmp( command, "tuplen") == 0){
			fscanf( queryFile, "%s", relName);
			if( checkRelation( configFile, relName) == 1){
				tuplen( relName, 1);
			}
			else{
				printf(" Error: %s relation is not in the database.\n\n", 
						relName);
				fflush( stdout);
				continue;
			}

		}

		/*If command entered is "infattr", get the relation and attribute
		names after the cmd.  Check if the relation is in the database. If
		it is, call the function to check if the attribute is in that 
		relation (and if it is, print the type and number of bytes of the 
		attribute). If the relation is not in the db, print an error message
		and move to the next query.
		*/
		else if( strcmp( command, "infattr") == 0){
			fscanf( queryFile, "%s", relName);
			fscanf( queryFile, "%s", attrName);
			if( checkRelation( configFile, relName) == 1){
				infattr( relName, attrName, 1);
			}
			else{
				printf(" Error: %s relation is not in the database.\n\n", 
						relName);
				fflush( stdout);
				continue;
			}
		}

		/*If the command entered is "count", get the relation name after
		the cmd and check that it is a relation in the db. If so, call the
		function which prints the number of tuples in this relation. If the 
		relation is not in the db, print an error message and move to the 
		next query in the query file.
		*/
		else if( strcmp( command, "count") == 0){
			fscanf( queryFile, "%s", relName);
			if( checkRelation( configFile, relName) == 1){
				count( relName, 1);
			}
			else{
				printf(" Error: %s relation is not in the database.\n\n", 
						relName);
				fflush( stdout);
				continue;
			}
		}

		/*If command entered is "project", get the relation name and 
		attribute name after the cmd. Check that the relation is indeed
		a relation in the database. If so, call the function which prints
		all non duplicate values for this relation in the database. If this
		is not a relation in the database, print an error message and move
		on to the next query.
		*/
		else if( strcmp( command, "project") == 0){
			fscanf( queryFile, "%s", relName);
			fscanf( queryFile, "%s", attrName);
			if( checkRelation( configFile, relName) == 1){
				project( relName, attrName);
			}
			else{
				printf(" Error: %s relation is not in the database.\n\n", 
						relName);
				fflush( stdout);
				continue;
			}
		}

		/*If command entered is "select", get the relation name, attribute
		name, and relational operator that follow, and store their values.
		Check if relation is in db, then check that the attribute belongs
		to the relation. Then get the type. If the type is INT, then get
		the int from the next position in the query file, and set the string
		to "". If the type is STRING, then get the string from the next 
		position in the query file, and set the int to -1. In either case
		("I" or "S") call the function which prints out all tuples who
		satisfy the condition in the query. If this is not a relation in the 
		db, print an error message and go on to the next query.
		*/
		else if( strcmp( command, "select") == 0){
			fscanf( queryFile, "%s", relName);
			fscanf( queryFile, "%s", attrName);
			fscanf( queryFile, "%s", relop);
			/*If the relation is in db
			*/
			if( checkRelation( configFile, relName) == 1){
				/*If the attribute belongs to the relation
				*/
				if( (infattr( relName, attrName, 0)) == 1){
					/*If the relation type is "I"
					*/
					if( whatType( relName, attrName, 0) == 1){  /*INT type*/
						fscanf( queryFile, "%d", &numericValue); /*Store int*/
						/*Dummy value used to determine if we are trying to 
						compare an int and a string, later on in select 
						function
						*/
						strcpy( value, "\0");  
						select( relName, attrName, relop, numericValue, 
									value, "I");
					}
					/*If the relation type is "S"
					*/
					else{
						fscanf( queryFile, "%s", value);  /*Store string*/
						/*Dummy value used to determine if we are trying to 
						compare a string and an int, later on in select 
						function
						*/
						numericValue = -1;  
						select( relName, attrName, relop, numericValue, 
									value, "S");
					}
				}
			}
			/*If the relation is not in db, print an error message and go to 
			next query
			*/
			else{  
				printf(" Error: %s relation is not in the database.\n\n", 
						relName);
				fflush( stdout);
				continue;
			}
		}

		/*If the command entered is "quit", then close the files and exit the
		program.
		*/
		else if( strcmp( command, "quit") == 0){
			/*Close query file*/
			if( fclose( queryFile) == EOF){
				fprintf( stderr, "Error closing query file.\n");
				exit(1);
			}
			/*Close config file*/
			if( fclose( configFile) == EOF){
				fprintf( stderr, "Error closing config file.\n");
				exit(1);
			}
			exit(1);
		}
	}
	return 0;
}