/* tdrmod.c CCMATH mathematics library source code. * * Copyright (C) 2000 Daniel A. Atkinson All rights reserved. * This code may be redistributed under the terms of the GNU library * public license (LGPL). ( See the lgpl.license file for details.) * ------------------------------------------------------------------------ */ /* Test: drmod setdr Uses: sarma setsim nrml setnrml Input parameters: n -> integer: size of time series model_file -> name of ARMA model specification file [ ts?.dat ] */ #include "ccmath.h" struct mcof *par,*pma; int nar,nma,np; void main(int na,char **av) { struct mcof *pa; int n,i,j; unsigned int seed; double y,*dr,e; FILE *fp; if(na!=3){ printf("para: n model_file\n"); exit(1);} printf(" Test of Time Series Derivative Computation\n\n"); n=atoi(*++av); fp=fopen(*++av,"r"); printf(" model file: %s\n",*av); /* load and print model parameters */ fscanf(fp,"%d %d",&nar,&nma); np=nar+nma; par=(struct mcof *)calloc(np,sizeof(*pa)); dr=(double *)calloc(np,sizeof(*dr)); pma=par+nar; printf(" model inputs:\n"); for(j=0,pa=par; jcf),&(pa->lag)); printf(" %6.3f %2d ",pa->cf,pa->lag); if(jlag-=1; } /* initialize series simulation */ fscanf(fp,"%u",&seed); setnrml(seed); printf(" random seed= %u\n",seed); setdr(1); setsim(1); /* simulate series */ printf(" y e ep derivatives\n"); for(j=0; j