45 |
/* SAMPLE transformation. */ |
/* SAMPLE transformation. */ |
46 |
struct sample_trns |
struct sample_trns |
47 |
{ |
{ |
|
struct trns_header h; |
|
48 |
int type; /* One of TYPE_*. */ |
int type; /* One of TYPE_*. */ |
49 |
int n, N; /* TYPE_A_FROM_B: n from N. */ |
int n, N; /* TYPE_A_FROM_B: n from N. */ |
50 |
int m, t; /* TYPE_A_FROM_B: # picked so far; # so far. */ |
int m, t; /* TYPE_A_FROM_B: # picked so far; # so far. */ |
52 |
}; |
}; |
53 |
|
|
54 |
static trns_proc_func sample_trns_proc; |
static trns_proc_func sample_trns_proc; |
55 |
|
static trns_free_func sample_trns_free; |
56 |
|
|
57 |
int |
int |
58 |
cmd_sample (void) |
cmd_sample (void) |
104 |
lex_get (); |
lex_get (); |
105 |
|
|
106 |
trns = xmalloc (sizeof *trns); |
trns = xmalloc (sizeof *trns); |
|
trns->h.proc = sample_trns_proc; |
|
|
trns->h.free = NULL; |
|
107 |
trns->type = type; |
trns->type = type; |
108 |
trns->n = a; |
trns->n = a; |
109 |
trns->N = b; |
trns->N = b; |
110 |
trns->m = trns->t = 0; |
trns->m = trns->t = 0; |
111 |
trns->frac = frac; |
trns->frac = frac; |
112 |
add_transformation ((struct trns_header *) trns); |
add_transformation (sample_trns_proc, sample_trns_free, trns); |
113 |
|
|
114 |
return lex_end_of_command (); |
return lex_end_of_command (); |
115 |
} |
} |
116 |
|
|
117 |
/* Executes a SAMPLE transformation. */ |
/* Executes a SAMPLE transformation. */ |
118 |
static int |
static int |
119 |
sample_trns_proc (struct trns_header * trns, struct ccase *c UNUSED, |
sample_trns_proc (void *t_, struct ccase *c UNUSED, |
120 |
int case_num UNUSED) |
int case_num UNUSED) |
121 |
{ |
{ |
122 |
struct sample_trns *t = (struct sample_trns *) trns; |
struct sample_trns *t = t_; |
123 |
double U; |
double U; |
124 |
|
|
125 |
if (t->type == TYPE_FRACTION) |
if (t->type == TYPE_FRACTION) |
146 |
return -1; |
return -1; |
147 |
} |
} |
148 |
} |
} |
149 |
|
|
150 |
|
static void |
151 |
|
sample_trns_free (void *t_) |
152 |
|
{ |
153 |
|
struct sample_trns *t = t_; |
154 |
|
free (t); |
155 |
|
} |