projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pspp-dump-sav: Add GNU standards compliant command line interface.
[pspp]
/
src
/
math
/
order-stats.c
diff --git
a/src/math/order-stats.c
b/src/math/order-stats.c
index ca4160f4fdf6f52b09d82972edf10f6d8f4f6703..be9c49a3122171b6f1eee792a802e080ab2f4150 100644
(file)
--- a/
src/math/order-stats.c
+++ b/
src/math/order-stats.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008
, 2009, 2011
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
@@
-15,14
+15,18
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
-#include "order-stats.h"
-#include <libpspp/assertion.h>
-#include <data/val-type.h>
-#include <gl/xalloc.h>
-#include <data/variable.h>
-#include <data/casereader.h>
+
+#include "math/order-stats.h"
+
#include <string.h>
#include <string.h>
+#include "data/casereader.h"
+#include "data/val-type.h"
+#include "data/variable.h"
+#include "libpspp/assertion.h"
+
+#include "gl/xalloc.h"
+
#if 0
#include <stdio.h>
#if 0
#include <stdio.h>
@@
-90,7
+94,7
@@
update_k_values (const struct ccase *cx, double y_i, double c_i, double cc_i,
{
int k;
struct order_stats *tos = os[j];
{
int k;
struct order_stats *tos = os[j];
- struct statistic *stat =
(struct statistic *) tos
;
+ struct statistic *stat =
&tos->parent
;
for (k = 0 ; k < tos->n_k; ++k)
{
struct k *myk = &tos->k[k];
for (k = 0 ; k < tos->n_k; ++k)
{
struct k *myk = &tos->k[k];
@@
-113,44
+117,41
@@
order_stats_accumulate (struct order_stats **os, size_t nos,
const struct variable *var,
enum mv_class exclude)
{
const struct variable *var,
enum mv_class exclude)
{
- struct ccase cx;
- struct ccase
prev_cx
;
+ struct ccase
*
cx;
+ struct ccase
*prev_cx = NULL
;
double prev_value = -DBL_MAX;
double cc_i = 0;
double c_i = 0;
double prev_value = -DBL_MAX;
double cc_i = 0;
double c_i = 0;
- case_nullify (&prev_cx);
-
- for (; casereader_read (reader, &cx); case_destroy (&cx))
+ for (; (cx = casereader_read (reader)) != NULL; case_unref (cx))
{
{
- const double weight = wv ? case_data (
&
cx, wv)->f : 1.0;
- const double this_value = case_data (
&
cx, var)->f;
+ const double weight = wv ? case_data (cx, wv)->f : 1.0;
+ const double this_value = case_data (cx, var)->f;
/* The casereader MUST be sorted */
assert (this_value >= prev_value);
/* The casereader MUST be sorted */
assert (this_value >= prev_value);
- if ( var_is_value_missing (var, case_data (
&
cx, var), exclude))
+ if ( var_is_value_missing (var, case_data (cx, var), exclude))
continue;
continue;
- case_destroy (&prev_cx);
-
if ( prev_value == -DBL_MAX || prev_value == this_value)
c_i += weight;
if ( prev_value > -DBL_MAX && this_value > prev_value)
{
if ( prev_value == -DBL_MAX || prev_value == this_value)
c_i += weight;
if ( prev_value > -DBL_MAX && this_value > prev_value)
{
- update_k_values (
&
prev_cx, prev_value, c_i, cc_i, os, nos);
+ update_k_values (prev_cx, prev_value, c_i, cc_i, os, nos);
c_i = weight;
}
c_i = weight;
}
+ case_unref (prev_cx);
cc_i += weight;
prev_value = this_value;
cc_i += weight;
prev_value = this_value;
-
case_clone (&prev_cx, &
cx);
+
prev_cx = case_ref (
cx);
}
}
- update_k_values (
&
prev_cx, prev_value, c_i, cc_i, os, nos);
- case_
destroy (&
prev_cx);
+ update_k_values (prev_cx, prev_value, c_i, cc_i, os, nos);
+ case_
unref (
prev_cx);
casereader_destroy (reader);
}
casereader_destroy (reader);
}