projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'savannah/perl-module'
[pspp-builds.git]
/
src
/
language
/
stats
/
crosstabs.q
diff --git
a/src/language/stats/crosstabs.q
b/src/language/stats/crosstabs.q
index fcfccc39a251c2fbbfffbda7a6913207a70d1757..68d11e307e0ff41584d1ffae0ef4abd6d8c9ff74 100644
(file)
--- a/
src/language/stats/crosstabs.q
+++ b/
src/language/stats/crosstabs.q
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006
, 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
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
@@
-177,8
+177,8
@@
static struct pool *pl_col; /* For column data. */
static int internal_cmd_crosstabs (struct lexer *lexer, struct dataset *ds);
static void precalc (struct casereader *, const struct dataset *);
static int internal_cmd_crosstabs (struct lexer *lexer, struct dataset *ds);
static void precalc (struct casereader *, const struct dataset *);
-static void calc_general (struct ccase *, const struct dataset *);
-static void calc_integer (struct ccase *, const struct dataset *);
+static void calc_general (
const
struct ccase *, const struct dataset *);
+static void calc_integer (
const
struct ccase *, const struct dataset *);
static void postcalc (void);
static void submit (struct tab_table *);
static void postcalc (void);
static void submit (struct tab_table *);
@@
-305,16
+305,16
@@
internal_cmd_crosstabs (struct lexer *lexer, struct dataset *ds)
grouper = casegrouper_create_splits (input, dataset_dict (ds));
while (casegrouper_get_next_group (grouper, &group))
{
grouper = casegrouper_create_splits (input, dataset_dict (ds));
while (casegrouper_get_next_group (grouper, &group))
{
- struct ccase c;
+ struct ccase
*
c;
precalc (group, ds);
precalc (group, ds);
- for (;
casereader_read (group, &c); case_destroy (&
c))
+ for (;
(c = casereader_read (group)) != NULL; case_unref (
c))
{
if (mode == GENERAL)
{
if (mode == GENERAL)
- calc_general (
&
c, ds);
+ calc_general (c, ds);
else
else
- calc_integer (
&
c, ds);
+ calc_integer (c, ds);
}
casereader_destroy (group);
}
casereader_destroy (group);
@@
-518,12
+518,13
@@
static unsigned hash_table_entry (const void *, const void *);
static void
precalc (struct casereader *input, const struct dataset *ds)
{
static void
precalc (struct casereader *input, const struct dataset *ds)
{
- struct ccase c;
+ struct ccase
*
c;
- 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);
}
if (mode == GENERAL)
}
if (mode == GENERAL)
@@
-598,7
+599,7
@@
precalc (struct casereader *input, const struct dataset *ds)
/* Form crosstabulations for general mode. */
static void
/* Form crosstabulations for general mode. */
static void
-calc_general (struct ccase *c, const struct dataset *ds)
+calc_general (
const
struct ccase *c, const struct dataset *ds)
{
/* Missing values to exclude. */
enum mv_class exclude = (cmd.miss == CRS_TABLE ? MV_ANY
{
/* Missing values to exclude. */
enum mv_class exclude = (cmd.miss == CRS_TABLE ? MV_ANY
@@
-672,7
+673,7
@@
calc_general (struct ccase *c, const struct dataset *ds)
}
static void
}
static void
-calc_integer (struct ccase *c, const struct dataset *ds)
+calc_integer (
const
struct ccase *c, const struct dataset *ds)
{
bool bad_warn = true;
{
bool bad_warn = true;
@@
-1674,7
+1675,7
@@
enum_var_values (struct table_entry **entries, int entry_cnt, int var_idx,
if (mode == GENERAL)
{
if (mode == GENERAL)
{
- int width =
var_get_width (v
);
+ int width =
MIN (var_get_width (v), MAX_SHORT_STRING
);
int i;
*values = xnmalloc (entry_cnt, sizeof **values);
int i;
*values = xnmalloc (entry_cnt, sizeof **values);
@@
-1861,7
+1862,6
@@
display_crosstabulation (void)
tab_offset (table, -1, tab_row (table) - num_cells * n_rows);
for (r = 0; r < n_rows; r++)
{
tab_offset (table, -1, tab_row (table) - num_cells * n_rows);
for (r = 0; r < n_rows; r++)
{
- char suffix = 0;
bool mark_missing = false;
if (cmd.miss == CRS_REPORT
bool mark_missing = false;
if (cmd.miss == CRS_REPORT
@@
-1870,6
+1870,7
@@
display_crosstabulation (void)
for (i = 0; i < num_cells; i++)
{
for (i = 0; i < num_cells; i++)
{
+ char suffix = 0;
double v;
switch (cells[i])
double v;
switch (cells[i])
@@
-1878,7
+1879,7
@@
display_crosstabulation (void)
v = row_tot[r];
break;
case CRS_CL_ROW:
v = row_tot[r];
break;
case CRS_CL_ROW:
- v = 100.;
+ v = 100.
0
;
suffix = '%';
break;
case CRS_CL_COLUMN:
suffix = '%';
break;
case CRS_CL_COLUMN:
@@
-1916,7
+1917,6
@@
display_crosstabulation (void)
{
double ct = c < n_cols ? col_tot[c] : W;
bool mark_missing = false;
{
double ct = c < n_cols ? col_tot[c] : W;
bool mark_missing = false;
- char suffix = 0;
int i;
if (cmd.miss == CRS_REPORT && c < n_cols
int i;
if (cmd.miss == CRS_REPORT && c < n_cols
@@
-1925,13
+1925,13
@@
display_crosstabulation (void)
for (i = 0; i < num_cells; i++)
{
for (i = 0; i < num_cells; i++)
{
+ char suffix = 0;
double v;
switch (cells[i])
{
case CRS_CL_COUNT:
v = ct;
double v;
switch (cells[i])
{
case CRS_CL_COUNT:
v = ct;
- suffix = '%';
break;
case CRS_CL_ROW:
v = ct / W * 100.;
break;
case CRS_CL_ROW:
v = ct / W * 100.;
@@
-1954,7
+1954,7
@@
display_crosstabulation (void)
NOT_REACHED ();
}
NOT_REACHED ();
}
-
format_cell_entry (table, c, i, v, suffix, mark_missing);
+ format_cell_entry (table, c, i, v, suffix, mark_missing);
}
last_row = i;
}
}
last_row = i;
}
@@
-2456,7
+2456,7
@@
calc_r (double *X, double *Y, double *r, double *ase_0, double *ase_1)
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += X[i] * row_tot[i];
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += X[i] * row_tot[i];
- sum_X2r +=
X[i] * X[i]
* row_tot[i];
+ sum_X2r +=
pow2 (X[i])
* row_tot[i];
}
Xbar = sum_Xr / W;
}
Xbar = sum_Xr / W;
@@
-2468,11
+2468,11
@@
calc_r (double *X, double *Y, double *r, double *ase_0, double *ase_1)
Ybar = sum_Yc / W;
S = sum_XYf - sum_Xr * sum_Yc / W;
Ybar = sum_Yc / W;
S = sum_XYf - sum_Xr * sum_Yc / W;
- SX = sum_X2r -
sum_Xr * sum_Xr
/ W;
- SY = sum_Y2c -
sum_Yc * sum_Yc
/ W;
+ SX = sum_X2r -
pow2 (sum_Xr)
/ W;
+ SY = sum_Y2c -
pow2 (sum_Yc)
/ W;
T = sqrt (SX * SY);
*r = S / T;
T = sqrt (SX * SY);
*r = S / T;
- *ase_0 = sqrt ((sum_X2Y2f -
(sum_XYf *
sum_XYf) / W) / (sum_X2r * sum_Y2c));
+ *ase_0 = sqrt ((sum_X2Y2f -
pow2 (
sum_XYf) / W) / (sum_X2r * sum_Y2c));
{
double s, c, y, t;
{
double s, c, y, t;
@@
-2562,9
+2562,9
@@
calc_symmetric (double v[N_SYMMETRIC], double ase[N_SYMMETRIC],
Dr = Dc = W * W;
for (r = 0; r < n_rows; r++)
Dr = Dc = W * W;
for (r = 0; r < n_rows; r++)
- Dr -=
row_tot[r] * row_tot[r]
;
+ Dr -=
pow2 (row_tot[r])
;
for (c = 0; c < n_cols; c++)
for (c = 0; c < n_cols; c++)
- Dc -=
col_tot[c] * col_tot[c]
;
+ Dc -=
pow2 (col_tot[c])
;
}
{
}
{
@@
-3073,10
+3073,10
@@
calc_directional (double v[N_DIRECTIONAL], double ase[N_DIRECTIONAL],
}
for (sum_ri2 = 0., i = 0; i < n_rows; i++)
}
for (sum_ri2 = 0., i = 0; i < n_rows; i++)
- sum_ri2 +=
row_tot[i] * row_tot[i]
;
+ sum_ri2 +=
pow2 (row_tot[i])
;
for (sum_cj2 = 0., j = 0; j < n_cols; j++)
for (sum_cj2 = 0., j = 0; j < n_cols; j++)
- sum_cj2 +=
col_tot[j] * col_tot[j]
;
+ sum_cj2 +=
pow2 (col_tot[j])
;
v[3] = (W * sum_fij2_ci - sum_ri2) / (W * W - sum_ri2);
v[4] = (W * sum_fij2_ri - sum_cj2) / (W * W - sum_cj2);
v[3] = (W * sum_fij2_ci - sum_ri2) / (W * W - sum_ri2);
v[4] = (W * sum_fij2_ri - sum_cj2) / (W * W - sum_cj2);
@@
-3166,9
+3166,9
@@
calc_directional (double v[N_DIRECTIONAL], double ase[N_DIRECTIONAL],
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += rows[i].f * row_tot[i];
for (sum_Xr = sum_X2r = 0., i = 0; i < n_rows; i++)
{
sum_Xr += rows[i].f * row_tot[i];
- sum_X2r +=
rows[i].f * rows[i].f
* row_tot[i];
+ sum_X2r +=
pow2 (rows[i].f)
* row_tot[i];
}
}
- SX = sum_X2r -
sum_Xr * sum_Xr
/ W;
+ SX = sum_X2r -
pow2 (sum_Xr)
/ W;
for (SXW = 0., j = 0; j < n_cols; j++)
{
for (SXW = 0., j = 0; j < n_cols; j++)
{
@@
-3176,7
+3176,7
@@
calc_directional (double v[N_DIRECTIONAL], double ase[N_DIRECTIONAL],
for (cum = 0., i = 0; i < n_rows; i++)
{
for (cum = 0., i = 0; i < n_rows; i++)
{
- SXW +=
rows[i].f * rows[i].f
* mat[j + i * n_cols];
+ SXW +=
pow2 (rows[i].f)
* mat[j + i * n_cols];
cum += rows[i].f * mat[j + i * n_cols];
}
cum += rows[i].f * mat[j + i * n_cols];
}
@@
-3193,7
+3193,7
@@
calc_directional (double v[N_DIRECTIONAL], double ase[N_DIRECTIONAL],
for (sum_Yc = sum_Y2c = 0., i = 0; i < n_cols; i++)
{
sum_Yc += cols[i].f * col_tot[i];
for (sum_Yc = sum_Y2c = 0., i = 0; i < n_cols; i++)
{
sum_Yc += cols[i].f * col_tot[i];
- sum_Y2c +=
cols[i].f * cols[i].f
* col_tot[i];
+ sum_Y2c +=
pow2 (cols[i].f)
* col_tot[i];
}
SY = sum_Y2c - sum_Yc * sum_Yc / W;
}
SY = sum_Y2c - sum_Yc * sum_Yc / W;
@@
-3203,7
+3203,7
@@
calc_directional (double v[N_DIRECTIONAL], double ase[N_DIRECTIONAL],
for (cum = 0., j = 0; j < n_cols; j++)
{
for (cum = 0., j = 0; j < n_cols; j++)
{
- SYW +=
cols[j].f * cols[j].f
* mat[j + i * n_cols];
+ SYW +=
pow2 (cols[j].f)
* mat[j + i * n_cols];
cum += cols[j].f * mat[j + i * n_cols];
}
cum += cols[j].f * mat[j + i * n_cols];
}