/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static void do_piechart(const struct variable *var,
const struct freq_tab *frq_tab);
-gsl_histogram *
+struct histogram *
freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var);
for (; casegrouper_get_next_group (grouper, &group);
casereader_destroy (group))
{
- struct ccase c;
+ struct ccase *c;
precalc (group, ds);
- for (; casereader_read (group, &c); case_destroy (&c))
- calc (&c, ds);
+ for (; (c = casereader_read (group)) != NULL; case_unref (c))
+ calc (c, ds);
postcalc ();
}
ok = casegrouper_destroy (grouper);
static void
precalc (struct casereader *input, struct dataset *ds)
{
- struct ccase c;
+ struct ccase *c;
size_t i;
- if (casereader_peek (input, 0, &c))
+ c = casereader_peek (input, 0);
+ if (c != NULL)
{
- output_split_file_values (ds, &c);
- case_destroy (&c);
+ output_split_file_values (ds, c);
+ case_unref (c);
}
pool_destroy (data_pool);
if ( chart == GFT_HIST)
{
double d[frq_n_stats];
- struct normal_curve norm;
- gsl_histogram *hist ;
-
-
- norm.N = vf->tab.valid_cases;
+ struct histogram *hist ;
calc_stats (v, d);
- norm.mean = d[frq_mean];
- norm.stddev = d[frq_stddev];
- hist = freq_tab_to_hist(ft,v);
+ hist = freq_tab_to_hist (ft,v);
- histogram_plot(hist, var_to_string(v), &norm, normal);
+ histogram_plot_n (hist, var_to_string(v),
+ vf->tab.valid_cases,
+ d[frq_mean],
+ d[frq_stddev],
+ normal);
- gsl_histogram_free(hist);
+ statistic_destroy ((struct statistic *)hist);
}
-
if ( chart == GFT_PIE)
{
do_piechart(v_variables[i], ft);
}
-
-
cleanup_freq_tab (v);
}
vf->groups = NULL;
vf->width = var_get_width (v);
vf->print = *var_get_print_format (v);
- if (vf->width > MAX_SHORT_STRING && get_algorithm () == COMPATIBLE)
+ if (vf->width > MAX_SHORT_STRING && settings_get_algorithm () == COMPATIBLE)
{
enum fmt_type type = var_get_print_format (v)->type;
vf->width = MAX_SHORT_STRING;
double tp;
if ( percentiles[i].flag2 ) continue ;
- if ( get_algorithm() != COMPATIBLE )
+ if ( settings_get_algorithm () != COMPATIBLE )
tp =
(ft->valid_cases - 1) * percentiles[i].p;
else
double s;
double dummy;
- if ( get_algorithm() != COMPATIBLE )
+ if ( settings_get_algorithm () != COMPATIBLE )
{
s = modf((ft->valid_cases - 1) * percentiles[i].p , &dummy);
}
/* Create a gsl_histogram from a freq_tab */
-gsl_histogram *
-freq_tab_to_hist(const struct freq_tab *ft, const struct variable *var)
+struct histogram *
+freq_tab_to_hist (const struct freq_tab *ft, const struct variable *var)
{
int i;
double x_min = DBL_MAX;
double x_max = -DBL_MAX;
- gsl_histogram *hist;
+ struct statistic *hist;
const double bins = 11;
struct hsh_iterator hi;
if ( frq->value[0].f > x_max ) x_max = frq->value[0].f ;
}
- hist = histogram_create(bins, x_min, x_max);
+ hist = histogram_create (bins, x_min, x_max);
for( i = 0 ; i < ft->n_valid ; ++i )
{
frq = &ft->valid[i];
- gsl_histogram_accumulate(hist, frq->value[0].f, frq->count);
+ histogram_add ((struct histogram *)hist, frq->value[0].f, frq->count);
}
- return hist;
+ return (struct histogram *)hist;
}
{
const struct freq *frq = &frq_tab->valid[i];
- slices[i].label = var_get_value_name (var, frq->value);
+ ds_init_empty (&slices[i].label);
+ var_append_value_name (var, frq->value, &slices[i].label);
slices[i].magnetude = frq->count;
}
do_piechart(const struct variable *var, const struct freq_tab *frq_tab)
{
struct slice *slices;
- int n_slices;
+ int n_slices, i;
slices = freq_tab_to_slice_array(frq_tab, var, &n_slices);
piechart_plot(var_to_string(var), slices, n_slices);
+ for (i = 0 ; i < n_slices ; ++i )
+ {
+ ds_destroy (&slices[i].label);
+ }
+
free(slices);
}