2 #include <gsl/gsl_ntuple.h>
3 #include <gsl/gsl_histogram.h>
12 int sel_func (void *ntuple_data, void *params);
13 double val_func (void *ntuple_data, void *params);
18 struct data ntuple_row;
21 = gsl_ntuple_open ("test.dat", &ntuple_row,
25 gsl_ntuple_select_fn S;
26 gsl_ntuple_value_fn V;
28 gsl_histogram *h = gsl_histogram_alloc (100);
29 gsl_histogram_set_ranges_uniform(h, 0.0, 10.0);
31 S.function = &sel_func;
34 V.function = &val_func;
37 gsl_ntuple_project (h, ntuple, &V, &S);
38 gsl_histogram_fprintf (stdout, h, "%f", "%f");
39 gsl_histogram_free (h);
40 gsl_ntuple_close (ntuple);
46 sel_func (void *ntuple_data, void *params)
48 struct data * data = (struct data *) ntuple_data;
49 double x, y, z, E2, scale;
50 scale = *(double *) params;
56 E2 = x * x + y * y + z * z;
62 val_func (void *ntuple_data, void *params)
64 struct data * data = (struct data *) ntuple_data;
71 return x * x + y * y + z * z;