/* PSPP - a program for statistical analysis. -*-c-*-
- Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2008, 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
#include <language/stats/binomial.h>
#include <language/stats/chisquare.h>
#include <language/stats/wilcoxon.h>
+#include <language/stats/sign.h>
#include <libpspp/hash.h>
#include <libpspp/pool.h>
#include <libpspp/taint.h>
test->insert_variables (test, var_hash);
}
- npar_specs.vv = (const struct variable **) const_hsh_data (var_hash);
+ npar_specs.vv = (const struct variable **) const_hsh_sort (var_hash);
npar_specs.n_vars = const_hsh_count (var_hash);
if ( cmd.sbc_statistics )
struct npar_specs *specs = aux;
struct chisquare_test *cstp = pool_alloc(specs->pool, sizeof(*cstp));
- struct one_sample_test *tp = (struct one_sample_test *) cstp;
+ struct one_sample_test *tp = &cstp->parent;
+ struct npar_test *nt = &tp->parent;
- ((struct npar_test *)tp)->execute = chisquare_execute;
- ((struct npar_test *)tp)->insert_variables = one_sample_insert_variables;
+ nt->execute = chisquare_execute;
+ nt->insert_variables = one_sample_insert_variables;
if (!parse_variables_const_pool (lexer, specs->pool, dataset_dict (ds),
&tp->vars, &tp->n_vars,
specs->test,
sizeof(*specs->test) * specs->n_tests);
- specs->test[specs->n_tests - 1] = (struct npar_test *) tp;
+ specs->test[specs->n_tests - 1] = nt;
return 1;
}
{
struct npar_specs *specs = aux;
struct binomial_test *btp = pool_alloc(specs->pool, sizeof(*btp));
- struct one_sample_test *tp = (struct one_sample_test *) btp;
+ struct one_sample_test *tp = &btp->parent;
+ struct npar_test *nt = &tp->parent;
- ((struct npar_test *)tp)->execute = binomial_execute;
- ((struct npar_test *)tp)->insert_variables = one_sample_insert_variables;
+ nt->execute = binomial_execute;
+ nt->insert_variables = one_sample_insert_variables;
btp->category1 = btp->category2 = btp->cutpoint = SYSMIS;
{
lex_force_num (lexer);
btp->category1 = lex_number (lexer);
- lex_get (lexer);
- if ( ! lex_force_match (lexer, ',')) return 2;
- if ( ! lex_force_num (lexer) ) return 2;
- btp->category2 = lex_number (lexer);
- lex_get (lexer);
+ lex_get (lexer);
+ if ( lex_match (lexer, ','))
+ {
+ if ( ! lex_force_num (lexer) ) return 2;
+ btp->category2 = lex_number (lexer);
+ lex_get (lexer);
+ }
+ else
+ {
+ btp->cutpoint = btp->category1;
+ }
+
lex_force_match (lexer, ')');
}
}
else
return 2;
}
- else
- {
- if ( lex_match (lexer, '(') )
- {
- lex_force_num (lexer);
- btp->cutpoint = lex_number (lexer);
- lex_get (lexer);
- lex_force_match (lexer, ')');
- }
- }
specs->n_tests++;
specs->test = pool_realloc (specs->pool,
specs->test,
sizeof(*specs->test) * specs->n_tests);
- specs->test[specs->n_tests - 1] = (struct npar_test *) tp;
+ specs->test[specs->n_tests - 1] = nt;
return 1;
}
const struct variable **vlist2;
size_t n_vlist2;
- ((struct npar_test *)test_parameters)->insert_variables = two_sample_insert_variables;
+ test_parameters->parent.insert_variables = two_sample_insert_variables;
if (!parse_variables_const_pool (lexer, pool,
dict,
struct npar_specs *specs = aux;
struct two_sample_test *tp = pool_alloc (specs->pool, sizeof(*tp));
- ((struct npar_test *)tp)->execute = wilcoxon_execute;
+ struct npar_test *nt = &tp->parent;
+ nt->execute = wilcoxon_execute;
if (!parse_two_sample_related_test (lexer, dataset_dict (ds), cmd,
tp, specs->pool) )
specs->test = pool_realloc (specs->pool,
specs->test,
sizeof(*specs->test) * specs->n_tests);
- specs->test[specs->n_tests - 1] = (struct npar_test *) tp;
+ specs->test[specs->n_tests - 1] = nt;
return 1;
}
struct npar_specs *specs = aux;
struct two_sample_test *tp = pool_alloc(specs->pool, sizeof(*tp));
- ((struct npar_test *)tp)->execute = NULL;
+ struct npar_test *nt = &tp->parent;
+ nt->execute = NULL;
if (!parse_two_sample_related_test (lexer, dataset_dict (ds),
specs->test = pool_realloc (specs->pool,
specs->test,
sizeof(*specs->test) * specs->n_tests);
- specs->test[specs->n_tests - 1] = (struct npar_test *) tp;
+ specs->test[specs->n_tests - 1] = nt;
return 1;
}
struct npar_specs *specs = aux;
struct two_sample_test *tp = pool_alloc(specs->pool, sizeof(*tp));
- ((struct npar_test *)tp)->execute = NULL;
+ struct npar_test *nt = &tp->parent;
+ nt->execute = sign_execute;
if (!parse_two_sample_related_test (lexer, dataset_dict (ds), cmd,
tp, specs->pool) )
specs->test = pool_realloc (specs->pool,
specs->test,
sizeof(*specs->test) * specs->n_tests);
- specs->test[specs->n_tests - 1] = (struct npar_test *) tp;
+ specs->test[specs->n_tests - 1] = nt;
return 1;
}