Beispiel #1
0
int
main (void)
{
  struct data ntuple_row;
  int i;

  gsl_ntuple *ntuple = gsl_ntuple_open ("test.dat", &ntuple_row,
                                        sizeof (ntuple_row));

  gsl_histogram *h = gsl_histogram_calloc_uniform (100, 0., 10.);

  gsl_ntuple_select_fn S;
  gsl_ntuple_value_fn V;

  double scale = 1.5;

  S.function = &sel_func;
  S.params = &scale;

  V.function = &val_func;
  V.params = 0;

  gsl_ntuple_project (h, ntuple, &V, &S);

  gsl_histogram_fprintf (stdout, h, "%f", "%f");

  gsl_histogram_free (h);

  gsl_ntuple_close (ntuple);
}
int main(void) {
	const gsl_rng_type * T;
	gsl_rng * r;

	struct data ntuple_row;
	int i;

	gsl_ntuple *ntuple = gsl_ntuple_create("test.dat", &ntuple_row,
			sizeof(ntuple_row));

	gsl_rng_env_setup();

	T = gsl_rng_default;
	r = gsl_rng_alloc(T);

	for (i = 0; i < 10000; i++) {
		ntuple_row.x = gsl_ran_ugaussian(r);
		ntuple_row.y = gsl_ran_ugaussian(r);
		ntuple_row.z = gsl_ran_ugaussian(r);
		gsl_ntuple_write(ntuple);
	}

	gsl_ntuple_close(ntuple);
	gsl_rng_free(r);

	return EXIT_SUCCESS;
}
int main(void) {
	struct data ntuple_row;

	gsl_ntuple *ntuple
	= gsl_ntuple_open ("test.dat", &ntuple_row,
	sizeof (ntuple_row));
	double lower = 1.5;

	gsl_ntuple_select_fn S;
	gsl_ntuple_value_fn V;

	gsl_histogram *h = gsl_histogram_alloc (100);
	gsl_histogram_set_ranges_uniform(h, 0.0, 10.0);

	S.function = &sel_func;
	S.params = &lower;

	V.function = &val_func;
	V.params = 0;

	gsl_ntuple_project (h, ntuple, &V, &S);

	gsl_histogram_fprintf (stdout, h, "%f", "%f");
	gsl_histogram_free (h);
	gsl_ntuple_close (ntuple);

	return 0;
}