예제 #1
0
파일: otama.c 프로젝트: kyama/otama
static VALUE
otama_rb_search(VALUE self, VALUE n, VALUE query)
{
	otama_t *otama;
	otama_status_t ret;
	VALUE result_array;
	otama_result_t *results = NULL;
	otama_variant_pool_t *pool;
	otama_variant_t *var;
	
	Data_Get_Struct(self, otama_t, otama);
	OTAMA_CHECK_NULL(otama);
	Check_Type(query, T_HASH);

	pool = otama_variant_pool_alloc();
	var = otama_variant_new(pool);
	rubyobj2variant(query, var);
	
	ret = otama_search(otama, &results, NUM2INT(n), var);
	if (ret != OTAMA_STATUS_OK) {
		otama_variant_pool_free(&pool);
		otama_rb_raise(ret);
		return Qnil;
	}
	result_array = make_results(results);
	
	otama_result_free(&results);
	otama_variant_pool_free(&pool);
	
	return result_array;
}
예제 #2
0
파일: three_d.c 프로젝트: Angeldude/pd
static void search(three_d_struct *three_d, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = three_d -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_a = three_d -> a;
	double temp_b = three_d -> b;
	double temp_c = three_d -> c;
	double temp_d = three_d -> d;
	double temp_e = three_d -> e;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], three_d -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		three_d -> a = (drand48() * (three_d -> a_hi - three_d -> a_lo)) + three_d -> a_lo;
		three_d -> b = (drand48() * (three_d -> b_hi - three_d -> b_lo)) + three_d -> b_lo;
		three_d -> c = (drand48() * (three_d -> c_hi - three_d -> c_lo)) + three_d -> c_lo;
		three_d -> d = (drand48() * (three_d -> d_hi - three_d -> d_lo)) + three_d -> d_lo;
		three_d -> e = (drand48() * (three_d -> e_hi - three_d -> e_lo)) + three_d -> e_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(three_d, NULL, argc, vars);
		do { calc(three_d, three_d -> vars); } while(jump--);
		three_d -> lyap_exp = lyapunov((void *) three_d, (t_gotfn) calc, M_var_count, (double *) three_d -> vars);
		if (isnan(three_d -> lyap_exp)) { not_found = 1; }
		if (three_d -> lyap_exp < three_d -> lyap_lo || three_d -> lyap_exp > three_d -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(three_d, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) three_d -> lyap_limit);
		post("Try using wider constraints.");
		three_d -> a = temp_a;
		three_d -> b = temp_b;
		three_d -> c = temp_c;
		three_d -> d = temp_d;
		three_d -> e = temp_e;
		outlet_anything(three_d -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		three_d -> failure_ratio = (three_d -> lyap_limit - not_expired) / three_d -> lyap_limit;
		make_results(three_d);
		outlet_anything(three_d -> search_outlet, gensym("search"), M_search_count, three_d -> search_out);
	}
}
예제 #3
0
파일: rossler.c 프로젝트: kmatheussen/libpd
static void search(rossler_struct *rossler, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = rossler -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_h = rossler -> h;
	double temp_a = rossler -> a;
	double temp_b = rossler -> b;
	double temp_c = rossler -> c;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], rossler -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		rossler -> h = (drand48() * (rossler -> h_hi - rossler -> h_lo)) + rossler -> h_lo;
		rossler -> a = (drand48() * (rossler -> a_hi - rossler -> a_lo)) + rossler -> a_lo;
		rossler -> b = (drand48() * (rossler -> b_hi - rossler -> b_lo)) + rossler -> b_lo;
		rossler -> c = (drand48() * (rossler -> c_hi - rossler -> c_lo)) + rossler -> c_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(rossler, NULL, argc, vars);
		do { calc(rossler, rossler -> vars); } while(jump--);
		rossler -> lyap_exp = lyapunov((void *) rossler, (t_gotfn) calc, M_var_count, (double *) rossler -> vars);
		if (isnan(rossler -> lyap_exp)) { not_found = 1; }
		if (rossler -> lyap_exp < rossler -> lyap_lo || rossler -> lyap_exp > rossler -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(rossler, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) rossler -> lyap_limit);
		post("Try using wider constraints.");
		rossler -> h = temp_h;
		rossler -> a = temp_a;
		rossler -> b = temp_b;
		rossler -> c = temp_c;
		outlet_anything(rossler -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		rossler -> failure_ratio = (rossler -> lyap_limit - not_expired) / rossler -> lyap_limit;
		make_results(rossler);
		outlet_anything(rossler -> search_outlet, gensym("search"), M_search_count, rossler -> search_out);
	}
}
예제 #4
0
static void search(mlogistic_struct *mlogistic, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = mlogistic -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_c = mlogistic -> c;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], mlogistic -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		mlogistic -> c = (drand48() * (mlogistic -> c_hi - mlogistic -> c_lo)) + mlogistic -> c_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(mlogistic, NULL, argc, vars);
		do { calc(mlogistic, mlogistic -> vars); } while(jump--);
		mlogistic -> lyap_exp = lyapunov((void *) mlogistic, (t_gotfn) calc, M_var_count, (double *) mlogistic -> vars);
		if (isnan(mlogistic -> lyap_exp)) { not_found = 1; }
		if (mlogistic -> lyap_exp < mlogistic -> lyap_lo || mlogistic -> lyap_exp > mlogistic -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(mlogistic, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) mlogistic -> lyap_limit);
		post("Try using wider constraints.");
		mlogistic -> c = temp_c;
		outlet_anything(mlogistic -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		mlogistic -> failure_ratio = (mlogistic -> lyap_limit - not_expired) / mlogistic -> lyap_limit;
		make_results(mlogistic);
		outlet_anything(mlogistic -> search_outlet, gensym("search"), M_search_count, mlogistic -> search_out);
	}
}
예제 #5
0
static void show(latoomutalpha_struct *latoomutalpha) {
	make_results(latoomutalpha);
	outlet_anything(latoomutalpha -> search_outlet, gensym("show"), M_search_count, latoomutalpha -> search_out);
}
예제 #6
0
파일: dejong.c 프로젝트: Angeldude/pd
static void show(dejong_struct *dejong) {
	make_results(dejong);
	outlet_anything(dejong -> search_outlet, gensym("show"), M_search_count, dejong -> search_out);
}
예제 #7
0
파일: base3.c 프로젝트: Angeldude/pd
static void show(base3_struct *base3) {
	make_results(base3);
	outlet_anything(base3 -> search_outlet, gensym("show"), M_search_count, base3 -> search_out);
}
예제 #8
0
static void show(mlogistic_struct *mlogistic) {
	make_results(mlogistic);
	outlet_anything(mlogistic -> search_outlet, gensym("show"), M_search_count, mlogistic -> search_out);
}
예제 #9
0
파일: rossler.c 프로젝트: kmatheussen/libpd
static void show(rossler_struct *rossler) {
	make_results(rossler);
	outlet_anything(rossler -> search_outlet, gensym("show"), M_search_count, rossler -> search_out);
}
예제 #10
0
파일: standardmap.c 프로젝트: Angeldude/pd
static void show(standardmap_struct *standardmap) {
	make_results(standardmap);
	outlet_anything(standardmap -> search_outlet, gensym("show"), M_search_count, standardmap -> search_out);
}
예제 #11
0
static void show(lotkavolterra_struct *lotkavolterra) {
	make_results(lotkavolterra);
	outlet_anything(lotkavolterra -> search_outlet, gensym("show"), M_search_count, lotkavolterra -> search_out);
}
예제 #12
0
static void show(pickover_struct *pickover) {
	make_results(pickover);
	outlet_anything(pickover -> search_outlet, gensym("show"), M_search_count, pickover -> search_out);
}
예제 #13
0
파일: three_d.c 프로젝트: Angeldude/pd
static void show(three_d_struct *three_d) {
	make_results(three_d);
	outlet_anything(three_d -> search_outlet, gensym("show"), M_search_count, three_d -> search_out);
}
예제 #14
0
파일: popcorn.c 프로젝트: kmatheussen/libpd
static void show(popcorn_struct *popcorn) {
	make_results(popcorn);
	outlet_anything(popcorn -> search_outlet, gensym("show"), M_search_count, popcorn -> search_out);
}
예제 #15
0
static void search(strange1_struct *strange1, t_symbol *s, int argc, t_atom *argv) {
	int not_found, not_expired = strange1 -> lyap_limit;
	int jump, i, iterations;
	t_atom vars[M_var_count];
	double temp_a0 = strange1 -> a0;
	double temp_a1 = strange1 -> a1;
	double temp_a2 = strange1 -> a2;
	double temp_a3 = strange1 -> a3;
	double temp_a4 = strange1 -> a4;
	double temp_a5 = strange1 -> a5;
	double temp_b0 = strange1 -> b0;
	double temp_b1 = strange1 -> b1;
	double temp_b2 = strange1 -> b2;
	double temp_b3 = strange1 -> b3;
	double temp_b4 = strange1 -> b4;
	double temp_b5 = strange1 -> b5;
	if (argc > 0) {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], atom_getfloatarg(i, argc, argv));
		}
	} else {
		for (i = 0; i < M_var_count; i++) {
			SETFLOAT(&vars[i], strange1 -> vars_init[i]);
		}
	}
	do {
		jump = 500;
		not_found = 0;
		iterations = 10000;
		bad_params:
		strange1 -> a0 = (drand48() * (strange1 -> a0_hi - strange1 -> a0_lo)) + strange1 -> a0_lo;
		strange1 -> a1 = (drand48() * (strange1 -> a1_hi - strange1 -> a1_lo)) + strange1 -> a1_lo;
		strange1 -> a2 = (drand48() * (strange1 -> a2_hi - strange1 -> a2_lo)) + strange1 -> a2_lo;
		strange1 -> a3 = (drand48() * (strange1 -> a3_hi - strange1 -> a3_lo)) + strange1 -> a3_lo;
		strange1 -> a4 = (drand48() * (strange1 -> a4_hi - strange1 -> a4_lo)) + strange1 -> a4_lo;
		strange1 -> a5 = (drand48() * (strange1 -> a5_hi - strange1 -> a5_lo)) + strange1 -> a5_lo;
		strange1 -> b0 = (drand48() * (strange1 -> b0_hi - strange1 -> b0_lo)) + strange1 -> b0_lo;
		strange1 -> b1 = (drand48() * (strange1 -> b1_hi - strange1 -> b1_lo)) + strange1 -> b1_lo;
		strange1 -> b2 = (drand48() * (strange1 -> b2_hi - strange1 -> b2_lo)) + strange1 -> b2_lo;
		strange1 -> b3 = (drand48() * (strange1 -> b3_hi - strange1 -> b3_lo)) + strange1 -> b3_lo;
		strange1 -> b4 = (drand48() * (strange1 -> b4_hi - strange1 -> b4_lo)) + strange1 -> b4_lo;
		strange1 -> b5 = (drand48() * (strange1 -> b5_hi - strange1 -> b5_lo)) + strange1 -> b5_lo;
		// put any preliminary checks specific to this fractal to eliminate bad_params

		reset(strange1, NULL, argc, vars);
		do { calc(strange1, strange1 -> vars); } while(jump--);
		strange1 -> lyap_exp = lyapunov((void *) strange1, (t_gotfn) calc, M_var_count, (double *) strange1 -> vars);
		if (isnan(strange1 -> lyap_exp)) { not_found = 1; }
		if (strange1 -> lyap_exp < strange1 -> lyap_lo || strange1 -> lyap_exp > strange1 -> lyap_hi) { not_found = 1; }
		not_expired--;
	} while(not_found && not_expired);
	reset(strange1, NULL, argc, vars);
	if (!not_expired) {
		post("Could not find a fractal after %d attempts.", (int) strange1 -> lyap_limit);
		post("Try using wider constraints.");
		strange1 -> a0 = temp_a0;
		strange1 -> a1 = temp_a1;
		strange1 -> a2 = temp_a2;
		strange1 -> a3 = temp_a3;
		strange1 -> a4 = temp_a4;
		strange1 -> a5 = temp_a5;
		strange1 -> b0 = temp_b0;
		strange1 -> b1 = temp_b1;
		strange1 -> b2 = temp_b2;
		strange1 -> b3 = temp_b3;
		strange1 -> b4 = temp_b4;
		strange1 -> b5 = temp_b5;
		outlet_anything(strange1 -> search_outlet, gensym("invalid"), 0, NULL);
	} else {
		strange1 -> failure_ratio = (strange1 -> lyap_limit - not_expired) / strange1 -> lyap_limit;
		make_results(strange1);
		outlet_anything(strange1 -> search_outlet, gensym("search"), M_search_count, strange1 -> search_out);
	}
}
예제 #16
0
static void show(strange1_struct *strange1) {
	make_results(strange1);
	outlet_anything(strange1 -> search_outlet, gensym("show"), M_search_count, strange1 -> search_out);
}
예제 #17
0
static void show(ikeda_struct *ikeda) {
	make_results(ikeda);
	outlet_anything(ikeda -> search_outlet, gensym("show"), M_search_count, ikeda -> search_out);
}
예제 #18
0
static void show(latoocarfian_struct *latoocarfian) {
	make_results(latoocarfian);
	outlet_anything(latoocarfian -> search_outlet, gensym("show"), M_search_count, latoocarfian -> search_out);
}