[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src/math/ts innovations.c innovations.h
From: |
Jason H Stover |
Subject: |
[Pspp-cvs] pspp/src/math/ts innovations.c innovations.h |
Date: |
Wed, 07 Jun 2006 22:32:30 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Jason H Stover <jstover> 06/06/07 22:32:30
Modified files:
src/math/ts : innovations.c innovations.h
Log message:
fixed mistakes
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.c?cvsroot=pspp&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ts/innovations.h?cvsroot=pspp&r1=1.1&r2=1.2
Patches:
Index: innovations.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/innovations.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- innovations.c 7 Jun 2006 01:52:48 -0000 1.2
+++ innovations.c 7 Jun 2006 22:32:30 -0000 1.3
@@ -88,10 +88,10 @@
bool value = true;
size_t lag = 0;
- while (value)
+ while (value && lag < max_lag)
{
lag++;
- value = casereader_read (r, c + lag);
+ value = casereader_read (r, c[lag]);
}
return value;
}
@@ -109,27 +109,28 @@
{
c[lag] = c[lag+1];
}
- value = casereader_read (r, c + lag);
+ value = casereader_read (r, c[lag]);
return value;
}
static void
get_covariance (size_t n_vars, const struct casefile *cf,
- struct innovations **est, size_t max_lag)
+ struct innovations_estimate **est, size_t max_lag)
{
struct casereader *r;
struct ccase **c;
- struct ccase *cur_case;
size_t lag;
- size_t n_vars;
+ size_t n;
bool read_case = false;
double d;
- double tmp;
+ double x;
+ const union value *tmp;
+ const union value *tmp2;
c = xnmalloc (max_lag, sizeof (*c));
for (lag = 0; lag < max_lag; lag++)
{
- c[lag] = xmalloc (sizeof *c[i]);
+ c[lag] = xmalloc (sizeof *c[lag]);
}
r = casefile_get_reader (cf);
@@ -139,17 +140,17 @@
{
for (n = 0; n < n_vars; n++)
{
- cur_case = case_data (c[0], est[n]->variable->fv);
- if (!mv_is_value_missing (&est[n]->variable->miss, cur_case))
+ tmp2 = case_data (c[0], est[n]->variable->fv);
+ if (!mv_is_value_missing (&est[n]->variable->miss, tmp2))
{
- cur_case -= est[n]->mean;
+ x = tmp2->f - est[n]->mean;
for (lag = 1; lag <= max_lag; lag++)
{
tmp = case_data (c[lag], est[n]->variable->fv);
if (!mv_is_value_missing (&est[n]->variable->miss, tmp))
{
- d = (tmp - est[n]->mean);
- *(est[n]->cov + lag) += d * cur_case;
+ d = (tmp->f - est[n]->mean);
+ *(est[n]->cov + lag) += d * x;
}
}
}
@@ -174,8 +175,6 @@
size_t lag, const struct
casefile *cf)
{
struct innovations_estimate **est;
- struct casereader *r;
- struct ccase *c;
size_t i;
size_t j;
@@ -192,7 +191,7 @@
est[i]->coeff = xnmalloc (lag, sizeof (*est[i]->coeff));
for (j = 0; j < lag; j++)
{
- est[i]->coeff + j = xmalloc (sizeof (*(est[i]->coeff + j)));
+ est[i]->coeff[j] = xmalloc (sizeof (*(est[i]->coeff + j)));
}
}
else
@@ -208,4 +207,6 @@
*/
get_mean_variance (*n_vars, cf, est);
get_covariance (*n_vars, cf, est, lag);
+
+ return est;
}
Index: innovations.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/math/ts/innovations.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- innovations.h 7 Jun 2006 01:52:48 -0000 1.1
+++ innovations.h 7 Jun 2006 22:32:30 -0000 1.2
@@ -32,12 +32,14 @@
#include <math/coefficient.h>
struct innovations_estimate
{
- struct variable *variable;
+ const struct variable *variable;
double mean;
double variance;
double *cov;
double n_obs;
double max_lag;
- coefficient *coeff;
+ coefficient **coeff;
};
+struct innovations_estimate ** pspp_innovations (const struct variable **,
size_t *,
+ size_t, const struct casefile
*);
#endif