3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Green Red Orange Magenta Azure Cyan Skyblue
46 static void my_usage(char *prog
,char *arg
)
48 fprintf(stderr
," Usage: %s [-p] [-s] [-c #columns]"
49 " naver < infile > outfile\n",prog
);
50 fprintf(stderr
,"-p means picoseconds rather than nanoseconds\n");
51 fprintf(stderr
,"-s means silent rather than verbose\n");
52 fprintf(stderr
,"Don't ever use argument %s again!\n",arg
);
56 void lsq_y_ax_b_double(int n
, double x
[], double y
[], double *a
, double *b
)
62 for (i
=0; (i
< n
); i
++) {
68 *a
=(n
*yx
-sy
*sx
)/(n
*xx
-sx
*sx
);
72 int main(int argc
, char *argv
[])
74 double *x
,**y
,value
=0.001;
75 double *yav
,yyy
,yyy2
,ymin
,ymax
,aver
,var
,sd
;
76 int i
,j
,k
,nav
=100,ncol
=1,MAX
=50000;
78 bool bSilent
=FALSE
,bVerySilent
=FALSE
;
79 double lsq_a
,lsq_b
,rms_res
;
81 for(i
=1; (i
<argc
); i
++) {
82 if (argv
[i
][0] == '-')
88 MAX
=iscan(argc
,argv
,&i
);
91 ncol
=iscan(argc
,argv
,&i
);
97 bVerySilent
=bSilent
=TRUE
;
100 my_usage(argv
[0],argv
[i
]);
103 nav
=strtol(argv
[i
],NULL
,10);
106 fprintf(stderr
,"Will average stdin with %d columns, over %d points\n",
112 for(i
=0; (i
<ncol
); i
++) {
118 if (scanf("%s",buf
) == 1) {
119 if ((buf
[0] != '@') && (buf
[0] != '#')) {
120 sscanf(buf
,"%lf",&x
[i
]);
121 for(k
=0; (k
<ncol
); k
++)
122 scanf("%lf",&(y
[k
][i
]));
125 printf("%10e",x
[i
-nav
/2]*value
);
126 for(k
=0; (k
<ncol
); k
++) {
128 for(j
=i
-nav
+1; (j
<=i
); j
++)
132 printf(" %10e",yav
[k
]);
140 while (getc(stdin
) != '\n')
146 } while (((int)strlen(buf
) > 0) && (i
<MAX
));
150 fprintf(stderr
,"%3s %12s %12s %12s %12s %12s %12s %12s\n",
151 "i","min","aver","max","var","sd","drift","fluc");
152 for(k
=0; (k
<ncol
); k
++) {
157 for(j
=1; (j
<i
); j
++) {
167 var
=yyy2
/i
-aver
*aver
;
170 lsq_y_ax_b_double(i
,x
,y
[k
],&lsq_a
,&lsq_b
);
173 rms_res
+=sqr(y
[k
][j
]-(lsq_a
*x
[j
]+lsq_b
));
174 rms_res
=sqrt(rms_res
/i
);
176 fprintf(stderr
,"%3d %12g %12g %12g %12g %12g %12g %12g\n",
177 k
,ymin
,aver
,ymax
,var
,sd
,lsq_a
,rms_res
);