예제 #1
0
void Color3WayMain::calculate_factors(float *r, float *g, float *b, int section)
{
	calculate_factors(r, g, b, config.hue_x[section], config.hue_y[section]);


//printf("Color3WayMain::calculate_factors %d %f %f %f\n", __LINE__, *r, *g, *b);
}
예제 #2
0
void Color3WayMain::process_pixel(float *r,
	float *g,
	float *b,
	float r_in, 
	float g_in, 
	float b_in,
	float x,
	float y)
{
	float r_factor[SECTIONS];
	float g_factor[SECTIONS];
	float b_factor[SECTIONS];
	float s_factor[SECTIONS];
	float v_factor[SECTIONS];
	for(int i = 0; i < SECTIONS; i++)
	{
		calculate_factors(r_factor + i, 
			g_factor + i, 
			b_factor + i, 
			x, 
			y);
		CALCULATE_FACTORS(s_factor[i], v_factor[i], 0, 0)
	}
	
	PROCESS_PIXEL(r_in, g_in, b_in);
	*r = r_in;
	*g = g_in;
	*b = b_in;
}
예제 #3
0
static PyObject *_pysieve_msieve(PyObject *self, PyObject *args){

	uint32 seed1, seed2;
	uint32 cache_size1, cache_size2;
	char buf[400];
	enum cpu_type cpu;
	uint32 flags;
	char *savefile_name = NULL;
	char *logfile_name = NULL;
	/*	char *infile_name = "worktodo.ini";*/
	char *nfs_fbfile_name = NULL;
	/*int32 deadline = 0;*/
	uint32 max_relations = 0;
	uint64 nfs_lower = 0;
	uint64 nfs_upper = 0;
	uint32 num_threads = 0;
	uint32 mem_mb = 0;
	uint32 which_gpu = 0;

	get_cache_sizes(&cache_size1, &cache_size2);
	cpu = get_cpu_type();

	flags = MSIEVE_DEFAULT_FLAGS;
	

	get_random_seeds(&seed1, &seed2);

	const char *number;
	PyObject *result = PyList_New(0);

	if (!PyArg_ParseTuple(args, "s", &number))
		return NULL;

	strcpy(buf, number);
			
		 
	calculate_factors(buf, result,flags, 
										savefile_name,
										logfile_name, nfs_fbfile_name,
										&seed1, &seed2,
										max_relations, nfs_lower , nfs_upper,
										cpu,
										cache_size1,
										cache_size2,
										num_threads, mem_mb, which_gpu);

	return result;
			
}
예제 #4
0
파일: ndiv.c 프로젝트: tin2012/random
int main()
{
    int tn;
    int a, b, c;
    int i, k;
	generate_primes();
	scanf("%d %d %d", &a, &b, &c);
    k = 0;
	for (i = a; i <= b; i++){
		if (calculate_factors(i, c) == c)
			k++;
	}
	printf("%d\n", k);
    return 0;
}
예제 #5
0
void DumbBot::process_now_message( TokenMessage &incoming_message )
{
	MapAndUnits::UNIT_SET::iterator unit_iterator;

	// handle press
	negotiator->start();

	if ( ( m_map_and_units->current_season == TOKEN_SEASON_SPR )
		|| ( m_map_and_units->current_season == TOKEN_SEASON_SUM ) )
	{
		// Spring Moves/Retreats
		calculate_factors( m_proximity_spring_attack_weight, m_proximity_spring_defence_weight );

		calculate_destination_value( m_spring_proximity_weight, m_spring_strength_weight, m_spring_competition_weight );
	}
	else if ( ( m_map_and_units->current_season == TOKEN_SEASON_FAL )
		|| ( m_map_and_units->current_season == TOKEN_SEASON_AUT ) )
	{
		// Fall Moves/Retreats
		calculate_factors( m_proximity_fall_attack_weight, m_proximity_fall_defence_weight );

		calculate_destination_value( m_fall_proximity_weight, m_fall_strength_weight, m_fall_competition_weight );
	}
	else
	{
		// Adjustments
		calculate_factors( m_proximity_spring_attack_weight, m_proximity_spring_defence_weight );

		if ( m_map_and_units->our_units.size() > m_map_and_units->our_centres.size() )
		{
			// Disbanding
			calculate_winter_destination_value( m_remove_proximity_weight, m_remove_defence_weight );
		}
		else
		{
			// Building
			calculate_winter_destination_value( m_build_proximity_weight, m_build_defence_weight );
		}
	}

	/*
	#ifdef _DEBUG
		generate_debug();
	#endif
	*/

	if ( ( m_map_and_units->current_season == TOKEN_SEASON_SPR )
		|| ( m_map_and_units->current_season == TOKEN_SEASON_FAL ) )
	{
		generate_movement_orders();
	}
	else if ( ( m_map_and_units->current_season == TOKEN_SEASON_SUM )
		|| ( m_map_and_units->current_season == TOKEN_SEASON_AUT ) )
	{
		generate_retreat_orders();
	}
	else
	{
		if ( m_map_and_units->our_units.size() > m_map_and_units->our_centres.size() )
		{
			// Too many units. Remove.
			generate_remove_orders( m_map_and_units->our_units.size() - m_map_and_units->our_centres.size() );
		}
		else if ( m_map_and_units->our_units.size() < m_map_and_units->our_centres.size() )
		{
			// Not enough units. Builds.
			generate_build_orders( m_map_and_units->our_centres.size() - m_map_and_units->our_units.size() );
		}
	}

	send_orders_to_server();
}