Reorganizing analysis of correlation functions.
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Wed, 21 May 2014 14:38:25 +0000 (16:38 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 14 Oct 2014 18:16:34 +0000 (20:16 +0200)
Moved routines computing correlation functions and
fitting to those in a special subdirectory not
dependent on gmxana. The autocorrelation now functions
as it should (previously there were issues with long
time correlations).

Replaced Levenberg-Marquardt algorithm by another implementation
from http://apps.jcns.fz-juelich.de/doku/sc/lmfit,
under a FreeBSD license. This code is in src/external/lmfit.

Added Doxygen comments to all headers.

Fixed wordcount algorithm in xvgr.c

The routines many_auto_correl and many_cross_correl
are optimized using OpenMP.

Change-Id: Ifbe003437db36e35d606cd942bb38deeef86ea64

69 files changed:
COPYING
cmake/legacy_and_external.supp
src/external/lmfit/README [new file with mode: 0644]
src/external/lmfit/lmcurve.c [new file with mode: 0644]
src/external/lmfit/lmcurve.h [new file with mode: 0644]
src/external/lmfit/lmmin.c [new file with mode: 0644]
src/external/lmfit/lmmin.h [new file with mode: 0644]
src/external/lmfit/lmstruct.h [new file with mode: 0644]
src/gromacs/CMakeLists.txt
src/gromacs/correlationfunctions/CMakeLists.txt [new file with mode: 0644]
src/gromacs/correlationfunctions/autocorr.c [moved from src/gromacs/gmxana/autocorr.c with 72% similarity]
src/gromacs/correlationfunctions/autocorr.h [new file with mode: 0644]
src/gromacs/correlationfunctions/crosscorr.c [new file with mode: 0644]
src/gromacs/correlationfunctions/crosscorr.h [new file with mode: 0644]
src/gromacs/correlationfunctions/expfit.c [new file with mode: 0644]
src/gromacs/correlationfunctions/expfit.h [new file with mode: 0644]
src/gromacs/correlationfunctions/integrate.c [new file with mode: 0644]
src/gromacs/correlationfunctions/integrate.h [new file with mode: 0644]
src/gromacs/correlationfunctions/manyautocorrelation.c [new file with mode: 0644]
src/gromacs/correlationfunctions/manyautocorrelation.h [new file with mode: 0644]
src/gromacs/correlationfunctions/polynomials.c [moved from src/gromacs/gmxana/polynomials.c with 79% similarity]
src/gromacs/correlationfunctions/polynomials.h [moved from src/gromacs/gmxana/correl.h with 70% similarity]
src/gromacs/correlationfunctions/tests/CMakeLists.txt [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/autocorr.cpp [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/correlationdataset.cpp [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/correlationdataset.h [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/expfit.cpp [new file with mode: 0755]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacCos.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacNormal.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP0.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP1.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP2.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP3.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP4.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacRcross.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacVector.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERF.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERREST.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP1.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP2.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP3.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP5.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP7.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP9.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnPRES.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnVAC.xml [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/testCOS3.xvg [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/testEXP.xvg [new file with mode: 0644]
src/gromacs/correlationfunctions/tests/testINVEXP.xvg [new file with mode: 0755]
src/gromacs/correlationfunctions/tests/testPRES.xvg [new file with mode: 0644]
src/gromacs/fileio/xvgr.cpp
src/gromacs/gmxana/correl.c [deleted file]
src/gromacs/gmxana/expfit.c [deleted file]
src/gromacs/gmxana/gmx_analyze.c
src/gromacs/gmxana/gmx_angle.c
src/gromacs/gmxana/gmx_chi.c
src/gromacs/gmxana/gmx_densorder.cpp
src/gromacs/gmxana/gmx_dielectric.c
src/gromacs/gmxana/gmx_dipoles.cpp
src/gromacs/gmxana/gmx_dos.c
src/gromacs/gmxana/gmx_energy.c
src/gromacs/gmxana/gmx_gyrate.c
src/gromacs/gmxana/gmx_hbond.c
src/gromacs/gmxana/gmx_rdf.c
src/gromacs/gmxana/gmx_rotacf.c
src/gromacs/gmxana/gmx_tcaf.c
src/gromacs/gmxana/gmx_velacc.c
src/gromacs/gmxana/gstat.h
src/gromacs/gmxana/levenmar.c [deleted file]

diff --git a/COPYING b/COPYING
index dddffe127ded8cb5974072599aaeb7641c571e4a..e2737f31982168c1f06adf4897400208fe093149 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -20,6 +20,7 @@ This file contains the licenses for the following bodies of code:
 10. Sun FDLIBM (Freely Distributable Maths Library)
 11. Random123
 12. md5
+13. lmfit
 
 Our chosen method for packaging distributions (CPack) only permits a
 package to have a single license file, so we are unfortunately forced
@@ -1215,3 +1216,36 @@ freely, subject to the following restrictions:
 
 L. Peter Deutsch
 ghost@aladdin.com
+
+13. lmfit
+============================================
+The package lmfit is distributed under the FreeBSD License:
+
+--
+  Copyright (c) 1980-1999 University of Chicago,
+                          as operator of Argonne National Laboratory
+  Copyright (c) 2004-2013 Joachim Wuttke, Forschungszentrum Juelich GmbH
+
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+
+  - Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+  - Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+  This software is provided by the copyright holders and contributors "as is"
+  and any express or implied warranties, including, but not limited to, the
+  implied warranties of merchantability and fitness for a particular purpose
+  are disclaimed. In no event shall the copyright holder or contributors
+  be liable for any direct, indirect, incidental, special, exemplary, or
+  consequential damages (including, but not limited to, procurement of
+  substitute goods or services; loss of use, data, or profits; or business
+  interruption) however caused and on any theory of liability, whether in
+  contract, strict liability, or tort (including negligence or otherwise)
+  arising in any way out of the use of this software, even if advised of the
+  possibility of such damage.
+--
index 082fcc14ae51c18e905299c884f0b73a6880a677..9a3166352dea0c42942eaa798acd65c5294bffc6 100644 (file)
    fun:make_unsp
    fun:nsc_dclm_pbc
 }
-
+{
+   libgomp
+   Memcheck:Leak
+   ...
+   obj:*/libgomp.so*
+}
 {
    ctime_r
    Memcheck:Leak
    ...
    fun:ctime_r
 }
-
 {
    libz
    Memcheck:Cond
    ...
    fun:__kmpc_global_thread_num
 }
+
diff --git a/src/external/lmfit/README b/src/external/lmfit/README
new file mode 100644 (file)
index 0000000..618129e
--- /dev/null
@@ -0,0 +1,5 @@
+This directory contains only the barebone version of the
+lmfit package, version 5.1. Full version is available from
+http://apps.jcns.fz-juelich.de/doku/sc/lmfit
+
+License in gromacs root directory in file COPYING
diff --git a/src/external/lmfit/lmcurve.c b/src/external/lmfit/lmcurve.c
new file mode 100644 (file)
index 0000000..838f884
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Library:   lmfit (Levenberg-Marquardt least squares fitting)
+ *
+ * File:      lmcurve.c
+ *
+ * Contents:  Levenberg-Marquardt curve-fitting
+ *
+ * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
+ *
+ * License:   see ../COPYING (FreeBSD)
+ *
+ * Homepage:  apps.jcns.fz-juelich.de/lmfit
+ */
+
+#include "lmmin.h"
+#include "gromacs/utility/basedefinitions.h"
+
+typedef struct {
+    const double *t;
+    const double *y;
+    double (*f)(double t, const double *par);
+} lmcurve_data_struct;
+
+
+void lmcurve_evaluate( const double *par, int m_dat, const void *data,
+                       double *fvec, gmx_unused int *info )
+{
+    int i;
+    for (i = 0; i < m_dat; i++)
+    {
+        fvec[i] =
+            ((lmcurve_data_struct*)data)->y[i] -
+            ((lmcurve_data_struct*)data)->f(
+                    ((lmcurve_data_struct*)data)->t[i], par );
+    }
+}
+
+
+void lmcurve( int n_par, double *par, int m_dat,
+              const double *t, const double *y,
+              double (*f)( double t, const double *par ),
+              const lm_control_struct *control,
+              lm_status_struct *status )
+{
+    lmcurve_data_struct data;
+    data.t = t;
+    data.y = y;
+    data.f = f;
+
+    lmmin( n_par, par, m_dat, (const void*) &data,
+           lmcurve_evaluate, control, status );
+}
diff --git a/src/external/lmfit/lmcurve.h b/src/external/lmfit/lmcurve.h
new file mode 100644 (file)
index 0000000..d74114c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Library:   lmfit (Levenberg-Marquardt least squares fitting)
+ *
+ * File:      lmcurve.h
+ *
+ * Contents:  Declarations for Levenberg-Marquardt curve fitting.
+ *
+ * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
+ *
+ * License:   see ../COPYING (FreeBSD)
+ *
+ * Homepage:  apps.jcns.fz-juelich.de/lmfit
+ */
+
+#ifndef LMCURVE_H
+#define LMCURVE_H
+#undef __BEGIN_DECLS
+#undef __END_DECLS
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS /* empty */
+# define __END_DECLS   /* empty */
+#endif
+
+#include "lmstruct.h"
+
+__BEGIN_DECLS
+
+void lmcurve( int n_par, double *par, int m_dat,
+              const double *t, const double *y,
+              double (*f)( double t, const double *par ),
+              const lm_control_struct *control,
+              lm_status_struct *status );
+
+__END_DECLS
+#endif /* LMCURVE_H */
diff --git a/src/external/lmfit/lmmin.c b/src/external/lmfit/lmmin.c
new file mode 100644 (file)
index 0000000..b6b8dfc
--- /dev/null
@@ -0,0 +1,1389 @@
+/*
+ * Library:   lmfit (Levenberg-Marquardt least squares fitting)
+ *
+ * File:      lmmin.c
+ *
+ * Contents:  Levenberg-Marquardt minimization.
+ *
+ * Copyright: MINPACK authors, The University of Chikago (1980-1999)
+ *            Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
+ *
+ * License:   see ../COPYING (FreeBSD)
+ *
+ * Homepage:  apps.jcns.fz-juelich.de/lmfit
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+#include "lmmin.h"
+
+#define MIN(a, b) (((a) <= (b)) ? (a) : (b))
+#define MAX(a, b) (((a) >= (b)) ? (a) : (b))
+#define SQR(x)   (x)*(x)
+
+/* function declarations (implemented below). */
+void lm_lmpar( int n, double *r, int ldr, int *ipvt, double *diag,
+               double *qtb, double delta, double *par, double *x,
+               double *sdiag, double *aux, double *xdi );
+void lm_qrfac( int m, int n, double *a, int *ipvt,
+               double *rdiag, double *acnorm, double *wa );
+void lm_qrsolv( int n, double *r, int ldr, int *ipvt, double *diag,
+                double *qtb, double *x, double *sdiag, double *wa );
+
+
+/*****************************************************************************/
+/*  Numeric constants                                                        */
+/*****************************************************************************/
+
+/* machine-dependent constants from float.h */
+#define LM_MACHEP     DBL_EPSILON   /* resolution of arithmetic */
+#define LM_DWARF      DBL_MIN       /* smallest nonzero number */
+#define LM_SQRT_DWARF sqrt(DBL_MIN) /* square should not underflow */
+#define LM_SQRT_GIANT sqrt(DBL_MAX) /* square should not overflow */
+#define LM_USERTOL    30*LM_MACHEP  /* users are recommended to require this */
+
+/* If the above values do not work, the following seem good for an x86:
+   LM_MACHEP     .555e-16
+   LM_DWARF      9.9e-324
+   LM_SQRT_DWARF 1.e-160
+   LM_SQRT_GIANT 1.e150
+   LM_USER_TOL   1.e-14
+   The following values should work on any machine:
+   LM_MACHEP     1.2e-16
+   LM_DWARF      1.0e-38
+   LM_SQRT_DWARF 3.834e-20
+   LM_SQRT_GIANT 1.304e19
+   LM_USER_TOL   1.e-14
+ */
+
+const lm_control_struct lm_control_double = {
+    LM_USERTOL, LM_USERTOL, LM_USERTOL, LM_USERTOL, 100., 100, 1,
+    NULL, 0, -1, -1
+};
+const lm_control_struct lm_control_float = {
+    1.e-7,      1.e-7,      1.e-7,      1.e-7,      100., 100, 1,
+    NULL, 0, -1, -1
+};
+
+
+/*****************************************************************************/
+/*  Message texts (indexed by status.info)                                   */
+/*****************************************************************************/
+
+const char *lm_infmsg[] = {
+    "found zero (sum of squares below underflow limit)",
+    "converged  (the relative error in the sum of squares is at most tol)",
+    "converged  (the relative error of the parameter vector is at most tol)",
+    "converged  (both errors are at most tol)",
+    "trapped    (by degeneracy; increasing epsilon might help)",
+    "exhausted  (number of function calls exceeding preset patience)",
+    "failed     (ftol<tol: cannot reduce sum of squares any further)",
+    "failed     (xtol<tol: cannot improve approximate solution any further)",
+    "failed     (gtol<tol: cannot improve approximate solution any further)",
+    "crashed    (not enough memory)",
+    "exploded   (fatal coding error: improper input parameters)",
+    "stopped    (break requested within function evaluation)"
+};
+
+const char *lm_shortmsg[] = {
+    "found zero",
+    "converged (f)",
+    "converged (p)",
+    "converged (2)",
+    "degenerate",
+    "call limit",
+    "failed (f)",
+    "failed (p)",
+    "failed (o)",
+    "no memory",
+    "invalid input",
+    "user break"
+};
+
+
+/*****************************************************************************/
+/*  Monitoring auxiliaries.                                                  */
+/*****************************************************************************/
+
+void lm_print_pars( int nout, const double *par, double fnorm, FILE* fout )
+{
+    int i;
+    for (i = 0; i < nout; ++i)
+    {
+        fprintf( fout, " %16.9g", par[i] );
+    }
+    fprintf( fout, " => %18.11g\n", fnorm );
+}
+
+
+/*****************************************************************************/
+/*  lmmin (main minimization routine)                                        */
+/*****************************************************************************/
+
+void lmmin( int n, double *x, int m, const void *data,
+            void (*evaluate) (const double *par, int m_dat, const void *data,
+                              double *fvec, int *userbreak),
+            const lm_control_struct *C, lm_status_struct *S )
+{
+    double       *fvec, *diag, *fjac, *qtf, *wa1, *wa2, *wa3, *wf;
+    int          *ipvt;
+    int           j, i;
+    double        actred, dirder, fnorm, fnorm1, gnorm, pnorm,
+                  prered, ratio, step, sum, temp, temp1, temp2, temp3;
+    static double p0001 = 1.0e-4;
+
+    int           maxfev = C->patience * (n+1);
+
+    int           outer, inner;  /* loop counters, for monitoring */
+    int           inner_success; /* flag for loop control */
+    double        lmpar = 0;     /* Levenberg-Marquardt parameter */
+    double        delta = 0;
+    double        xnorm = 0;
+    double        eps   = sqrt(MAX(C->epsilon, LM_MACHEP)); /* for forward differences */
+
+    int           nout = C->n_maxpri == -1 ? n : MIN( C->n_maxpri, n );
+
+    /* The workaround msgfile=NULL is needed for default initialization */
+    FILE* msgfile = C->msgfile ? C->msgfile : stdout;
+
+    /* Default status info; must be set ahead of first return statements */
+    S->outcome   = 0; /* status code */
+    S->userbreak = 0;
+    S->nfev      = 0; /* function evaluation counter */
+
+/***  Check input parameters for errors.  ***/
+
+    if (n <= 0)
+    {
+        fprintf( stderr, "lmmin: invalid number of parameters %i\n", n );
+        S->outcome = 10; /* invalid parameter */
+        return;
+    }
+    if (m < n)
+    {
+        fprintf( stderr, "lmmin: number of data points (%i) "
+                 "smaller than number of parameters (%i)\n", m, n );
+        S->outcome = 10;
+        return;
+    }
+    if (C->ftol < 0. || C->xtol < 0. || C->gtol < 0.)
+    {
+        fprintf( stderr,
+                 "lmmin: negative tolerance (at least one of %g %g %g)\n",
+                 C->ftol, C->xtol, C->gtol );
+        S->outcome = 10;
+        return;
+    }
+    if (maxfev <= 0)
+    {
+        fprintf( stderr, "lmmin: nonpositive function evaluations limit %i\n",
+                 maxfev );
+        S->outcome = 10;
+        return;
+    }
+    if (C->stepbound <= 0.)
+    {
+        fprintf( stderr, "lmmin: nonpositive stepbound %g\n", C->stepbound );
+        S->outcome = 10;
+        return;
+    }
+    if (C->scale_diag != 0 && C->scale_diag != 1)
+    {
+        fprintf( stderr, "lmmin: logical variable scale_diag=%i, "
+                 "should be 0 or 1\n", C->scale_diag );
+        S->outcome = 10;
+        return;
+    }
+
+/***  Allocate work space.  ***/
+    fvec = diag = fjac = qtf = wa1 = wa2 = wa3 = wf = NULL;
+    ipvt = NULL;
+    if ( (fvec = (double *) malloc(m * sizeof(double))) == NULL ||
+         (diag = (double *) malloc(n * sizeof(double))) == NULL ||
+         (qtf  = (double *) malloc(n * sizeof(double))) == NULL ||
+         (fjac = (double *) malloc(n*m*sizeof(double))) == NULL ||
+         (wa1  = (double *) malloc(n * sizeof(double))) == NULL ||
+         (wa2  = (double *) malloc(n * sizeof(double))) == NULL ||
+         (wa3  = (double *) malloc(n * sizeof(double))) == NULL ||
+         (wf  = (double *)  malloc(m * sizeof(double))) == NULL ||
+         (ipvt = (int *)    malloc(n * sizeof(int)   )) == NULL)
+    {
+        S->outcome = 9;
+        if (NULL != fvec)
+        {
+            free(fvec);
+        }
+        if (NULL != diag)
+        {
+            free(diag);
+        }
+        if (NULL != qtf)
+        {
+            free(qtf);
+        }
+        if (NULL != fjac)
+        {
+            free(fjac);
+        }
+        if (NULL != wa1)
+        {
+            free(wa1);
+        }
+        if (NULL != wa2)
+        {
+            free(wa2);
+        }
+        if (NULL != wa3)
+        {
+            free(wa3);
+        }
+        if (NULL != wf)
+        {
+            free(wf);
+        }
+        if (NULL != ipvt)
+        {
+            free(ipvt);
+        }
+        return;
+    }
+
+    if (!C->scale_diag)
+    {
+        for (j = 0; j < n; j++)
+        {
+            diag[j] = 1.;
+        }
+    }
+
+/***  Evaluate function at starting point and calculate norm.  ***/
+
+    (*evaluate)( x, m, data, fvec, &(S->userbreak) );
+    S->nfev = 1;
+    if (S->userbreak)
+    {
+        goto terminate;
+    }
+    fnorm = lm_enorm(m, fvec);
+    if (C->verbosity)
+    {
+        fprintf( msgfile, "lmmin start " );
+        lm_print_pars( nout, x, fnorm, msgfile );
+    }
+    if (fnorm <= LM_DWARF)
+    {
+        S->outcome = 0; /* sum of squares almost zero, nothing to do */
+        goto terminate;
+    }
+
+/***  The outer loop: compute gradient, then descend.  ***/
+
+    for (outer = 0;; ++outer)
+    {
+
+/***  [outer]  Calculate the Jacobian.  ***/
+
+        for (j = 0; j < n; j++)
+        {
+            temp  = x[j];
+            step  = MAX(eps*eps, eps * fabs(temp));
+            x[j] += step; /* replace temporarily */
+            (*evaluate)( x, m, data, wf, &(S->userbreak) );
+            ++(S->nfev);
+            if (S->userbreak)
+            {
+                goto terminate;
+            }
+            for (i = 0; i < m; i++)
+            {
+                fjac[j*m+i] = (wf[i] - fvec[i]) / step;
+            }
+            x[j] = temp; /* restore */
+        }
+        if (C->verbosity >= 10)
+        {
+            /* print the entire matrix */
+            printf("\nlmmin Jacobian\n");
+            for (i = 0; i < m; i++)
+            {
+                printf("  ");
+                for (j = 0; j < n; j++)
+                {
+                    printf("%.5e ", fjac[j*m+i]);
+                }
+                printf("\n");
+            }
+        }
+
+/***  [outer]  Compute the QR factorization of the Jacobian.  ***/
+
+/*      fjac is an m by n array. The upper n by n submatrix of fjac
+ *        is made to contain an upper triangular matrix r with diagonal
+ *        elements of nonincreasing magnitude such that
+ *
+ *              p^T*(jac^T*jac)*p = r^T*r
+ *
+ *              (NOTE: ^T stands for matrix transposition),
+ *
+ *        where p is a permutation matrix and jac is the final calculated
+ *        Jacobian. Column j of p is column ipvt(j) of the identity matrix.
+ *        The lower trapezoidal part of fjac contains information generated
+ *        during the computation of r.
+ *
+ *      ipvt is an integer array of length n. It defines a permutation
+ *        matrix p such that jac*p = q*r, where jac is the final calculated
+ *        Jacobian, q is orthogonal (not stored), and r is upper triangular
+ *        with diagonal elements of nonincreasing magnitude. Column j of p
+ *        is column ipvt(j) of the identity matrix.
+ */
+
+        lm_qrfac(m, n, fjac, ipvt, wa1, wa2, wa3);
+        /* return values are ipvt, wa1=rdiag, wa2=acnorm */
+
+/***  [outer]  Form q^T * fvec and store first n components in qtf.  ***/
+
+        for (i = 0; i < m; i++)
+        {
+            wf[i] = fvec[i];
+        }
+
+        for (j = 0; j < n; j++)
+        {
+            temp3 = fjac[j*m+j];
+            if (temp3 != 0.)
+            {
+                sum = 0;
+                for (i = j; i < m; i++)
+                {
+                    sum += fjac[j*m+i] * wf[i];
+                }
+                temp = -sum / temp3;
+                for (i = j; i < m; i++)
+                {
+                    wf[i] += fjac[j*m+i] * temp;
+                }
+            }
+            fjac[j*m+j] = wa1[j];
+            qtf[j]      = wf[j];
+        }
+
+/***  [outer]  Compute norm of scaled gradient and detect degeneracy.  ***/
+
+        gnorm = 0;
+        for (j = 0; j < n; j++)
+        {
+            if (wa2[ipvt[j]] == 0)
+            {
+                continue;
+            }
+            sum = 0.;
+            for (i = 0; i <= j; i++)
+            {
+                sum += fjac[j*m+i] * qtf[i];
+            }
+            gnorm = MAX( gnorm, fabs( sum / wa2[ipvt[j]] / fnorm ) );
+        }
+
+        if (gnorm <= C->gtol)
+        {
+            S->outcome = 4;
+            goto terminate;
+        }
+
+/***  [outer]  Initialize / update diag and delta. ***/
+
+        if (!outer)
+        {
+            /* first iteration only */
+            if (C->scale_diag)
+            {
+                /* diag := norms of the columns of the initial Jacobian */
+                for (j = 0; j < n; j++)
+                {
+                    diag[j] = wa2[j] ? wa2[j] : 1;
+                }
+                /* xnorm := || D x || */
+                for (j = 0; j < n; j++)
+                {
+                    wa3[j] = diag[j] * x[j];
+                }
+                xnorm = lm_enorm(n, wa3);
+                if (C->verbosity >= 2)
+                {
+                    fprintf( msgfile, "lmmin diag  " );
+                    lm_print_pars( nout, x, xnorm, msgfile );
+                }
+                /* only now print the header for the loop table */
+                if (C->verbosity >= 3)
+                {
+                    fprintf( msgfile, "  o  i     lmpar    prered"
+                             "          ratio    dirder      delta"
+                             "      pnorm                 fnorm" );
+                    for (i = 0; i < nout; ++i)
+                    {
+                        fprintf( msgfile, "               p%i", i );
+                    }
+                    fprintf( msgfile, "\n" );
+                }
+            }
+            else
+            {
+                xnorm = lm_enorm(n, x);
+            }
+            /* initialize the step bound delta. */
+            if (xnorm)
+            {
+                delta = C->stepbound * xnorm;
+            }
+            else
+            {
+                delta = C->stepbound;
+            }
+        }
+        else
+        {
+            if (C->scale_diag)
+            {
+                for (j = 0; j < n; j++)
+                {
+                    diag[j] = MAX( diag[j], wa2[j] );
+                }
+            }
+        }
+
+/***  The inner loop. ***/
+        inner = 0;
+        do
+        {
+
+/***  [inner]  Determine the Levenberg-Marquardt parameter.  ***/
+
+            lm_lmpar( n, fjac, m, ipvt, diag, qtf, delta, &lmpar,
+                      wa1, wa2, wf, wa3 );
+            /* used return values are fjac (partly), lmpar, wa1=x, wa3=diag*x */
+
+            /* predict scaled reduction */
+            pnorm = lm_enorm(n, wa3);
+            temp2 = lmpar * SQR( pnorm / fnorm );
+            for (j = 0; j < n; j++)
+            {
+                wa3[j] = 0;
+                for (i = 0; i <= j; i++)
+                {
+                    wa3[i] -= fjac[j*m+i] * wa1[ipvt[j]];
+                }
+            }
+            temp1  = SQR( lm_enorm(n, wa3) / fnorm );
+            prered = temp1 + 2 * temp2;
+            dirder = -temp1 + temp2; /* scaled directional derivative */
+
+            /* at first call, adjust the initial step bound. */
+            if (!outer && pnorm < delta)
+            {
+                delta = pnorm;
+            }
+
+/***  [inner]  Evaluate the function at x + p.  ***/
+
+            for (j = 0; j < n; j++)
+            {
+                wa2[j] = x[j] - wa1[j];
+            }
+
+            (*evaluate)( wa2, m, data, wf, &(S->userbreak) );
+            ++(S->nfev);
+            if (S->userbreak)
+            {
+                goto terminate;
+            }
+            fnorm1 = lm_enorm(m, wf);
+
+/***  [inner]  Evaluate the scaled reduction.  ***/
+
+            /* actual scaled reduction */
+            actred = 1 - SQR(fnorm1/fnorm);
+
+            /* ratio of actual to predicted reduction */
+            ratio = prered ? actred/prered : 0;
+
+            if (C->verbosity == 2)
+            {
+                fprintf( msgfile, "lmmin (%i:%i) ", outer, inner );
+                lm_print_pars( nout, wa2, fnorm1, msgfile );
+            }
+            else if (C->verbosity >= 3)
+            {
+                printf( "%3i %2i %9.2g %9.2g %14.6g"
+                        " %9.2g %10.3e %10.3e %21.15e",
+                        outer, inner, lmpar, prered, ratio,
+                        dirder, delta, pnorm, fnorm1 );
+                for (i = 0; i < nout; ++i)
+                {
+                    fprintf( msgfile, " %16.9g", wa2[i] );
+                }
+                fprintf( msgfile, "\n" );
+            }
+
+            /* update the step bound */
+            if        (ratio <= 0.25)
+            {
+                if      (actred >= 0)
+                {
+                    temp = 0.5;
+                }
+                else if (actred > -99)   /* -99 = 1-1/0.1^2 */
+                {
+                    temp = MAX( dirder / (2*dirder + actred), 0.1 );
+                }
+                else
+                {
+                    temp = 0.1;
+                }
+                delta  = temp * MIN(delta, pnorm / 0.1);
+                lmpar /= temp;
+            }
+            else if (ratio >= 0.75)
+            {
+                delta  = 2*pnorm;
+                lmpar *= 0.5;
+            }
+            else if (!lmpar)
+            {
+                delta = 2*pnorm;
+            }
+
+/***  [inner]  On success, update solution, and test for convergence.  ***/
+
+            inner_success = ratio >= p0001;
+            if (inner_success)
+            {
+
+                /* update x, fvec, and their norms */
+                if (C->scale_diag)
+                {
+                    for (j = 0; j < n; j++)
+                    {
+                        x[j]   = wa2[j];
+                        wa2[j] = diag[j] * x[j];
+                    }
+                }
+                else
+                {
+                    for (j = 0; j < n; j++)
+                    {
+                        x[j] = wa2[j];
+                    }
+                }
+                for (i = 0; i < m; i++)
+                {
+                    fvec[i] = wf[i];
+                }
+                xnorm = lm_enorm(n, wa2);
+                fnorm = fnorm1;
+            }
+
+            /* convergence tests */
+            S->outcome = 0;
+            if (fnorm <= LM_DWARF)
+            {
+                goto terminate;  /* success: sum of squares almost zero */
+            }
+            /* test two criteria (both may be fulfilled) */
+            if (fabs(actred) <= C->ftol && prered <= C->ftol && ratio <= 2)
+            {
+                S->outcome = 1;  /* success: x almost stable */
+            }
+            if (delta <= C->xtol * xnorm)
+            {
+                S->outcome += 2; /* success: sum of squares almost stable */
+            }
+            if (S->outcome != 0)
+            {
+                goto terminate;
+            }
+
+/***  [inner]  Tests for termination and stringent tolerances.  ***/
+
+            if (S->nfev >= maxfev)
+            {
+                S->outcome = 5;
+                goto terminate;
+            }
+            if (fabs(actred) <= LM_MACHEP &&
+                prered <= LM_MACHEP && ratio <= 2)
+            {
+                S->outcome = 6;
+                goto terminate;
+            }
+            if (delta <= LM_MACHEP*xnorm)
+            {
+                S->outcome = 7;
+                goto terminate;
+            }
+            if (gnorm <= LM_MACHEP)
+            {
+                S->outcome = 8;
+                goto terminate;
+            }
+
+/***  [inner]  End of the loop. Repeat if iteration unsuccessful.  ***/
+
+            ++inner;
+        }
+        while (!inner_success);
+
+/***  [outer]  End of the loop. ***/
+
+    }
+    ;
+
+terminate:
+    S->fnorm = lm_enorm(m, fvec);
+    if (C->verbosity >= 2)
+    {
+        printf("lmmin outcome (%i) xnorm %g ftol %g xtol %g\n",
+               S->outcome, xnorm, C->ftol, C->xtol );
+    }
+    if (C->verbosity & 1)
+    {
+        fprintf( msgfile, "lmmin final " );
+        lm_print_pars( nout, x, S->fnorm, msgfile );
+    }
+    if (S->userbreak)   /* user-requested break */
+    {
+        S->outcome = 11;
+    }
+
+/***  Deallocate the workspace.  ***/
+    free(fvec);
+    free(diag);
+    free(qtf);
+    free(fjac);
+    free(wa1);
+    free(wa2);
+    free(wa3);
+    free(wf);
+    free(ipvt);
+
+} /*** lmmin. ***/
+
+
+/*****************************************************************************/
+/*  lm_lmpar (determine Levenberg-Marquardt parameter)                       */
+/*****************************************************************************/
+
+void lm_lmpar(int n, double *r, int ldr, int *ipvt, double *diag,
+              double *qtb, double delta, double *par, double *x,
+              double *sdiag, double *aux, double *xdi)
+{
+/*     Given an m by n matrix a, an n by n nonsingular diagonal
+ *     matrix d, an m-vector b, and a positive number delta,
+ *     the problem is to determine a value for the parameter
+ *     par such that if x solves the system
+ *
+ *          a*x = b  and  sqrt(par)*d*x = 0
+ *
+ *     in the least squares sense, and dxnorm is the euclidean
+ *     norm of d*x, then either par=0 and (dxnorm-delta) < 0.1*delta,
+ *     or par>0 and abs(dxnorm-delta) < 0.1*delta.
+ *
+ *     Using lm_qrsolv, this subroutine completes the solution of the problem
+ *     if it is provided with the necessary information from the
+ *     qr factorization, with column pivoting, of a. That is, if
+ *     a*p = q*r, where p is a permutation matrix, q has orthogonal
+ *     columns, and r is an upper triangular matrix with diagonal
+ *     elements of nonincreasing magnitude, then lmpar expects
+ *     the full upper triangle of r, the permutation matrix p,
+ *     and the first n components of qT*b. On output
+ *     lmpar also provides an upper triangular matrix s such that
+ *
+ *          p^T*(a^T*a + par*d*d)*p = s^T*s.
+ *
+ *     s is employed within lmpar and may be of separate interest.
+ *
+ *     Only a few iterations are generally needed for convergence
+ *     of the algorithm. If, however, the limit of 10 iterations
+ *     is reached, then the output par will contain the best
+ *     value obtained so far.
+ *
+ *     parameters:
+ *
+ *      n is a positive integer input variable set to the order of r.
+ *
+ *      r is an n by n array. on input the full upper triangle
+ *        must contain the full upper triangle of the matrix r.
+ *        on OUTPUT the full upper triangle is unaltered, and the
+ *        strict lower triangle contains the strict upper triangle
+ *        (transposed) of the upper triangular matrix s.
+ *
+ *      ldr is a positive integer input variable not less than n
+ *        which specifies the leading dimension of the array r.
+ *
+ *      ipvt is an integer input array of length n which defines the
+ *        permutation matrix p such that a*p = q*r. column j of p
+ *        is column ipvt(j) of the identity matrix.
+ *
+ *      diag is an input array of length n which must contain the
+ *        diagonal elements of the matrix d.
+ *
+ *      qtb is an input array of length n which must contain the first
+ *        n elements of the vector (q transpose)*b.
+ *
+ *      delta is a positive input variable which specifies an upper
+ *        bound on the euclidean norm of d*x.
+ *
+ *      par is a nonnegative variable. on input par contains an
+ *        initial estimate of the levenberg-marquardt parameter.
+ *        on OUTPUT par contains the final estimate.
+ *
+ *      x is an OUTPUT array of length n which contains the least
+ *        squares solution of the system a*x = b, sqrt(par)*d*x = 0,
+ *        for the output par.
+ *
+ *      sdiag is an array of length n needed as workspace; on OUTPUT
+ *        it contains the diagonal elements of the upper triangular matrix s.
+ *
+ *      aux is a multi-purpose work array of length n.
+ *
+ *      xdi is a work array of length n. On OUTPUT: diag[j] * x[j].
+ *
+ */
+    int           i, iter, j, nsing;
+    double        dxnorm, fp, fp_old, gnorm, parc, parl, paru;
+    double        sum, temp;
+    static double p1 = 0.1;
+
+/*** lmpar: compute and store in x the gauss-newton direction. if the
+     jacobian is rank-deficient, obtain a least squares solution. ***/
+
+    nsing = n;
+    for (j = 0; j < n; j++)
+    {
+        aux[j] = qtb[j];
+        if (r[j * ldr + j] == 0 && nsing == n)
+        {
+            nsing = j;
+        }
+        if (nsing < n)
+        {
+            aux[j] = 0;
+        }
+    }
+    for (j = nsing - 1; j >= 0; j--)
+    {
+        aux[j] = aux[j] / r[j + ldr * j];
+        temp   = aux[j];
+        for (i = 0; i < j; i++)
+        {
+            aux[i] -= r[j * ldr + i] * temp;
+        }
+    }
+
+    for (j = 0; j < n; j++)
+    {
+        x[ipvt[j]] = aux[j];
+    }
+
+/*** lmpar: initialize the iteration counter, evaluate the function at the
+     origin, and test for acceptance of the gauss-newton direction. ***/
+
+    for (j = 0; j < n; j++)
+    {
+        xdi[j] = diag[j] * x[j];
+    }
+    dxnorm = lm_enorm(n, xdi);
+    fp     = dxnorm - delta;
+    if (fp <= p1 * delta)
+    {
+#ifdef LMFIT_DEBUG_MESSAGES
+        printf("debug lmpar nsing %d n %d, terminate (fp<p1*delta)\n",
+               nsing, n);
+#endif
+        *par = 0;
+        return;
+    }
+
+/*** lmpar: if the jacobian is not rank deficient, the newton
+     step provides a lower bound, parl, for the 0. of
+     the function. otherwise set this bound to 0.. ***/
+
+    parl = 0;
+    if (nsing >= n)
+    {
+        for (j = 0; j < n; j++)
+        {
+            aux[j] = diag[ipvt[j]] * xdi[ipvt[j]] / dxnorm;
+        }
+
+        for (j = 0; j < n; j++)
+        {
+            sum = 0.;
+            for (i = 0; i < j; i++)
+            {
+                sum += r[j * ldr + i] * aux[i];
+            }
+            aux[j] = (aux[j] - sum) / r[j + ldr * j];
+        }
+        temp = lm_enorm(n, aux);
+        parl = fp / delta / temp / temp;
+    }
+
+/*** lmpar: calculate an upper bound, paru, for the 0. of the function. ***/
+
+    for (j = 0; j < n; j++)
+    {
+        sum = 0;
+        for (i = 0; i <= j; i++)
+        {
+            sum += r[j * ldr + i] * qtb[i];
+        }
+        aux[j] = sum / diag[ipvt[j]];
+    }
+    gnorm = lm_enorm(n, aux);
+    paru  = gnorm / delta;
+    if (paru == 0.)
+    {
+        paru = LM_DWARF / MIN(delta, p1);
+    }
+
+/*** lmpar: if the input par lies outside of the interval (parl,paru),
+     set par to the closer endpoint. ***/
+
+    *par = MAX(*par, parl);
+    *par = MIN(*par, paru);
+    if (*par == 0.)
+    {
+        *par = gnorm / dxnorm;
+    }
+
+/*** lmpar: iterate. ***/
+
+    for (iter = 0;; iter++)
+    {
+
+        /** evaluate the function at the current value of par. **/
+
+        if (*par == 0.)
+        {
+            *par = MAX(LM_DWARF, 0.001 * paru);
+        }
+        temp = sqrt(*par);
+        for (j = 0; j < n; j++)
+        {
+            aux[j] = temp * diag[j];
+        }
+
+        lm_qrsolv( n, r, ldr, ipvt, aux, qtb, x, sdiag, xdi );
+        /* return values are r, x, sdiag */
+
+        for (j = 0; j < n; j++)
+        {
+            xdi[j] = diag[j] * x[j]; /* used as output */
+        }
+        dxnorm = lm_enorm(n, xdi);
+        fp_old = fp;
+        fp     = dxnorm - delta;
+
+        /** if the function is small enough, accept the current value
+            of par. Also test for the exceptional cases where parl
+            is zero or the number of iterations has reached 10. **/
+
+        if (fabs(fp) <= p1 * delta
+            || (parl == 0. && fp <= fp_old && fp_old < 0.)
+            || iter == 10)
+        {
+#ifdef LMFIT_DEBUG_MESSAGES
+            printf("debug lmpar nsing %d iter %d "
+                   "par %.4e [%.4e %.4e] delta %.4e fp %.4e\n",
+                   nsing, iter, *par, parl, paru, delta, fp);
+#endif
+            break; /* the only exit from the iteration. */
+        }
+
+        /** compute the Newton correction. **/
+
+        for (j = 0; j < n; j++)
+        {
+            aux[j] = diag[ipvt[j]] * xdi[ipvt[j]] / dxnorm;
+        }
+
+        for (j = 0; j < n; j++)
+        {
+            aux[j] = aux[j] / sdiag[j];
+            for (i = j + 1; i < n; i++)
+            {
+                aux[i] -= r[j * ldr + i] * aux[j];
+            }
+        }
+        temp = lm_enorm(n, aux);
+        parc = fp / delta / temp / temp;
+
+        /** depending on the sign of the function, update parl or paru. **/
+
+        if (fp > 0)
+        {
+            parl = MAX(parl, *par);
+        }
+        else if (fp < 0)
+        {
+            paru = MIN(paru, *par);
+        }
+        /* the case fp==0 is precluded by the break condition  */
+
+        /** compute an improved estimate for par. **/
+
+        *par = MAX(parl, *par + parc);
+
+    }
+
+} /*** lm_lmpar. ***/
+
+/*****************************************************************************/
+/*  lm_qrfac (QR factorization, from lapack)                                 */
+/*****************************************************************************/
+
+void lm_qrfac(int m, int n, double *a, int *ipvt,
+              double *rdiag, double *acnorm, double *wa)
+{
+/*
+ *     This subroutine uses Householder transformations with column
+ *     pivoting (optional) to compute a qr factorization of the
+ *     m by n matrix a. That is, qrfac determines an orthogonal
+ *     matrix q, a permutation matrix p, and an upper trapezoidal
+ *     matrix r with diagonal elements of nonincreasing magnitude,
+ *     such that a*p = q*r. The Householder transformation for
+ *     column k, k = 1,2,...,min(m,n), is of the form
+ *
+ *          i - (1/u(k))*u*uT
+ *
+ *     where u has zeroes in the first k-1 positions. The form of
+ *     this transformation and the method of pivoting first
+ *     appeared in the corresponding linpack subroutine.
+ *
+ *     Parameters:
+ *
+ *      m is a positive integer input variable set to the number
+ *        of rows of a.
+ *
+ *      n is a positive integer input variable set to the number
+ *        of columns of a.
+ *
+ *      a is an m by n array. On input a contains the matrix for
+ *        which the qr factorization is to be computed. On OUTPUT
+ *        the strict upper trapezoidal part of a contains the strict
+ *        upper trapezoidal part of r, and the lower trapezoidal
+ *        part of a contains a factored form of q (the non-trivial
+ *        elements of the u vectors described above).
+ *
+ *      ipvt is an integer OUTPUT array of length lipvt. This array
+ *        defines the permutation matrix p such that a*p = q*r.
+ *        Column j of p is column ipvt(j) of the identity matrix.
+ *
+ *      rdiag is an OUTPUT array of length n which contains the
+ *        diagonal elements of r.
+ *
+ *      acnorm is an OUTPUT array of length n which contains the
+ *        norms of the corresponding columns of the input matrix a.
+ *        If this information is not needed, then acnorm can coincide
+ *        with rdiag.
+ *
+ *      wa is a work array of length n.
+ *
+ */
+    int    i, j, k, kmax, minmn;
+    double ajnorm, sum, temp;
+
+/*** qrfac: compute initial column norms and initialize several arrays. ***/
+
+    for (j = 0; j < n; j++)
+    {
+        acnorm[j] = lm_enorm(m, &a[j*m]);
+        rdiag[j]  = acnorm[j];
+        wa[j]     = rdiag[j];
+        ipvt[j]   = j;
+    }
+#ifdef LMFIT_DEBUG_MESSAGES
+    printf("debug qrfac\n");
+#endif
+
+/*** qrfac: reduce a to r with Householder transformations. ***/
+
+    minmn = MIN(m, n);
+    for (j = 0; j < minmn; j++)
+    {
+
+        /** bring the column of largest norm into the pivot position. **/
+
+        kmax = j;
+        for (k = j + 1; k < n; k++)
+        {
+            if (rdiag[k] > rdiag[kmax])
+            {
+                kmax = k;
+            }
+        }
+        if (kmax == j)
+        {
+            goto pivot_ok;
+        }
+
+        for (i = 0; i < m; i++)
+        {
+            temp        = a[j*m+i];
+            a[j*m+i]    = a[kmax*m+i];
+            a[kmax*m+i] = temp;
+        }
+        rdiag[kmax] = rdiag[j];
+        wa[kmax]    = wa[j];
+        k           = ipvt[j];
+        ipvt[j]     = ipvt[kmax];
+        ipvt[kmax]  = k;
+
+pivot_ok:
+        /** compute the Householder transformation to reduce the
+            j-th column of a to a multiple of the j-th unit vector. **/
+
+        ajnorm = lm_enorm(m-j, &a[j*m+j]);
+        if (ajnorm == 0.)
+        {
+            rdiag[j] = 0;
+            continue;
+        }
+
+        if (a[j*m+j] < 0.)
+        {
+            ajnorm = -ajnorm;
+        }
+        for (i = j; i < m; i++)
+        {
+            a[j*m+i] /= ajnorm;
+        }
+        a[j*m+j] += 1;
+
+        /** apply the transformation to the remaining columns
+            and update the norms. **/
+
+        for (k = j + 1; k < n; k++)
+        {
+            sum = 0;
+
+            for (i = j; i < m; i++)
+            {
+                sum += a[j*m+i] * a[k*m+i];
+            }
+
+            temp = sum / a[j + m * j];
+
+            for (i = j; i < m; i++)
+            {
+                a[k*m+i] -= temp * a[j*m+i];
+            }
+
+            if (rdiag[k] != 0.)
+            {
+                temp      = a[m * k + j] / rdiag[k];
+                temp      = MAX(0., 1 - temp * temp);
+                rdiag[k] *= sqrt(temp);
+                temp      = rdiag[k] / wa[k];
+                if (0.05 * SQR(temp) <= LM_MACHEP)
+                {
+                    rdiag[k] = lm_enorm(m-j-1, &a[m*k+j+1]);
+                    wa[k]    = rdiag[k];
+                }
+            }
+        }
+
+        rdiag[j] = -ajnorm;
+    }
+} /*** lm_qrfac. ***/
+
+
+/*****************************************************************************/
+/*  lm_qrsolv (linear least-squares)                                         */
+/*****************************************************************************/
+
+void lm_qrsolv(int n, double *r, int ldr, int *ipvt, double *diag,
+               double *qtb, double *x, double *sdiag, double *wa)
+{
+/*
+ *     Given an m by n matrix a, an n by n diagonal matrix d,
+ *     and an m-vector b, the problem is to determine an x which
+ *     solves the system
+ *
+ *          a*x = b  and  d*x = 0
+ *
+ *     in the least squares sense.
+ *
+ *     This subroutine completes the solution of the problem
+ *     if it is provided with the necessary information from the
+ *     qr factorization, with column pivoting, of a. That is, if
+ *     a*p = q*r, where p is a permutation matrix, q has orthogonal
+ *     columns, and r is an upper triangular matrix with diagonal
+ *     elements of nonincreasing magnitude, then qrsolv expects
+ *     the full upper triangle of r, the permutation matrix p,
+ *     and the first n components of (q transpose)*b. The system
+ *     a*x = b, d*x = 0, is then equivalent to
+ *
+ *          r*z = q^T*b,  p^T*d*p*z = 0,
+ *
+ *     where x = p*z. If this system does not have full rank,
+ *     then a least squares solution is obtained. On output qrsolv
+ *     also provides an upper triangular matrix s such that
+ *
+ *          p^T *(a^T *a + d*d)*p = s^T *s.
+ *
+ *     s is computed within qrsolv and may be of separate interest.
+ *
+ *     Parameters
+ *
+ *      n is a positive integer input variable set to the order of r.
+ *
+ *      r is an n by n array. On input the full upper triangle
+ *        must contain the full upper triangle of the matrix r.
+ *        On OUTPUT the full upper triangle is unaltered, and the
+ *        strict lower triangle contains the strict upper triangle
+ *        (transposed) of the upper triangular matrix s.
+ *
+ *      ldr is a positive integer input variable not less than n
+ *        which specifies the leading dimension of the array r.
+ *
+ *      ipvt is an integer input array of length n which defines the
+ *        permutation matrix p such that a*p = q*r. Column j of p
+ *        is column ipvt(j) of the identity matrix.
+ *
+ *      diag is an input array of length n which must contain the
+ *        diagonal elements of the matrix d.
+ *
+ *      qtb is an input array of length n which must contain the first
+ *        n elements of the vector (q transpose)*b.
+ *
+ *      x is an OUTPUT array of length n which contains the least
+ *        squares solution of the system a*x = b, d*x = 0.
+ *
+ *      sdiag is an OUTPUT array of length n which contains the
+ *        diagonal elements of the upper triangular matrix s.
+ *
+ *      wa is a work array of length n.
+ *
+ */
+    int    i, kk, j, k, nsing;
+    double qtbpj, sum, temp;
+    double _sin, _cos, _tan, _cot; /* local variables, not functions */
+
+/*** qrsolv: copy r and q^T*b to preserve input and initialize s.
+     in particular, save the diagonal elements of r in x. ***/
+
+    for (j = 0; j < n; j++)
+    {
+        for (i = j; i < n; i++)
+        {
+            r[j * ldr + i] = r[i * ldr + j];
+        }
+        x[j]  = r[j * ldr + j];
+        wa[j] = qtb[j];
+    }
+/*** qrsolv: eliminate the diagonal matrix d using a Givens rotation. ***/
+
+    for (j = 0; j < n; j++)
+    {
+
+/*** qrsolv: prepare the row of d to be eliminated, locating the
+     diagonal element using p from the qr factorization. ***/
+
+        if (diag[ipvt[j]] == 0.)
+        {
+            goto L90;
+        }
+        for (k = j; k < n; k++)
+        {
+            sdiag[k] = 0.;
+        }
+        sdiag[j] = diag[ipvt[j]];
+
+/*** qrsolv: the transformations to eliminate the row of d modify only
+     a single element of qT*b beyond the first n, which is initially 0. ***/
+
+        qtbpj = 0.;
+        for (k = j; k < n; k++)
+        {
+
+            /** determine a Givens rotation which eliminates the
+                appropriate element in the current row of d. **/
+
+            if (sdiag[k] == 0.)
+            {
+                continue;
+            }
+            kk = k + ldr * k;
+            if (fabs(r[kk]) < fabs(sdiag[k]))
+            {
+                _cot = r[kk] / sdiag[k];
+                _sin = 1 / sqrt(1 + SQR(_cot));
+                _cos = _sin * _cot;
+            }
+            else
+            {
+                _tan = sdiag[k] / r[kk];
+                _cos = 1 / sqrt(1 + SQR(_tan));
+                _sin = _cos * _tan;
+            }
+
+            /** compute the modified diagonal element of r and
+                the modified element of ((q^T)*b,0). **/
+
+            r[kk] = _cos * r[kk] + _sin * sdiag[k];
+            temp  = _cos * wa[k] + _sin * qtbpj;
+            qtbpj = -_sin * wa[k] + _cos * qtbpj;
+            wa[k] = temp;
+
+            /** accumulate the tranformation in the row of s. **/
+
+            for (i = k + 1; i < n; i++)
+            {
+                temp           = _cos * r[k * ldr + i] + _sin * sdiag[i];
+                sdiag[i]       = -_sin * r[k * ldr + i] + _cos * sdiag[i];
+                r[k * ldr + i] = temp;
+            }
+        }
+
+L90:
+        /** store the diagonal element of s and restore
+            the corresponding diagonal element of r. **/
+
+        sdiag[j]       = r[j * ldr + j];
+        r[j * ldr + j] = x[j];
+    }
+
+/*** qrsolv: solve the triangular system for z. if the system is
+     singular, then obtain a least squares solution. ***/
+
+    nsing = n;
+    for (j = 0; j < n; j++)
+    {
+        if (sdiag[j] == 0. && nsing == n)
+        {
+            nsing = j;
+        }
+        if (nsing < n)
+        {
+            wa[j] = 0;
+        }
+    }
+
+    for (j = nsing - 1; j >= 0; j--)
+    {
+        sum = 0;
+        for (i = j + 1; i < nsing; i++)
+        {
+            sum += r[j * ldr + i] * wa[i];
+        }
+        wa[j] = (wa[j] - sum) / sdiag[j];
+    }
+
+/*** qrsolv: permute the components of z back to components of x. ***/
+
+    for (j = 0; j < n; j++)
+    {
+        x[ipvt[j]] = wa[j];
+    }
+
+} /*** lm_qrsolv. ***/
+
+
+/*****************************************************************************/
+/*  lm_enorm (Euclidean norm)                                                */
+/*****************************************************************************/
+
+double lm_enorm(int n, const double *x)
+{
+/*     Given an n-vector x, this function calculates the
+ *     euclidean norm of x.
+ *
+ *     The euclidean norm is computed by accumulating the sum of
+ *     squares in three different sums. The sums of squares for the
+ *     small and large components are scaled so that no overflows
+ *     occur. Non-destructive underflows are permitted. Underflows
+ *     and overflows do not occur in the computation of the unscaled
+ *     sum of squares for the intermediate components.
+ *     The definitions of small, intermediate and large components
+ *     depend on two constants, LM_SQRT_DWARF and LM_SQRT_GIANT. The main
+ *     restrictions on these constants are that LM_SQRT_DWARF**2 not
+ *     underflow and LM_SQRT_GIANT**2 not overflow.
+ *
+ *     Parameters
+ *
+ *      n is a positive integer input variable.
+ *
+ *      x is an input array of length n.
+ */
+    int    i;
+    double agiant, s1, s2, s3, xabs, x1max, x3max, temp;
+
+    s1     = 0;
+    s2     = 0;
+    s3     = 0;
+    x1max  = 0;
+    x3max  = 0;
+    agiant = LM_SQRT_GIANT / n;
+
+    /** sum squares. **/
+
+    for (i = 0; i < n; i++)
+    {
+        xabs = fabs(x[i]);
+        if (xabs > LM_SQRT_DWARF)
+        {
+            if (xabs < agiant)
+            {
+                s2 += xabs * xabs;
+            }
+            else if (xabs > x1max)
+            {
+                temp  = x1max / xabs;
+                s1    = 1 + s1 * SQR(temp);
+                x1max = xabs;
+            }
+            else
+            {
+                temp = xabs / x1max;
+                s1  += SQR(temp);
+            }
+        }
+        else if (xabs > x3max)
+        {
+            temp  = x3max / xabs;
+            s3    = 1 + s3 * SQR(temp);
+            x3max = xabs;
+        }
+        else if (xabs != 0.)
+        {
+            temp = xabs / x3max;
+            s3  += SQR(temp);
+        }
+    }
+
+    /** calculation of norm. **/
+
+    if (s1 != 0)
+    {
+        return x1max * sqrt(s1 + (s2 / x1max) / x1max);
+    }
+    else if (s2 != 0)
+    {
+        if (s2 >= x3max)
+        {
+            return sqrt(s2 * (1 + (x3max / s2) * (x3max * s3)));
+        }
+        else
+        {
+            return sqrt(x3max * ((s2 / x3max) + (x3max * s3)));
+        }
+    }
+    else
+    {
+        return x3max * sqrt(s3);
+    }
+
+} /*** lm_enorm. ***/
diff --git a/src/external/lmfit/lmmin.h b/src/external/lmfit/lmmin.h
new file mode 100644 (file)
index 0000000..3c8aa71
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Library:   lmfit (Levenberg-Marquardt least squares fitting)
+ *
+ * File:      lmmin.h
+ *
+ * Contents:  Declarations for Levenberg-Marquardt minimization.
+ *
+ * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
+ *
+ * License:   see ../COPYING (FreeBSD)
+ *
+ * Homepage:  apps.jcns.fz-juelich.de/lmfit
+ */
+
+#ifndef LMMIN_H
+#define LMMIN_H
+#undef __BEGIN_DECLS
+#undef __END_DECLS
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS /* empty */
+# define __END_DECLS   /* empty */
+#endif
+
+#include "lmstruct.h"
+
+__BEGIN_DECLS
+
+/*! \brief
+ * Levenberg-Marquardt minimization.
+ *
+ *   This routine contains the core algorithm of our library.
+ *
+ *   It minimizes the sum of the squares of m nonlinear functions
+ *   in n variables by a modified Levenberg-Marquardt algorithm.
+ *   The function evaluation is done by the user-provided routine 'evaluate'.
+ *   The Jacobian is then calculated by a forward-difference approximation.
+ *
+ *   Parameters:
+ *
+ * \param[in] n_par The number of variables (INPUT, positive integer).
+ * \param par The parameters to be fitted
+ *      x is the solution vector (INPUT/OUTPUT, array of length n).
+ *        On input it must be set to an estimated solution.
+ *        On output it yields the final estimate of the solution.
+ *
+ *      m is the number of functions to be minimized (INPUT, positive integer).
+ *        It must fulfill m>=n.
+ *
+ *      data is a pointer that is ignored by lmmin; it is however forwarded
+ *        to the user-supplied functions evaluate and printout.
+ *        In a typical application, it contains experimental data to be fitted.
+ *
+ *      evaluate is a user-supplied function that calculates the m functions.
+ *        Parameters:
+ *          n, x, m, data as above.
+ *          fvec is an array of length m; on OUTPUT, it must contain the
+ *            m function values for the parameter vector x.
+ *          userbreak is an integer pointer. When *userbreak is set to a
+ *            nonzero value, lmmin will terminate.
+ *
+ *      control contains INPUT variables that control the fit algorithm,
+ *        as declared and explained in lmstruct.h
+ *
+ *      status contains OUTPUT variables that inform about the fit result,
+ *        as declared and explained in lmstruct.h
+ */
+void lmmin( int n_par, double *par, int m_dat, const void *data,
+            void (*evaluate) (const double *par, int m_dat, const void *data,
+                              double *fvec, int *userbreak),
+            const lm_control_struct *control, lm_status_struct *status );
+
+/* Refined calculation of Eucledian norm. */
+double lm_enorm( int, const double * );
+
+__END_DECLS
+#endif /* LMMIN_H */
diff --git a/src/external/lmfit/lmstruct.h b/src/external/lmfit/lmstruct.h
new file mode 100644 (file)
index 0000000..9a220e4
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Library:   lmfit (Levenberg-Marquardt least squares fitting)
+ *
+ * File:      lmstruct.h
+ *
+ * Contents:  Declarations of parameter records, used in lmmin.h and lmcurve.h
+ *
+ * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
+ *
+ * License:   see ../COPYING (FreeBSD)
+ *
+ * Homepage:  apps.jcns.fz-juelich.de/lmfit
+ */
+
+#ifndef LMSTRUCT_H
+#define LMSTRUCT_H
+#undef __BEGIN_DECLS
+#undef __END_DECLS
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS /* empty */
+# define __END_DECLS   /* empty */
+#endif
+__BEGIN_DECLS
+
+#include <stdio.h>
+
+/* Collection of input parameters for fit control. */
+typedef struct {
+    double ftol;      /* Relative error desired in the sum of squares.
+                         Termination occurs when both the actual and
+                         predicted relative reductions in the sum of squares
+                         are at most ftol. */
+    double xtol;      /* Relative error between last two approximations.
+                         Termination occurs when the relative error between
+                         two consecutive iterates is at most xtol. */
+    double gtol;      /* Orthogonality desired between fvec and its derivs.
+                         Termination occurs when the cosine of the angle
+                         between fvec and any column of the Jacobian is at
+                         most gtol in absolute value. */
+    double epsilon;   /* Step used to calculate the Jacobian, should be
+                         slightly larger than the relative error in the
+                         user-supplied functions. */
+    double stepbound; /* Used in determining the initial step bound. This
+                         bound is set to the product of stepbound and the
+                         Euclidean norm of diag*x if nonzero, or else to
+                         stepbound itself. In most cases stepbound should lie
+                         in the interval (0.1,100.0). Generally, the value
+                         100.0 is recommended. */
+    int   patience;   /* Used to set the maximum number of function evaluations
+                         to patience*(number_of_parameters+1). */
+    int   scale_diag; /* If 1, the variables will be rescaled internally.
+                         Recommended value is 1. */
+    FILE* msgfile;    /* Progress messages will be written to this file. */
+    int   verbosity;  /* OR'ed: 1: print some messages; 2: print Jacobian. */
+    int   n_maxpri;   /* -1, or max number of parameters to print. */
+    int   m_maxpri;   /* -1, or max number of residuals to print. */
+} lm_control_struct;
+
+/* Collection of output parameters for status info. */
+typedef struct {
+    double fnorm;     /* norm of the residue vector fvec. */
+    int    nfev;      /* actual number of iterations. */
+    int    outcome;   /* Status indicator. Nonnegative values are used as index
+                         for the message text lm_infmsg, set in lmmin.c. */
+    int    userbreak; /* Set when function evaluation requests termination. */
+} lm_status_struct;
+
+/* Preset (and recommended) control parameter settings. */
+extern const lm_control_struct lm_control_double;
+extern const lm_control_struct lm_control_float;
+
+/* Preset message texts. */
+
+extern const char *lm_infmsg[];
+extern const char *lm_shortmsg[];
+
+__END_DECLS
+#endif /* LMSTRUCT_H */
index deeca78c5816181aba81cf9c30fc280c904dbd0a..bd597d68d82d179e491cf38cb38647490dbefc55 100644 (file)
@@ -113,6 +113,7 @@ add_subdirectory(imd)
 if (NOT GMX_BUILD_MDRUN_ONLY)
     add_subdirectory(legacyheaders)
     add_subdirectory(gmxana)
+    add_subdirectory(correlationfunctions)
     add_subdirectory(statistics)
     add_subdirectory(analysisdata)
     add_subdirectory(selection)
diff --git a/src/gromacs/correlationfunctions/CMakeLists.txt b/src/gromacs/correlationfunctions/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6c6718a
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2014, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+file(GLOB GMXCORRFUNC_SOURCES *.c *.cpp)
+file(GLOB LMFIT_SOURCES ${CMAKE_SOURCE_DIR}/src/external/lmfit/*.c)
+
+set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${GMXCORRFUNC_SOURCES}  ${LMFIT_SOURCES} PARENT_SCOPE)
+if (BUILD_TESTING)
+    add_subdirectory(tests)
+endif()
similarity index 72%
rename from src/gromacs/gmxana/autocorr.c
rename to src/gromacs/correlationfunctions/autocorr.c
index 9b0a13b69103c833f5407b0bd0ca0b38d93344ba..159790811f1e4113f458472198eebac5a3579581 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \internal \file
+ * \brief
+ * Implements function to compute many autocorrelation functions
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \ingroup module_correlationfunctions
+ */
 #include "gmxpre.h"
 
+#include "autocorr.h"
+
 #include <math.h>
 #include <stdio.h>
 #include <string.h>
 
+#include "gromacs/correlationfunctions/expfit.h"
+#include "gromacs/correlationfunctions/integrate.h"
+#include "gromacs/correlationfunctions/manyautocorrelation.h"
+#include "gromacs/correlationfunctions/polynomials.h"
 #include "gromacs/fileio/xvgr.h"
-#include "gromacs/gmxana/correl.h"
-#include "gromacs/gmxana/gstat.h"
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/names.h"
-#include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
+#include "gromacs/utility/real.h"
 #include "gromacs/utility/smalloc.h"
 
+/*! \brief Shortcut macro to select modes. */
 #define MODE(x) ((mode & (x)) == (x))
 
 typedef struct {
@@ -60,33 +72,22 @@ typedef struct {
     real          tbeginfit, tendfit;
 } t_acf;
 
+/*! \brief Global variable set true if initialization routines are called. */
 static gmx_bool  bACFinit = FALSE;
+
+/*! \brief Data structure for storing command line variables. */
 static t_acf     acf;
 
 enum {
     enNorm, enCos, enSin
 };
 
-int sffn2effn(const char **sffn)
-{
-    int eFitFn, i;
-
-    eFitFn = 0;
-    for (i = 0; i < effnNR; i++)
-    {
-        if (sffn[i+1] && strcmp(sffn[0], sffn[i+1]) == 0)
-        {
-            eFitFn = i;
-        }
-    }
-
-    return eFitFn;
-}
-
+/*! \brief Routine to compute ACF using FFT. */
 static void low_do_four_core(int nfour, int nframes, real c1[], real cfour[],
-                             int nCos, gmx_bool bPadding)
+                             int nCos)
 {
     int  i = 0;
+    int  fftcode;
     real aver, *ans;
 
     aver = 0.0;
@@ -114,49 +115,18 @@ static void low_do_four_core(int nfour, int nframes, real c1[], real cfour[],
         default:
             gmx_fatal(FARGS, "nCos = %d, %s %d", nCos, __FILE__, __LINE__);
     }
-    for (; (i < nfour); i++)
-    {
-        cfour[i] = 0.0;
-    }
-
-    if (bPadding)
-    {
-        aver /= nframes;
-        /* printf("aver = %g\n",aver); */
-        for (i = 0; (i < nframes); i++)
-        {
-            cfour[i] -= aver;
-        }
-    }
-
-    snew(ans, 2*nfour);
-    correl(cfour-1, cfour-1, nfour, ans-1);
 
-    if (bPadding)
-    {
-        for (i = 0; (i < nfour); i++)
-        {
-            cfour[i] = ans[i]+sqr(aver);
-        }
-    }
-    else
-    {
-        for (i = 0; (i < nfour); i++)
-        {
-            cfour[i] = ans[i];
-        }
-    }
-
-    sfree(ans);
+    fftcode = many_auto_correl(1, nframes, nfour, &cfour);
 }
 
+/*! \brief Routine to comput ACF without FFT. */
 static void do_ac_core(int nframes, int nout,
                        real corr[], real c1[], int nrestart,
                        unsigned long mode)
 {
     int     j, k, j3, jk3, m, n;
     real    ccc, cth;
-    rvec    xj, xk, rr;
+    rvec    xj, xk;
 
     if (nrestart < 1)
     {
@@ -205,6 +175,8 @@ static void do_ac_core(int nframes, int nout,
             }
             else if (MODE(eacP1) || MODE(eacP2) || MODE(eacP3))
             {
+                unsigned int mmm;
+
                 for (m = 0; (m < DIM); m++)
                 {
                     xj[m] = c1[j3+m];
@@ -217,11 +189,20 @@ static void do_ac_core(int nframes, int nout,
                     printf("j: %d, k: %d, xj:(%g,%g,%g), xk:(%g,%g,%g)\n",
                            j, k, xj[XX], xj[YY], xj[ZZ], xk[XX], xk[YY], xk[ZZ]);
                 }
-
-                corr[k] += LegendreP(cth, mode); /* 1.5*cth*cth-0.5; */
+                mmm = 1;
+                if (MODE(eacP2))
+                {
+                    mmm = 2;
+                }
+                else if (MODE(eacP3))
+                {
+                    mmm = 3;
+                }
+                corr[k] += LegendreP(cth, mmm); /* 1.5*cth*cth-0.5; */
             }
             else if (MODE(eacRcross))
             {
+                rvec xj, xk, rr;
                 for (m = 0; (m < DIM); m++)
                 {
                     xj[m] = c1[j3+m];
@@ -256,10 +237,11 @@ static void do_ac_core(int nframes, int nout,
     }
 }
 
+/*! \brief Routine to normalize ACF, dividing by corr[0]. */
 void normalize_acf(int nout, real corr[])
 {
-    int  j;
-    real c0;
+    int    j;
+    double c0;
 
     if (debug)
     {
@@ -273,7 +255,7 @@ void normalize_acf(int nout, real corr[])
     /* Normalisation makes that c[0] = 1.0 and that other points are scaled
      * accordingly.
      */
-    if (corr[0] == 0.0)
+    if (fabs(corr[0]) < 1e-5)
     {
         c0 = 1.0;
     }
@@ -296,6 +278,7 @@ void normalize_acf(int nout, real corr[])
     }
 }
 
+/*! \brief Routine that averages ACFs. */
 void average_acf(gmx_bool bVerbose, int n, int nitem, real **c1)
 {
     real c0;
@@ -317,6 +300,7 @@ void average_acf(gmx_bool bVerbose, int n, int nitem, real **c1)
     }
 }
 
+/*! \brief Normalize ACFs. */
 void norm_and_scale_vectors(int nframes, real c1[], real scale)
 {
     int   j, m;
@@ -333,7 +317,8 @@ void norm_and_scale_vectors(int nframes, real c1[], real scale)
     }
 }
 
-void dump_tmp(char *s, int n, real c[])
+/*! \brief Debugging */
+static void dump_tmp(char *s, int n, real c[])
 {
     FILE *fp;
     int   i;
@@ -346,99 +331,7 @@ void dump_tmp(char *s, int n, real c[])
     gmx_ffclose(fp);
 }
 
-real print_and_integrate(FILE *fp, int n, real dt, real c[], real *fit, int nskip)
-{
-    real c0, sum;
-    int  j;
-
-    /* Use trapezoidal rule for calculating integral */
-    sum = 0.0;
-    for (j = 0; (j < n); j++)
-    {
-        c0 = c[j];
-        if (fp && (nskip == 0 || j % nskip == 0))
-        {
-            fprintf(fp, "%10.3f  %10.5f\n", j*dt, c0);
-        }
-        if (j > 0)
-        {
-            sum += dt*(c0+c[j-1]);
-        }
-    }
-    if (fp)
-    {
-        fprintf(fp, "&\n");
-        if (fit)
-        {
-            for (j = 0; (j < n); j++)
-            {
-                if (nskip == 0 || j % nskip == 0)
-                {
-                    fprintf(fp, "%10.3f  %10.5f\n", j*dt, fit[j]);
-                }
-            }
-            fprintf(fp, "&\n");
-        }
-    }
-    return sum*0.5;
-}
-
-real evaluate_integral(int n, real x[], real y[], real dy[], real aver_start,
-                       real *stddev)
-{
-    double sum, sum_var, w;
-    double sum_tail = 0, sum2_tail = 0;
-    int    j, nsum_tail = 0;
-
-    /* Use trapezoidal rule for calculating integral */
-    if (n <= 0)
-    {
-        gmx_fatal(FARGS, "Evaluating integral: n = %d (file %s, line %d)",
-                  n, __FILE__, __LINE__);
-    }
-
-    sum     = 0;
-    sum_var = 0;
-    for (j = 0; (j < n); j++)
-    {
-        w = 0;
-        if (j > 0)
-        {
-            w += 0.5*(x[j] - x[j-1]);
-        }
-        if (j < n-1)
-        {
-            w += 0.5*(x[j+1] - x[j]);
-        }
-        sum += w*y[j];
-        if (dy)
-        {
-            /* Assume all errors are uncorrelated */
-            sum_var += sqr(w*dy[j]);
-        }
-
-        if ((aver_start > 0) && (x[j] >= aver_start))
-        {
-            sum_tail  += sum;
-            sum2_tail += sqrt(sum_var);
-            nsum_tail += 1;
-        }
-    }
-
-    if (nsum_tail > 0)
-    {
-        sum = sum_tail/nsum_tail;
-        /* This is a worst case estimate, assuming all stddev's are correlated. */
-        *stddev = sum2_tail/nsum_tail;
-    }
-    else
-    {
-        *stddev = sqrt(sum_var);
-    }
-
-    return sum;
-}
-
+/*! \brief High level ACF routine. */
 void do_four_core(unsigned long mode, int nfour, int nf2, int nframes,
                   real c1[], real csum[], real ctmp[])
 {
@@ -454,7 +347,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes,
         /********************************************
          *  N O R M A L
          ********************************************/
-        low_do_four_core(nfour, nf2, c1, csum, enNorm, FALSE);
+        low_do_four_core(nfour, nf2, c1, csum, enNorm);
     }
     else if (MODE(eacCos))
     {
@@ -470,14 +363,14 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes,
         }
 
         /* Cosine term of AC function */
-        low_do_four_core(nfour, nf2, ctmp, cfour, enCos, FALSE);
+        low_do_four_core(nfour, nf2, ctmp, cfour, enCos);
         for (j = 0; (j < nf2); j++)
         {
             c1[j]  = cfour[j];
         }
 
         /* Sine term of AC function */
-        low_do_four_core(nfour, nf2, ctmp, cfour, enSin, FALSE);
+        low_do_four_core(nfour, nf2, ctmp, cfour, enSin);
         for (j = 0; (j < nf2); j++)
         {
             c1[j]  += cfour[j];
@@ -544,7 +437,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes,
                 dump_tmp(buf, nf2, ctmp);
             }
 
-            low_do_four_core(nfour, nf2, ctmp, cfour, enNorm, FALSE);
+            low_do_four_core(nfour, nf2, ctmp, cfour, enNorm);
 
             if (debug)
             {
@@ -572,7 +465,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes,
                 sprintf(buf, "c1off%d.xvg", m);
                 dump_tmp(buf, nf2, ctmp);
             }
-            low_do_four_core(nfour, nf2, ctmp, cfour, enNorm, FALSE);
+            low_do_four_core(nfour, nf2, ctmp, cfour, enNorm);
             if (debug)
             {
                 sprintf(buf, "c1ofout%d.xvg", m);
@@ -611,7 +504,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes,
             {
                 ctmp[j] = c1[DIM*j+m];
             }
-            low_do_four_core(nfour, nf2, ctmp, cfour, enNorm, FALSE);
+            low_do_four_core(nfour, nf2, ctmp, cfour, enNorm);
             for (j = 0; (j < nf2); j++)
             {
                 csum[j] += cfour[j];
@@ -630,146 +523,6 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes,
     }
 }
 
-real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose,
-             real tbeginfit, real tendfit, real dt, real c1[], real *fit)
-{
-    real        fitparm[3];
-    real        tStart, tail_corr, sum, sumtot = 0, c_start, ct_estimate, *sig;
-    int         i, j, jmax, nf_int;
-    gmx_bool    bPrint;
-
-    bPrint = bVerbose || bDebugMode();
-
-    if (bPrint)
-    {
-        printf("COR:\n");
-    }
-
-    if (tendfit <= 0)
-    {
-        tendfit = ncorr*dt;
-    }
-    nf_int = min(ncorr, (int)(tendfit/dt));
-    sum    = print_and_integrate(debug, nf_int, dt, c1, NULL, 1);
-
-    /* Estimate the correlation time for better fitting */
-    ct_estimate = 0.5*c1[0];
-    for (i = 1; (i < ncorr) && (c1[i] > 0); i++)
-    {
-        ct_estimate += c1[i];
-    }
-    ct_estimate *= dt/c1[0];
-
-    if (bPrint)
-    {
-        printf("COR: Correlation time (plain integral from %6.3f to %6.3f ps) = %8.5f ps\n",
-               0.0, dt*nf_int, sum);
-        printf("COR: Relaxation times are computed as fit to an exponential:\n");
-        printf("COR:   %s\n", longs_ffn[fitfn]);
-        printf("COR: Fit to correlation function from %6.3f ps to %6.3f ps, results in a\n", tbeginfit, min(ncorr*dt, tendfit));
-    }
-
-    tStart = 0;
-    if (bPrint)
-    {
-        printf("COR:%11s%11s%11s%11s%11s%11s%11s\n",
-               "Fit from", "Integral", "Tail Value", "Sum (ps)", " a1 (ps)",
-               (nfp_ffn[fitfn] >= 2) ? " a2 ()" : "",
-               (nfp_ffn[fitfn] >= 3) ? " a3 (ps)" : "");
-    }
-
-    snew(sig, ncorr);
-
-    if (tbeginfit > 0)
-    {
-        jmax = 3;
-    }
-    else
-    {
-        jmax = 1;
-    }
-    for (j = 0; ((j < jmax) && (tStart < tendfit) && (tStart < ncorr*dt)); j++)
-    {
-        /* Estimate the correlation time for better fitting */
-        c_start     = -1;
-        ct_estimate = 0;
-        for (i = 0; (i < ncorr) && (dt*i < tStart || c1[i] > 0); i++)
-        {
-            if (c_start < 0)
-            {
-                if (dt*i >= tStart)
-                {
-                    c_start     = c1[i];
-                    ct_estimate = 0.5*c1[i];
-                }
-            }
-            else
-            {
-                ct_estimate += c1[i];
-            }
-        }
-        if (c_start > 0)
-        {
-            ct_estimate *= dt/c_start;
-        }
-        else
-        {
-            /* The data is strange, so we need to choose somehting */
-            ct_estimate = tendfit;
-        }
-        if (debug)
-        {
-            fprintf(debug, "tStart %g ct_estimate: %g\n", tStart, ct_estimate);
-        }
-
-        if (fitfn == effnEXP3)
-        {
-            fitparm[0] = 0.002*ncorr*dt;
-            fitparm[1] = 0.95;
-            fitparm[2] = 0.2*ncorr*dt;
-        }
-        else
-        {
-            /* Good initial guess, this increases the probability of convergence */
-            fitparm[0] = ct_estimate;
-            fitparm[1] = 1.0;
-            fitparm[2] = 1.0;
-        }
-
-        /* Generate more or less appropriate sigma's */
-        for (i = 0; i < ncorr; i++)
-        {
-            sig[i] = sqrt(ct_estimate+dt*i);
-        }
-
-        nf_int    = min(ncorr, (int)((tStart+1e-4)/dt));
-        sum       = print_and_integrate(debug, nf_int, dt, c1, NULL, 1);
-        tail_corr = do_lmfit(ncorr, c1, sig, dt, NULL, tStart, tendfit, oenv,
-                             bDebugMode(), fitfn, fitparm, 0);
-        sumtot = sum+tail_corr;
-        if (fit && ((jmax == 1) || (j == 1)))
-        {
-            for (i = 0; (i < ncorr); i++)
-            {
-                fit[i] = fit_function(fitfn, fitparm, i*dt);
-            }
-        }
-        if (bPrint)
-        {
-            printf("COR:%11.4e%11.4e%11.4e%11.4e", tStart, sum, tail_corr, sumtot);
-            for (i = 0; (i < nfp_ffn[fitfn]); i++)
-            {
-                printf(" %11.4e", fitparm[i]);
-            }
-            printf("\n");
-        }
-        tStart += tbeginfit;
-    }
-    sfree(sig);
-
-    return sumtot;
-}
-
 void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title,
                      int nframes, int nitem, int nout, real **c1,
                      real dt, unsigned long mode, int nrestart,
@@ -802,7 +555,10 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title,
     }
     if ((MODE(eacP3) || MODE(eacRcross)) && bFour)
     {
-        fprintf(stderr, "Can't combine mode %lu with FFT, turning off FFT\n", mode);
+        if (bVerbose)
+        {
+            fprintf(stderr, "Can't combine mode %lu with FFT, turning off FFT\n", mode);
+        }
         bFour = FALSE;
     }
     if (MODE(eacNormal) && MODE(eacVector))
@@ -966,6 +722,7 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title,
     sfree(fit);
 }
 
+/*! \brief Legend for selecting Legendre polynomials. */
 static const char *Leg[]   = { NULL, "0", "1", "2", "3", NULL };
 
 t_pargs *add_acf_pargs(int *npargs, t_pargs *pa)
@@ -988,20 +745,20 @@ t_pargs *add_acf_pargs(int *npargs, t_pargs *pa)
         { "-endfit",   FALSE, etREAL, {&acf.tendfit},
           "Time where to end the exponential fit of the correlation function, -1 is until the end" },
     };
-#define NPA asize(acfpa)
     t_pargs *ppa;
-    int      i;
+    int      i, npa;
 
-    snew(ppa, *npargs+NPA);
+    npa = asize(pa);
+    snew(ppa, *npargs+npa);
     for (i = 0; (i < *npargs); i++)
     {
         ppa[i] = pa[i];
     }
-    for (i = 0; (i < NPA); i++)
+    for (i = 0; (i < npa); i++)
     {
         ppa[*npargs+i] = acfpa[i];
     }
-    (*npargs) += NPA;
+    (*npargs) += npa;
 
     acf.mode       = 0;
     acf.nrestart   = 1;
@@ -1071,24 +828,3 @@ int get_acffitfn(void)
 
     return sffn2effn(s_ffn);
 }
-
-void cross_corr(int n, real f[], real g[], real corr[])
-{
-    int i, j;
-
-    if (acf.bFour)
-    {
-        correl(f-1, g-1, n, corr-1);
-    }
-    else
-    {
-        for (i = 0; (i < n); i++)
-        {
-            for (j = i; (j < n); j++)
-            {
-                corr[j-i] += f[i]*g[j];
-            }
-            corr[i] /= (real)(n-i);
-        }
-    }
-}
diff --git a/src/gromacs/correlationfunctions/autocorr.h b/src/gromacs/correlationfunctions/autocorr.h
new file mode 100644 (file)
index 0000000..e408b67
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \libinternal
+ * \defgroup module_correlationfunctions Correlation functions
+ * \ingroup group_analysismodules
+ * \brief
+ * Compute correlation functions and fit analytical functions to the result.
+ */
+/*! \libinternal
+ * \file
+ * \brief
+ * Declares routine for computing autocorrelation functions
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \inlibraryapi
+ * \ingroup module_correlationfunctions
+ */
+#ifndef GMX_AUTOCORR_H
+#define GMX_AUTOCORR_H
+
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/utility/real.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief Normal correlation f(t)*f(t+dt) */
+#define eacNormal (1<<0)
+/*! \brief Cosine correlation cos(f(t)-f(t+dt)) */
+#define eacCos    (1<<1)
+/*! \brief Vector correlation f(t).f(t+dt) */
+#define eacVector (1<<2)
+/*! \brief Norm of cross product |f(t) (x) f(t+dt)| */
+#define eacRcross (1<<3  | eacVector)
+/*! \brief Vector with Legendre polynomial of order 0 (same as vector) */
+#define eacP0     (1<<4  | eacVector)
+/*! \brief Vector with Legendre polynomial of order P_1(f(t).f(t+dt)) */
+#define eacP1     (1<<5  | eacVector)
+/*! \brief Vector with Legendre polynomial of order P_2(f(t).f(t+dt)) */
+#define eacP2     (1<<6  | eacVector)
+/*! \brief Vector with Legendre polynomial of order P_3(f(t).f(t+dt)) */
+#define eacP3     (1<<7  | eacVector)
+/*! \brief Vector with Legendre polynomial of order P_4(f(t).f(t+dt)) */
+#define eacP4     (1<<8  | eacVector)
+/*! \brief Binary identy correlation (f(t) == f(t+dt)) */
+#define eacIden   (1<<9) //Not supported for multiple cores
+
+/*! \brief
+ * Add commandline arguments related to autocorrelations to the existing array.
+ * *npargs must be initialised to the number of elements in pa,
+ * it will be incremented appropriately.
+ *
+ * \param npargs The number of arguments before and after (is changed in this function)
+ * \param[in] pa The initial argument list
+ * \return the new array
+ */
+t_pargs *add_acf_pargs(int *npargs, t_pargs *pa);
+
+/*! \brief
+ * Returns the number of points to output from a correlation function.
+ * Works only AFTER do_auto_corr has been called!
+ * \return the output length for the correlation function
+ */
+int get_acfnout(void);
+
+/*! \brief
+ * Returns the fitting function selected.
+ * Works only AFTER do_auto_corr has been called!
+ * \return the fit function type.
+ */
+int get_acffitfn(void);
+
+/*! \brief
+ * Calls low_do_autocorr (see below). add_acf_pargs has to be called before this
+ * can be used.
+ * \param[in] fn File name for xvg output (may this be NULL)?
+ * \param[in] oenv The output environment information
+ * \param[in] title is the title in the output file
+ * \param[in] nframes is the number of frames in the time series
+ * \param[in] nitem is the number of items
+ * \param[inout] c1 is an array of dimension [ 0 .. nitem-1 ] [ 0 .. nframes-1 ]
+ *          on output, this array is filled with the correlation function
+ *          to reduce storage
+ * \param[in] dt is the time between frames
+ * \param[in] mode Different types of ACF can be done, see above
+ * \param[in] bAver    If set, all ndih C(t) functions are averaged into a single
+ *          C(t)
+ */
+void do_autocorr(const char *fn, const output_env_t oenv,
+                 const char *title,
+                 int nframes, int nitem, real **c1,
+                 real dt, unsigned long mode, gmx_bool bAver);
+
+/*! \brief
+ * Low level computation of autocorrelation functions
+ *
+ * do_autocorr calculates autocorrelation functions for many things.
+ * It takes a 2 d array containing nitem arrays of length nframes
+ * for each item the ACF is calculated.
+ *
+ * A number of "modes" exist for computation of the ACF controlled
+ * by variable mode, with the following meaning.
+ *
+ * Mode       | Function
+ * -----------|------------
+ * eacNormal  | C(t) = < X (tau) * X (tau+t) >
+ * eacCos     | C(t) = < cos (X(tau) - X(tau+t)) >
+ * eacIden    | C(t) = < (X(tau) == X(tau+t)) > (not fully supported yet)
+ * eacVector  | C(t) = < X(tau) * X(tau+t)
+ * eacP1      | C(t) = < cos (X(tau) * X(tau+t) >
+ * eacP2      | C(t) = 1/2 * < 3 cos (X(tau) * X(tau+t) - 1 >
+ * eacRcross  | C(t) = < ( X(tau) * X(tau+t) )^2 >
+ *
+ * For modes eacVector, eacP1, eacP2 and eacRcross the input should be
+ * 3 x nframes long, where each triplet is taken as a 3D vector
+ *
+ * For mode eacCos inputdata must be in radians, not degrees!
+ *
+ * Other parameters are:
+ *
+ * \param[in] fn is output filename (.xvg) where the correlation function(s) are printed
+ * \param[in] oenv controls output file properties
+ * \param[in] title is the title in the output file
+ * \param[in] nframes is the number of frames in the time series
+ * \param[in] nitem is the number of items
+ * \param[in] nout
+ * \param[inout] c1 is an array of dimension [ 0 .. nitem-1 ] [ 0 .. nframes-1 ]
+ *          on output, this array is filled with the correlation function
+ *          to reduce storage
+ * \param[in] dt is the time between frames
+ * \param[in] mode Different types of ACF can be done, see above
+ * \param[in] nrestart     is the number of steps between restarts for direct ACFs
+ *              (i.e. without FFT) When set to 1 all points are used as
+ *              time origin for averaging
+ * \param[in] bAver    If set, all ndih C(t) functions are averaged into a single
+ *          C(t)
+ * \param[in] bNormalize   If set, all ACFs will be normalized to start at 0
+ * \param[in] bVerbose If set output to console will be generated
+ * \param[in] tbeginfit Time to start fitting to the ACF
+ * \param[in] tendfit Time to end fitting to the ACF
+ * \param[in] nfitparm Number of fitting parameters in a multi-exponential fit
+ */
+void low_do_autocorr(const char *fn, const output_env_t oenv,
+                     const char *title, int  nframes, int nitem,
+                     int nout, real **c1, real dt, unsigned long mode,
+                     int nrestart, gmx_bool bAver, gmx_bool bNormalize,
+                     gmx_bool bVerbose, real tbeginfit, real tendfit,
+                     int nfitparm);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gromacs/correlationfunctions/crosscorr.c b/src/gromacs/correlationfunctions/crosscorr.c
new file mode 100644 (file)
index 0000000..1911b5b
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal
+ * \file
+ * \brief
+ * Implements routine for computing a cross correlation between two data sets
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \ingroup module_correlationfunctions
+ */
+#include "gmxpre.h"
+
+#include "crosscorr.h"
+
+#include "gromacs/fft/fft.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/utility/smalloc.h"
+
+/*! \brief
+ * return the size witch the array should be after zero padding
+ *
+ * \param[in] n Factor to multiply by 2
+ * \return zeroPaddingSize
+ */
+static int zeroPaddingSize(int n)
+{
+    return 2*n;
+}
+
+/*! \brief
+ * Compute complex conjugate. Output in the first input variable.
+ *
+ * \param[in] in1 first complex number
+ * \param[in] in2 second complex number
+ */
+static void complexConjugatMult(double in1[], double in2[])
+{
+    double res[2];
+    res[0]  = in1[0] * in2[0] + in1[1] * in2[1];
+    res[1]  = in1[0] * -in2[1] + in1[1] * in2[0];
+    in1[0]  = res[0];
+    in1[1]  = res[1];
+}
+
+/*! \brief
+ * Compute one cross correlation corr = f x g using FFT.
+ *
+ * \param[in] n number of data point
+ * \param[in] f first function
+ * \param[in] g second function
+ * \param[out] corr output correlation
+ * \param[in] fft FFT data structure
+ */
+static void cross_corr_low(int n, real f[], real g[], real corr[], gmx_fft_t fft)
+{
+    int             i;
+    const int       size = zeroPaddingSize(n);
+    double    **    in1, ** in2;
+    snew(in1, size);
+    snew(in2, size);
+
+    for (i = 0; i < size; i++)
+    {
+        snew(in1[i], 2);
+        snew(in2[i], 2);
+    }
+
+    for (i = 0; i < n; i++)
+    {
+        in1[i][0]  = (double)f[i];
+        in1[i][1]  = 0;
+        in2[i][0]  = (double)g[i];
+        in2[i][1]  = 0;
+    }
+    for (; i < size; i++)
+    {
+        in1[i][0]  = 0;
+        in1[i][1]  = 0;
+        in2[i][0]  = 0;
+        in2[i][1]  = 0;
+    }
+
+
+    gmx_fft_1d(fft, GMX_FFT_FORWARD, in1, in1);
+    gmx_fft_1d(fft, GMX_FFT_FORWARD, in2, in2);
+
+    for (i = 0; i < size; i++)
+    {
+        complexConjugatMult(in1[i], in2[i]);
+        in1[i][0] /= size;
+    }
+    gmx_fft_1d(fft, GMX_FFT_BACKWARD, in1, in1);
+
+    for (i = 0; i < n; i++)
+    {
+        corr[i] = (real)(in1[i][0]);
+    }
+
+    for (i = 0; i < size; i++)
+    {
+        sfree(in1[i]);
+        sfree(in2[i]);
+    }
+
+    sfree(in1);
+    sfree(in2);
+
+}
+
+void cross_corr(int n, real f[], real g[], real corr[])
+{
+    gmx_fft_t fft;
+    gmx_fft_init_1d(&fft, zeroPaddingSize(n), GMX_FFT_FLAG_CONSERVATIVE);
+    cross_corr_low( n,  f,  g, corr, fft);
+    gmx_fft_destroy(fft);
+    gmx_fft_cleanup();
+}
+
+void many_cross_corr(int nFunc, int * nData, real ** f, real ** g, real ** corr)
+{
+#pragma omp parallel
+    //gmx_fft_t is not thread safe, so structure are allocated per thread.
+    {
+        int i;
+
+#pragma omp for
+        for (i = 0; i < nFunc; i++)
+        {
+            gmx_fft_t fft;
+            gmx_fft_init_1d(&fft, zeroPaddingSize(nData[i]), GMX_FFT_FLAG_CONSERVATIVE);
+            cross_corr_low( nData[i],  f[i],  g[i], corr[i], fft);
+            gmx_fft_destroy(fft);
+        }
+    }
+    gmx_fft_cleanup();
+
+}
diff --git a/src/gromacs/correlationfunctions/crosscorr.h b/src/gromacs/correlationfunctions/crosscorr.h
new file mode 100644 (file)
index 0000000..232e50f
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \libinternal
+ * \file
+ * \brief
+ * Declares routine for computing a cross correlation between two data sets
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \inlibraryapi
+ * \ingroup module_correlationfunctions
+ */
+#ifndef GMX_CROSSCORR_H
+#define GMX_CROSSCORR_H
+
+#include "gromacs/utility/real.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief
+ * fft cross correlation algorithm.
+ * Computes corr = f (.) g
+ *
+ * \param[in] n number of data point
+ * \param[in] f First function
+ * \param[in] g Second function
+ * \param[out] corr The cross correlation
+ */
+void cross_corr(int n, real f[], real g[], real corr[]);
+
+/*! \brief
+ * fft cross correlation algorithm.
+ *
+ * Computes corr[n] = f[n][i] (.) g[n][i], that is for nFunc
+ * pairs of arrays n the cross correlation is computed in parallel
+ * using OpenMP.
+ *
+ * \param[in] nFunc nuber of function to crosscorrelate
+ * \param[in] nData number of data point in eatch function
+ * \param[in] f 2D array of first function to crosscorrelate
+ * \param[in] g 2D array of second function to crosscorrelate
+ * \param[out] corr 2D array of the cross correlations
+ */
+void many_cross_corr(int nFunc, int * nData, real ** f, real ** g, real ** corr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gromacs/correlationfunctions/expfit.c b/src/gromacs/correlationfunctions/expfit.c
new file mode 100644 (file)
index 0000000..704943c
--- /dev/null
@@ -0,0 +1,698 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal
+ * \file
+ * \brief
+ * Implements routine for fitting a data set to a curve
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \ingroup module_correlationfunctions
+ */
+#include "gmxpre.h"
+
+#include "expfit.h"
+
+#include <math.h>
+#include <string.h>
+
+#include "external/lmfit/lmcurve.h"
+
+#include "gromacs/correlationfunctions/integrate.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/real.h"
+#include "gromacs/utility/smalloc.h"
+
+/*! \brief Number of parameters for each fitting function */
+static const int   nfp_ffn[effnNR] = { 0, 1, 2, 3, 2, 5, 7, 9, 4, 3, 6};
+
+const char        *s_ffn[effnNR+2] = {
+    NULL, "none", "exp", "aexp", "exp_exp", "vac",
+    "exp5", "exp7", "exp9", "erffit", "effnPRES", NULL, NULL
+};
+/* We don't allow errest as a choice on the command line */
+
+/*! \brief Long description for each fitting function type */
+static const char *longs_ffn[effnNR] = {
+    "no fit",
+    "y = exp(-x/a1)",
+    "y = a2 exp(-x/a1)",
+    "y = a2 exp(-x/a1) + (1-a2) exp(-x/a3)",
+    "y = exp(-v) (cosh(wv) + 1/w sinh(wv)), v = x/(2 a1), w = sqrt(1 - a2)",
+    "y = a1 exp(-x/a2) +  a3 exp(-x/a4) + a5",
+    "y = a1 exp(-x/a2) +  a3 exp(-x/a4) + a5 exp(-x/a6) + a7",
+    "y = a1 exp(-x/a2) +  a3 exp(-x/a4) + a5 exp(-x/a6) + a7 exp(-x/a8) + a9",
+    "y = 1/2*(a1+a2) - 1/2*(a1-a2)*erf( (x-a3) /a4^2)",
+    "y = a2 *2*a1*((exp(-x/a1)-1)*(a1/x)+1)+(1-a2)*2*a3*((exp(-x/a3)-1)*(a3/x)+1)",
+    "y = (1-a1) * exp(-(x/a3)^a4)*cos(x*a2) + a1*exp(-(x/a5)^a6)"
+};
+
+int effnNparams(int effn)
+{
+    if ((0 <= effn) && (effn < effnNR))
+    {
+        return nfp_ffn[effn];
+    }
+    else
+    {
+        return -1;
+    }
+}
+
+const char *effnDescription(int effn)
+{
+    if ((0 <= effn) && (effn < effnNR))
+    {
+        return longs_ffn[effn];
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+int sffn2effn(const char **sffn)
+{
+    int eFitFn, i;
+
+    eFitFn = 0;
+    for (i = 0; i < effnNR; i++)
+    {
+        if (sffn[i+1] && strcmp(sffn[0], sffn[i+1]) == 0)
+        {
+            eFitFn = i;
+        }
+    }
+
+    return eFitFn;
+}
+
+/*! \brief Compute exponential function A exp(-x/tau) */
+static double myexp(double x, double A, double tau)
+{
+    if ((A == 0) || (tau == 0))
+    {
+        return 0;
+    }
+    return A*exp(-x/tau);
+}
+
+/*! \brief Compute y=(a0+a1)/2-(a0-a1)/2*erf((x-a2)/a3^2) */
+static double lmc_erffit (double x, const double *a)
+{
+    double erfarg;
+
+    erfarg  = (x-a[2])/(a[3]*a[3]);
+    return (a[0]+a[1])/2-(a[0]-a[1])*gmx_erf(erfarg);
+}
+
+/*! \brief Compute y = exp(-x/a0) */
+static double lmc_exp_one_parm(double x, const double *a)
+{
+    return exp(-x/a[0]);
+}
+
+/*! \brief Compute y = a1 exp(-x/a0) */
+static double lmc_exp_two_parm(double x, const double *a)
+{
+    return a[1]*exp(-x/a[0]);
+}
+
+/*! \brief Compute y = a1 exp(-x/a0) + (1-a1) exp(-x/a2) */
+static double lmc_exp_3_parm(double x, const double *a)
+{
+    double e1, e2;
+
+    e1      = exp(-x/a[0]);
+    e2      = exp(-x/a[2]);
+    return a[1]*e1 + (1-a[1])*e2;
+}
+
+/*! \brief Compute y = a0 exp(-x/a1) + a2 exp(-x/a3) + a4 */
+static double lmc_exp_5_parm(double x, const double *a)
+{
+    double e1, e2;
+
+    e1      = exp(-x/a[1]);
+    e2      = exp(-x/a[3]);
+    return a[0]*e1 + a[2]*e2 + a[4];
+}
+
+/*! \brief Compute y = a0 exp(-x/a1) + a2 exp(-x/a3) + a4 exp(-x/a5) + a6 */
+static double lmc_exp_7_parm(double x, const double *a)
+{
+    double e1, e2, e3;
+
+    e1      = exp(-x/a[1]);
+    e2      = exp(-x/a[3]);
+    e3      = exp(-x/a[5]);
+    return a[0]*e1 + a[2]*e2 + a[4]*e3 + a[6];
+}
+
+/*! \brief Compute y = a0 exp(-x/a1) + a2 exp(-x/a3) + a4 exp(-x/a5) + a6 exp(-x/a7) + a8 */
+static double lmc_exp_9_parm(double x, const double *a)
+{
+    double e1, e2, e3, e4;
+
+    e1      = exp(-x/a[1]);
+    e2      = exp(-x/a[3]);
+    e3      = exp(-x/a[5]);
+    e4      = exp(-x/a[7]);
+    return a[0]*e1 + a[2]*e2 + a[4]*e3 + a[6]*e4 + a[8];
+}
+
+/*! \brief Compute y = (1-a1) * exp(-(x/a3)^a4)*cos(x*a2) + a1*exp(-(x/a5)^a6) */
+static double effnPRES_fun(double x, const double *a)
+{
+    double term1, term2, term3;
+
+    if (a[0] != 0)
+    {
+        term3 = a[0] * exp(-pow((x/a[4]), a[5]));
+    }
+    else
+    {
+        term3 = 0;
+    }
+
+    term1 = 1-a[0];
+    if (term1 != 0)
+    {
+        term2 = exp(-pow((x/a[2]), a[3])) * cos(x*a[1]);
+    }
+    else
+    {
+        term2 = 0;
+    }
+
+    return term1*term2 + term3;
+}
+
+/*! \brief Compute vac function */
+static double lmc_vac_2_parm(double x, const double *a)
+{
+    /* Fit to function
+     *
+     * y = 1/2 (1 - 1/w) exp(-(1+w)v) + 1/2 (1 + 1/w) exp(-(1-w)v)
+     *
+     *   = exp(-v) (cosh(wv) + 1/w sinh(wv))
+     *
+     *    v = x/(2 a1)
+     *    w = sqrt(1 - a2)
+     *
+     *    For tranverse current autocorrelation functions:
+     *       a1 = tau
+     *       a2 = 4 tau (eta/rho) k^2
+     *
+     */
+
+    double y, v, det, omega, omega2, em, ec, es;
+
+    v   = x/(2*a[0]);
+    det = 1 - a[1];
+    em  = exp(-v);
+    if (det != 0)
+    {
+        omega2  = fabs(det);
+        omega   = sqrt(omega2);
+        if (det > 0)
+        {
+            ec = em*0.5*(exp(omega*v)+exp(-omega*v));
+            es = em*0.5*(exp(omega*v)-exp(-omega*v))/omega;
+        }
+        else
+        {
+            ec = em*cos(omega*v);
+            es = em*sin(omega*v)/omega;
+        }
+        y      = ec + es;
+    }
+    else
+    {
+        y      = (1+v)*em;
+    }
+    return y;
+}
+
+/*! \brief Compute error estimate */
+static double lmc_errest_3_parm(double x, const double *a)
+{
+    /*
+       e1 = (exp(-x/a1) - 1)
+       e2 = (exp(-x/a3) - 1)
+       v1=  2*a1 * (e1*a1/x + 1)
+       v2 = 2*a3 * (e2*a3/x + 1)
+       fun = a2*v1 + (1 - a2) * v2
+     */
+    double e1, e2, v1, v2;
+
+    if (a[0] != 0)
+    {
+        e1 = exp(-x/a[0]) - 1;
+    }
+    else
+    {
+        e1 = 0;
+    }
+    if (a[2] != 0)
+    {
+        e2 = exp(-x/a[2]) - 1;
+    }
+    else
+    {
+        e2 = 0;
+    }
+
+    if (x > 0)
+    {
+        v1      = 2*a[0]*(e1*a[0]/x + 1);
+        v2      = 2*a[2]*(e2*a[2]/x + 1);
+        return a[1]*v1 + (1-a[1])*v2;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+/*! \brief function type for passing to fitting routine */
+typedef double (*t_lmcurve)(double x, const double *a);
+
+/*! \brief array of fitting functions corresponding to the pre-defined types */
+t_lmcurve lmcurves[effnNR] = {
+    lmc_exp_one_parm, lmc_exp_one_parm, lmc_exp_two_parm,
+    lmc_exp_3_parm, lmc_vac_2_parm,
+    lmc_exp_5_parm,   lmc_exp_7_parm,
+    lmc_exp_9_parm, lmc_erffit,  lmc_errest_3_parm, effnPRES_fun
+};
+
+double fit_function(int eFitFn, double *parm, double x)
+{
+    // TODO: check that eFitFn is within bounds
+    return lmcurves[eFitFn](x, parm);
+}
+
+/*! \brief lmfit_exp supports up to 3 parameter fitting of exponential functions */
+static gmx_bool lmfit_exp(int nfit, double x[], double y[],
+                          real ftol, int maxiter,
+                          double parm[], gmx_bool bVerbose,
+                          int eFitFn)
+{
+    double             chisq, ochisq;
+    gmx_bool           bCont;
+    int                i, j;
+    lm_control_struct *control;
+    lm_status_struct  *status;
+
+    if ((eFitFn < 0) || (eFitFn >= effnNR))
+    {
+        gmx_fatal(FARGS, "fitfn = %d, should be in 0..%d (%s,%d)",
+                  effnNR-1, eFitFn, __FILE__, __LINE__);
+    }
+
+    snew(control, 1);
+    control->ftol       = ftol;
+    control->xtol       = ftol;
+    control->gtol       = ftol;
+    control->epsilon    = 0.1;
+    control->stepbound  = 100;
+    control->patience   = maxiter;
+    control->scale_diag = 1;
+    control->msgfile    = stdout;
+    control->verbosity  = (bVerbose ? 1 : 0);
+    control->n_maxpri   = nfp_ffn[eFitFn];
+    control->m_maxpri   = 0;
+    snew(status, 1);
+    /* Initial params */
+    chisq  = 1e12;
+    j      = 0;
+    if (bVerbose)
+    {
+        fprintf(stderr, "%4s  %10s  Parameters\n",
+                "Step", "chi^2");
+    }
+    do
+    {
+        ochisq = chisq;
+
+        lmcurve(nfp_ffn[eFitFn], parm, nfit, x, y,
+                lmcurves[eFitFn], control, status);
+        chisq = sqr(status->fnorm);
+        if (bVerbose)
+        {
+            int mmm;
+            fprintf(stderr, "%4d  %10.5e", j, chisq);
+            for (mmm = 0; (mmm < nfp_ffn[eFitFn]); mmm++)
+            {
+                fprintf(stderr, "  %10.5e", parm[mmm]);
+            }
+            fprintf(stderr, "\n");
+        }
+        j++;
+        bCont = ((fabs(ochisq - chisq) > fabs(ftol*chisq)) ||
+                 ((ochisq == chisq)));
+    }
+    while (bCont && (j < maxiter));
+    if (bVerbose)
+    {
+        fprintf(stderr, "\n");
+    }
+
+    sfree(control);
+    sfree(status);
+
+    return TRUE;
+}
+
+/*! \brief See description in header file. */
+real do_lmfit(int ndata, real c1[], real sig[], real dt, real x0[],
+              real begintimefit, real endtimefit, const output_env_t oenv,
+              gmx_bool bVerbose, int eFitFn, double fitparms[], int fix)
+{
+    FILE    *fp;
+    char     buf[32];
+
+    int      i, j, nparm, nfitpnts;
+    double   integral, ttt;
+    double  *parm, *dparm;
+    double  *x, *y, *dy;
+#ifdef GMX_DOUBLE
+    real     ftol    = 1e-16;
+#else
+    real     ftol    = 1e-8;
+#endif
+    int      maxiter = 50;
+
+    if (0 != fix)
+    {
+        fprintf(stderr, "Using fixed parameters in curve fitting is not working anymore\n");
+    }
+    nparm = nfp_ffn[eFitFn];
+    if (debug)
+    {
+        fprintf(debug, "There are %d points to fit %d vars!\n", ndata, nparm);
+        fprintf(debug, "Fit to function %d from %g through %g, dt=%g\n",
+                eFitFn, begintimefit, endtimefit, dt);
+    }
+
+    snew(x, ndata);
+    snew(y, ndata);
+    snew(dy, ndata);
+
+    j = 0;
+    for (i = 0; i < ndata; i++)
+    {
+        ttt = x0 ? x0[i] : dt*i;
+        if (ttt >= begintimefit && ttt <= endtimefit)
+        {
+            x[j] = ttt;
+            y[j] = c1[i];
+
+            /* mrqmin does not like sig to be zero */
+            if (sig[i] < 1.0e-7)
+            {
+                dy[j] = 1.0e-7;
+            }
+            else
+            {
+                dy[j] = sig[i];
+            }
+            if (debug)
+            {
+                fprintf(debug, "j= %d, i= %d, x= %g, y= %g, dy= %g\n",
+                        j, i, x[j], y[j], dy[j]);
+            }
+            j++;
+        }
+    }
+    nfitpnts = j;
+    integral = 0;
+    if (nfitpnts < nparm)
+    {
+        fprintf(stderr, "Not enough data points for fitting!\n");
+    }
+    else
+    {
+        snew(parm, nparm);
+        snew(dparm, nparm);
+        if (fitparms)
+        {
+            for (i = 0; (i < nparm); i++)
+            {
+                parm[i] = fitparms[i];
+            }
+        }
+
+        if (!lmfit_exp(nfitpnts, x, y, ftol, maxiter, parm, bVerbose, eFitFn))
+        {
+            fprintf(stderr, "Fit failed!\n");
+        }
+        else if (nparm <= 3)
+        {
+            /* Compute the integral from begintimefit */
+            if (nparm == 3)
+            {
+                integral = (parm[0]*myexp(begintimefit, parm[1],  parm[0]) +
+                            parm[2]*myexp(begintimefit, 1-parm[1], parm[2]));
+            }
+            else if (nparm == 2)
+            {
+                integral = parm[0]*myexp(begintimefit, parm[1],  parm[0]);
+            }
+            else if (nparm == 1)
+            {
+                integral = parm[0]*myexp(begintimefit, 1,  parm[0]);
+            }
+            else
+            {
+                gmx_fatal(FARGS, "nparm = %d in file %s, line %d",
+                          nparm, __FILE__, __LINE__);
+            }
+
+            /* Generate THE output */
+            if (bVerbose)
+            {
+                fprintf(stderr, "FIT: # points used in fit is: %d\n", nfitpnts);
+                fprintf(stderr, "FIT: %21s%21s%21s\n",
+                        "parm0     ", "parm1 (ps)   ", "parm2 (ps)    ");
+                fprintf(stderr, "FIT: ------------------------------------------------------------\n");
+                fprintf(stderr, "FIT: %8.3g +/- %8.3g%9.4g +/- %8.3g%8.3g +/- %8.3g\n",
+                        parm[0], dparm[0], parm[1], dparm[1], parm[2], dparm[2]);
+                fprintf(stderr, "FIT: Integral (calc with fitted function) from %g ps to inf. is: %g\n",
+                        begintimefit, integral);
+
+                sprintf(buf, "test%d.xvg", nfitpnts);
+                fp = xvgropen(buf, "C(t) + Fit to C(t)", "Time (ps)", "C(t)", oenv);
+                fprintf(fp, "# parm0 = %g, parm1 = %g, parm2 = %g\n",
+                        parm[0], parm[1], parm[2]);
+                for (j = 0; (j < nfitpnts); j++)
+                {
+                    ttt = x0 ? x0[j] : dt*j;
+                    fprintf(fp, "%10.5e  %10.5e  %10.5e\n",
+                            ttt, c1[j],
+                            lmcurves[eFitFn](ttt, parm));
+                }
+                xvgrclose(fp);
+            }
+        }
+        if (fitparms)
+        {
+            for (i = 0; (i < nparm); i++)
+            {
+                fitparms[i] = parm[i];
+            }
+        }
+        sfree(parm);
+        sfree(dparm);
+    }
+
+    sfree(x);
+    sfree(y);
+    sfree(dy);
+
+    return integral;
+}
+
+/*! See description in header file. */
+real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose,
+             real tbeginfit, real tendfit, real dt, real c1[], real *fit)
+{
+    double      fitparm[3];
+    double      tStart, tail_corr, sum, sumtot = 0, c_start, ct_estimate;
+    real       *sig;
+    int         i, j, jmax, nf_int;
+    gmx_bool    bPrint;
+
+    bPrint = bVerbose || bDebugMode();
+
+    if (bPrint)
+    {
+        printf("COR:\n");
+    }
+
+    if (tendfit <= 0)
+    {
+        tendfit = ncorr*dt;
+    }
+    nf_int = min(ncorr, (int)(tendfit/dt));
+    sum    = print_and_integrate(debug, nf_int, dt, c1, NULL, 1);
+
+    /* Estimate the correlation time for better fitting */
+    ct_estimate = 0.5*c1[0];
+    for (i = 1; (i < ncorr) && (c1[i] > 0); i++)
+    {
+        ct_estimate += c1[i];
+    }
+    ct_estimate *= dt/c1[0];
+
+    if (bPrint)
+    {
+        printf("COR: Correlation time (plain integral from %6.3f to %6.3f ps) = %8.5f ps\n",
+               0.0, dt*nf_int, sum);
+        printf("COR: Relaxation times are computed as fit to an exponential:\n");
+        printf("COR:   %s\n", longs_ffn[fitfn]);
+        printf("COR: Fit to correlation function from %6.3f ps to %6.3f ps, results in a\n", tbeginfit, min(ncorr*dt, tendfit));
+    }
+
+    tStart = 0;
+    if (bPrint)
+    {
+        printf("COR:%11s%11s%11s%11s%11s%11s%11s\n",
+               "Fit from", "Integral", "Tail Value", "Sum (ps)", " a1 (ps)",
+               (nfp_ffn[fitfn] >= 2) ? " a2 ()" : "",
+               (nfp_ffn[fitfn] >= 3) ? " a3 (ps)" : "");
+    }
+
+    snew(sig, ncorr);
+
+    if (tbeginfit > 0)
+    {
+        jmax = 3;
+    }
+    else
+    {
+        jmax = 1;
+    }
+    for (j = 0; ((j < jmax) && (tStart < tendfit) && (tStart < ncorr*dt)); j++)
+    {
+        /* Estimate the correlation time for better fitting */
+        c_start     = -1;
+        ct_estimate = 0;
+        for (i = 0; (i < ncorr) && (dt*i < tStart || c1[i] > 0); i++)
+        {
+            if (c_start < 0)
+            {
+                if (dt*i >= tStart)
+                {
+                    c_start     = c1[i];
+                    ct_estimate = 0.5*c1[i];
+                }
+            }
+            else
+            {
+                ct_estimate += c1[i];
+            }
+        }
+        if (c_start > 0)
+        {
+            ct_estimate *= dt/c_start;
+        }
+        else
+        {
+            /* The data is strange, so we need to choose somehting */
+            ct_estimate = tendfit;
+        }
+        if (debug)
+        {
+            fprintf(debug, "tStart %g ct_estimate: %g\n", tStart, ct_estimate);
+        }
+
+        if (fitfn == effnEXP3)
+        {
+            fitparm[0] = 0.002*ncorr*dt;
+            fitparm[1] = 0.95;
+            fitparm[2] = 0.2*ncorr*dt;
+        }
+        else
+        {
+            /* Good initial guess, this increases the probability of convergence */
+            fitparm[0] = ct_estimate;
+            fitparm[1] = 1.0;
+            fitparm[2] = 1.0;
+        }
+
+        /* Generate more or less appropriate sigma's */
+        for (i = 0; i < ncorr; i++)
+        {
+            sig[i] = sqrt(ct_estimate+dt*i);
+        }
+
+        nf_int    = min(ncorr, (int)((tStart+1e-4)/dt));
+        sum       = print_and_integrate(debug, nf_int, dt, c1, NULL, 1);
+        tail_corr = do_lmfit(ncorr, c1, sig, dt, NULL, tStart, tendfit, oenv,
+                             bDebugMode(), fitfn, fitparm, 0);
+        sumtot = sum+tail_corr;
+        if (fit && ((jmax == 1) || (j == 1)))
+        {
+            double mfp[3];
+            for (i = 0; (i < 3); i++)
+            {
+                mfp[i] = fitparm[i];
+            }
+            for (i = 0; (i < ncorr); i++)
+            {
+                fit[i] = lmcurves[fitfn](i*dt, mfp);
+            }
+        }
+        if (bPrint)
+        {
+            printf("COR:%11.4e%11.4e%11.4e%11.4e", tStart, sum, tail_corr, sumtot);
+            for (i = 0; (i < nfp_ffn[fitfn]); i++)
+            {
+                printf(" %11.4e", fitparm[i]);
+            }
+            printf("\n");
+        }
+        tStart += tbeginfit;
+    }
+    sfree(sig);
+
+    return sumtot;
+}
diff --git a/src/gromacs/correlationfunctions/expfit.h b/src/gromacs/correlationfunctions/expfit.h
new file mode 100644 (file)
index 0000000..ee75f8d
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \libinternal
+ * \file
+ * \brief
+ * Declares routine for fitting a data set to a curve
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \inlibraryapi
+ * \ingroup module_correlationfunctions
+ */
+#ifndef GMX_EXPFIT_H
+#define GMX_EXPFIT_H
+
+#include "gromacs/legacyheaders/oenv.h"
+#include "gromacs/utility/real.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief
+ * Enum to select fitting functions
+ */
+enum {
+    effnNONE, effnEXP1, effnEXP2, effnEXP3,   effnVAC,
+    effnEXP5, effnEXP7, effnEXP9, effnERF, effnERREST, effnPRES, effnNR
+};
+
+/*! \brief
+ * Short name of each function type.
+ * This is exported for now in order to use when
+ * calling parse_common_args.
+ */
+extern const char *s_ffn[effnNR+2];
+
+/*! \brief
+ * Returns  description corresponding to the enum above, or NULL if out of range
+ * \param[in] effn Index
+ * \return Description or NULL
+ */
+const char *effnDescription(int effn);
+
+/*! \brief
+ * Returns  number of function parameters associated with a fitting function.
+ * \param[in] effn Index
+ * \return number or -1 if index out of range
+ */
+int effnNparams(int effn);
+
+/*! \brief
+ * Returns  corresponding to the selected enum option in sffn
+ * \param[in] sffn Two dimensional string array coming from parse_common_args
+ * \return the ffn enum
+ */
+int sffn2effn(const char **sffn);
+
+/*! \brief
+ * Returns the value of fit function eFitFn at x
+ * \param[in] eFitFn the index to the fitting function (0 .. effnNR)
+ * \param[in] parm Array of parameters, the length of which depends on eFitFn
+ * \param[in] x The value of x
+ * \return the value of the fit
+ */
+double fit_function(int eFitFn, double *parm, double x);
+
+/*! \brief
+ * Use Levenberg-Marquardt method to fit to a nfitparm parameter exponential
+ * or to a transverse current autocorrelation function.
+ *
+ * If x == NULL, the timestep dt will be used to create a time axis.
+ * \param[in] ndata Number of data points
+ * \param[in] c1 The data points
+ * \param[in] sig The standard deviation in the points
+ * \param[in] dt The time step
+ * \param[in] x The X-axis (may be NULL, see above)
+ * \param[in] begintimefit Starting time for fitting
+ * \param[in] endtimefit Ending time for fitting
+ * \param[in] oenv Output formatting information
+ * \param[in] bVerbose Should the routine write to console?
+ * \param[in] eFitFn Fitting function (0 .. effnNR)
+ * \param[out] fitparms[]
+ * \param[in] fix Constrains fit parameter i at it's starting value, when the i'th bit
+ * of fix is set.
+ * \return integral.
+ */
+real do_lmfit(int ndata, real c1[], real sig[], real dt, real *x,
+              real begintimefit, real endtimefit, const output_env_t oenv,
+              gmx_bool bVerbose, int eFitFn, double fitparms[], int fix);
+
+/*! \brief
+ * Fit an autocorrelation function to a pre-defined functional form
+ *
+ * \todo check parameters
+ * \param[in] ncorr
+ * \param[in] fitfn Fitting function (0 .. effnNR)
+ * \param[in] oenv Output formatting information
+ * \param[in] bVerbose Should the routine write to console?
+ * \param[in] tbeginfit Starting time for fitting
+ * \param[in] tendfit Ending time for fitting
+ * \param[in] dt The time step
+ * \param[in] c1 The data points
+ * \param[out] fit The fitting parameters
+ * \return the integral over the autocorrelation function?
+ */
+real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose,
+             real tbeginfit, real tendfit, real dt, real c1[], real *fit);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gromacs/correlationfunctions/integrate.c b/src/gromacs/correlationfunctions/integrate.c
new file mode 100644 (file)
index 0000000..dc0a7ae
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \brief
+ * Implement routines for integrating a data set
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ */
+#include "gmxpre.h"
+
+#include "integrate.h"
+
+#include <math.h>
+#include <stdio.h>
+
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/fatalerror.h"
+
+/*! \brief Integrate a function and printe the integral value. */
+real print_and_integrate(FILE *fp, int n, real dt, const real c[],
+                         const real *fit, int nskip)
+{
+    real c0, sum;
+    int  j;
+
+    /* Use trapezoidal rule for calculating integral */
+    sum = 0.0;
+    for (j = 0; (j < n); j++)
+    {
+        c0 = c[j];
+        if (fp && (nskip == 0 || j % nskip == 0))
+        {
+            fprintf(fp, "%10.3f  %10.5f\n", j*dt, c0);
+        }
+        if (j > 0)
+        {
+            sum += dt*(c0+c[j-1]);
+        }
+    }
+    if (fp)
+    {
+        fprintf(fp, "&\n");
+        if (fit)
+        {
+            for (j = 0; (j < n); j++)
+            {
+                if (nskip == 0 || j % nskip == 0)
+                {
+                    fprintf(fp, "%10.3f  %10.5f\n", j*dt, fit[j]);
+                }
+            }
+            fprintf(fp, "&\n");
+        }
+    }
+    return sum*0.5;
+}
+
+/*! \brief Compute and return the integral of a function. */
+real evaluate_integral(int n, const real x[], const real y[],
+                       const real dy[], real aver_start,
+                       real *stddev)
+{
+    double sum, sum_var, w;
+    double sum_tail = 0, sum2_tail = 0;
+    int    j, nsum_tail = 0;
+
+    /* Use trapezoidal rule for calculating integral */
+    if (n <= 0)
+    {
+        gmx_fatal(FARGS, "Evaluating integral: n = %d (file %s, line %d)",
+                  n, __FILE__, __LINE__);
+    }
+
+    sum     = 0;
+    sum_var = 0;
+    for (j = 0; (j < n); j++)
+    {
+        w = 0;
+        if (j > 0)
+        {
+            w += 0.5*(x[j] - x[j-1]);
+        }
+        if (j < n-1)
+        {
+            w += 0.5*(x[j+1] - x[j]);
+        }
+        sum += w*y[j];
+        if (dy)
+        {
+            /* Assume all errors are uncorrelated */
+            sum_var += sqr(w*dy[j]);
+        }
+
+        if ((aver_start > 0) && (x[j] >= aver_start))
+        {
+            sum_tail  += sum;
+            sum2_tail += sqrt(sum_var);
+            nsum_tail += 1;
+        }
+    }
+
+    if (nsum_tail > 0)
+    {
+        sum = sum_tail/nsum_tail;
+        /* This is a worst case estimate, assuming all stddev's are correlated. */
+        *stddev = sum2_tail/nsum_tail;
+    }
+    else
+    {
+        *stddev = sqrt(sum_var);
+    }
+
+    return sum;
+}
diff --git a/src/gromacs/correlationfunctions/integrate.h b/src/gromacs/correlationfunctions/integrate.h
new file mode 100644 (file)
index 0000000..2159cb9
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \libinternal
+ * \file
+ * \brief
+ * Declares routines for integrating a data set
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \inlibraryapi
+ * \ingroup module_correlationfunctions
+ */
+#ifndef GMX_INTEGRATE_H
+#define GMX_INTEGRATE_H
+
+#include <stdio.h>
+
+#include "gromacs/utility/real.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief
+ * Integrate the equispaced data in c[] from 0 to n using trapezium rule.
+ * If fit != NULL the fit is written as well.
+ * \param[in] fp File pointer to write to (maybe NULL)
+ * \param[in] n Number of data points
+ * \param[in] dt The time step between data points
+ * \param[in] c The data set
+ * \param[in] fit Fit to the function that is printed too if not a NULL pointer is passed.
+ * \param[in] nskip Determines whether all elements are written to the output file
+ * (written when i % nskip == 0)
+ * \return The integral
+ */
+real print_and_integrate(FILE *fp, int n, real dt, const real c[], const real *fit, int nskip);
+
+/*! \brief
+ * Integrate data in y using the trapezium rule, and, if given, use dy as weighting
+ *
+ * \param[in] n The number of data points
+ * \param[in] x The x coordinate
+ * \param[in] y The y data (function values)
+ * \param[in] dy The uncertainties (can be NULL)
+ * \param[in] aver_start should be set to a value where the function has
+ * converged to 0.
+ * \param[out] stddev The standard deviation in the integral
+ * \return the integral
+ */
+real evaluate_integral(int n, const real x[], const real y[], const real dy[], real aver_start,
+                       real *stddev);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/gromacs/correlationfunctions/manyautocorrelation.c b/src/gromacs/correlationfunctions/manyautocorrelation.c
new file mode 100644 (file)
index 0000000..c4fb7db
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief
+ * Implements function to compute many autocorrelation functions
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \ingroup module_correlationfunctions
+ */
+#include "gmxpre.h"
+
+#include "manyautocorrelation.h"
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gromacs/fft/fft.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/utility/gmxomp.h"
+#include "gromacs/utility/smalloc.h"
+
+int many_auto_correl(int nfunc, int ndata, int nfft, real **c)
+{
+    #pragma omp parallel
+    {
+        typedef real complex[2];
+        int          i, t, j, fftcode;
+        gmx_fft_t    fft1;
+        complex     *in, *out;
+        int          i0, i1;
+        int          nthreads, thread_id;
+
+        nthreads  = gmx_omp_get_max_threads();
+        thread_id = gmx_omp_get_thread_num();
+        if ((0 == thread_id))
+        {
+            // fprintf(stderr, "There are %d threads for correlation functions\n", nthreads);
+        }
+        i0 = thread_id*nfunc/nthreads;
+        i1 = min(nfunc, (thread_id+1)*nfunc/nthreads);
+
+        fftcode = gmx_fft_init_1d(&fft1, nfft, GMX_FFT_FLAG_CONSERVATIVE);
+        /* Allocate temporary arrays */
+        snew(in, nfft);
+        snew(out, nfft);
+        for (i = i0; (i < i1); i++)
+        {
+            for (j = 0; j < ndata; j++)
+            {
+                in[j][0] = c[i][j];
+                in[j][1] = 0;
+            }
+            for (; (j < nfft); j++)
+            {
+                in[j][0] = in[j][1] = 0;
+            }
+
+            fftcode = gmx_fft_1d(fft1, GMX_FFT_BACKWARD, (void *)in, (void *)out);
+            for (j = 0; j < nfft; j++)
+            {
+                in[j][0] = (out[j][0]*out[j][0] + out[j][1]*out[j][1])/nfft;
+                in[j][1] = 0;
+            }
+            for (; (j < nfft); j++)
+            {
+                in[j][0] = in[j][1] = 0;
+            }
+
+            fftcode = gmx_fft_1d(fft1, GMX_FFT_FORWARD, (void *)in, (void *)out);
+            for (j = 0; (j < nfft); j++)
+            {
+                c[i][j] = out[j][0]/ndata;
+            }
+        }
+        /* Free the memory */
+        gmx_fft_destroy(fft1);
+        sfree(in);
+        sfree(out);
+    }
+    // gmx_fft_cleanup();
+    return 0;
+}
diff --git a/src/gromacs/correlationfunctions/manyautocorrelation.h b/src/gromacs/correlationfunctions/manyautocorrelation.h
new file mode 100644 (file)
index 0000000..160f2da
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \libinternal
+ * \file
+ * \brief
+ * Declares routine for computing many correlation functions using OpenMP
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \inlibraryapi
+ * \ingroup module_correlationfunctions
+ */
+#ifndef GMX_MANYAUTOCORRELATION_H
+#define GMX_MANYAUTOCORRELATION_H
+
+#include "gromacs/fft/fft.h"
+#include "gromacs/utility/real.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief
+ * Perform many autocorrelation calculations.
+ *
+ * This routine performs many autocorrelation function calculations using FFTs.
+ * The GROMACS FFT library wrapper is employed. On return the c[] arrays contain
+ * a symmetric function that is useful for further FFT:ing, for instance in order to
+ * compute spectra.
+ *
+ * The functions uses OpenMP parallellization.
+ *
+ * \param[in] nfunc   Number of data functions to autocorrelate
+ * \param[in] ndata   Number of valid data points in the data
+ * \param[in] nfft    Length of the data arrays, this should at least be 50% larger than ndata. The c arrays will filled with zero beyond ndata before computing the correlation.
+ * \param[inout] c    Data array of size nfunc x nfft, will also be used for output
+ * \return fft error code, or zero if everything went fine (see fft/fft.h)
+ */
+int many_auto_correl(int nfunc, int ndata, int nfft, real **c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
similarity index 79%
rename from src/gromacs/gmxana/polynomials.c
rename to src/gromacs/correlationfunctions/polynomials.c
index 9f6257bfbe7adfe6645d630f7583760e8124f34d..c5f499a17daf50f92fbd1b2a13d3db484427c02c 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \internal \file
+ * \brief
+ * Implements help function to compute Legendre polynomials
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \author Anders G&auml;rden&auml;s <anders.gardenas@gmail.com>
+ * \ingroup module_correlationfunctions
+ */
 #include "gmxpre.h"
 
-#include <math.h>
-#include <stdio.h>
+#include "polynomials.h"
 
-#include "gromacs/gmxana/gstat.h"
-#include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/utility/fatalerror.h"
 
-real LegendreP(real x, unsigned long m)
+real LegendreP(real x, unsigned int m)
 
 {
     real polynomial = 0, x2, x3;
 
     switch (m)
     {
-        case eacP0:
+        case 0:
             polynomial = 1.0;
             break;
-        case eacP1:
+        case 1:
             polynomial = x;
             break;
-        case eacP2:
+        case 2:
             x2         = x*x;
             polynomial = 1.5*x2 - 0.5;
             break;
-        case eacP3:
+        case 3:
+            x2         = x*x;
+            polynomial = (5*x2*x - 3*x )* 0.5;
+            break;
+        case 4:
             x2         = x*x;
             polynomial = (35*x2*x2 - 30*x2 + 3)/8;
             break;
-        case eacP4:
+        case 5:
             x2         = x*x;
             x3         = x2*x;
             polynomial = (63*x3*x2 - 70*x3 + 15*x)/8;
             break;
         default:
-            gmx_fatal(FARGS, "Legendre polynomials of order %d are not supported, %s %d",
-                      m, __FILE__, __LINE__);
+            gmx_fatal(FARGS, "Legendre polynomials of order %u are not supported", m);
     }
     return (polynomial);
 }
similarity index 70%
rename from src/gromacs/gmxana/correl.h
rename to src/gromacs/correlationfunctions/polynomials.h
index 5851d6c28c2c569b8234a8a75a544974684a2cf9..5bb494e1a57da8bb7c63d4e70cea1b2952972481 100644 (file)
@@ -1,9 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2008, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/*! \libinternal
+ * \file
+ * \brief
+ * Declares routine for computing a Legendre polynomial
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \inlibraryapi
+ * \ingroup module_correlationfunctions
+ */
+#ifndef GMX_POLYNOMIALS_H
+#define GMX_POLYNOMIALS_H
 
+#include "gromacs/utility/real.h"
 
-#ifndef _correl_h
-#define _correl_h
-
-#include "gromacs/fft/fft.h"
-#include "gromacs/legacyheaders/typedefs.h"
-
-typedef struct {
-    int        n;
-    gmx_fft_t  fft_setup;
-    real      *buf1, *buf2, *abuf;
-} correl_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-extern correl_t *init_correl(int n);
-extern void done_correl(correl_t *c);
+/*! \brief
+ * Return Legendre polynomial value Pm(x)
+ * http://en.wikipedia.org/wiki/Legendre_polynomials
+ * \param[in] x The value
+ * \param[in] m The order of the polynomial (0-4 are supported)
+ * \return Pm(x)
+ */
+real LegendreP(real x, unsigned int m);
 
-extern void correl(real data1[], real data2[], int n, real ans[]);
-extern void four1(real data[], int nn, int isign);
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/src/gromacs/correlationfunctions/tests/CMakeLists.txt b/src/gromacs/correlationfunctions/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5bb3ad4
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2014, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+gmx_add_unit_test(CorrelationsTest  correlations-test
+  autocorr.cpp
+  correlationdataset.cpp
+  expfit.cpp)
+
diff --git a/src/gromacs/correlationfunctions/tests/autocorr.cpp b/src/gromacs/correlationfunctions/tests/autocorr.cpp
new file mode 100644 (file)
index 0000000..0bc95b3
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief
+ * Implements test of autocorrelation function routines
+ *
+ * \author Anders G&auml;rden&auml;s <anders.gardenas@gmail.com>
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \ingroup module_correlationfunctions
+ */
+#include "gmxpre.h"
+
+#include "gromacs/correlationfunctions/autocorr.h"
+
+#include <cmath>
+
+#include <gtest/gtest.h>
+
+#include "gromacs/correlationfunctions/expfit.h"
+#include "gromacs/fft/fft.h"
+#include "gromacs/legacyheaders/oenv.h"
+#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/uniqueptr.h"
+
+#include "testutils/refdata.h"
+#include "testutils/testasserts.h"
+#include "testutils/testfilemanager.h"
+
+#include "correlationdataset.h"
+
+namespace gmx
+{
+namespace
+{
+
+//! Definition of pointer to class containing test data.
+typedef gmx_unique_ptr<CorrelationDataSet>::type CorrelationDataSetPointer;
+
+class AutocorrTest : public ::testing::Test
+{
+    protected:
+
+        static int                                  nrFrames_;
+        static CorrelationDataSetPointer            data_;
+        // Need raw pointer for passing this to C routines
+        static t_pargs                            * tempArgs_;
+
+        test::TestReferenceData                     refData_;
+        test::TestReferenceChecker                  checker_;
+
+        // Use erefdataCreateMissing for creating new files
+        AutocorrTest( )
+            : checker_(refData_.rootChecker())
+        {
+#ifdef GMX_DOUBLE
+            checker_.setDefaultTolerance(test::relativeToleranceAsFloatingPoint(1, 1e-6));
+#else
+            checker_.setDefaultTolerance(test::relativeToleranceAsFloatingPoint(1, 1e-3));
+#endif
+        }
+
+        // Static initiation, only run once every test.
+        static void SetUpTestCase()
+        {
+            int         n        = 0;
+            std::string fileName = "testCOS3.xvg";
+            data_                = CorrelationDataSetPointer(new CorrelationDataSet(fileName));
+            nrFrames_            = data_->getNrLines();
+            tempArgs_            = add_acf_pargs(&n, NULL);
+        }
+
+        static void TearDownTestCase()
+        {
+
+            sfree(tempArgs_);
+            tempArgs_ = NULL;
+            gmx_fft_cleanup();
+        }
+
+        void test(unsigned long mode)
+        {
+            bool              bAverage      = false;
+            bool              bNormalize    = true;
+            bool              bVerbose      = false;
+            int               nrRestart     = 1;
+            int               dim           = getDim(mode);
+            std::vector<real> result;
+
+            for (int i = 0; i < nrFrames_; i++)
+            {
+                for (int m = 0; m < dim; m++)
+                {
+                    result.push_back(data_->getValue(m, i));
+                }
+            }
+            real *ptr = static_cast<real*>(&(result[0]));
+            low_do_autocorr(0, 0, 0,   nrFrames_, 1,
+                            get_acfnout(), &ptr, data_->getDt(), mode,
+                            nrRestart, bAverage, bNormalize,
+                            bVerbose, data_->getStartTime(), data_->getEndTime(),
+                            effnNONE);
+
+            double testResult = 0;
+            for (int i = 0; i < nrFrames_; i++)
+            {
+                testResult += result[i];
+            }
+            checker_.checkSequenceArray(nrFrames_, ptr,
+                                        "AutocorrelationFunction");
+            checker_.checkReal(testResult, "Integral");
+        }
+
+        int getDim(unsigned long type)
+        {
+            switch (type)
+            {
+                case eacNormal:
+                    return 1;
+                case eacVector:
+                    return 3;
+                case eacCos:
+                    return 1;
+                case eacRcross:
+                    return 3;
+                case eacP0:
+                    return 3;
+                case eacP1:
+                    return 3;
+                case eacP2:
+                    return 3;
+                case eacP3:
+                    return 3;
+                case eacP4:
+                    return 3;
+                case eacIden:
+                    return 1;
+                default:
+                    GMX_RELEASE_ASSERT(false, "Invalid auto correlation option");
+                    return -1;
+            }
+
+        }
+
+};
+
+int                         AutocorrTest::nrFrames_;
+CorrelationDataSetPointer   AutocorrTest::data_;
+t_pargs                   * AutocorrTest::tempArgs_;
+
+TEST_F (AutocorrTest, EacNormal)
+{
+    test(eacNormal);
+}
+
+TEST_F (AutocorrTest, EacCos)
+{
+    test(eacCos);
+}
+
+TEST_F (AutocorrTest, EacVector)
+{
+    test(eacVector);
+}
+
+TEST_F (AutocorrTest, EacRcross)
+{
+    test(eacRcross);
+}
+
+TEST_F (AutocorrTest, EacP0)
+{
+    test(eacP0);
+}
+
+TEST_F (AutocorrTest, EacP1)
+{
+    test(eacP1);
+}
+
+TEST_F (AutocorrTest, EacP2)
+{
+    test(eacP2);
+}
+
+TEST_F (AutocorrTest, EacP3)
+{
+    test(eacP3);
+}
+
+TEST_F (AutocorrTest, EacP4)
+{
+    test(eacP4);
+}
+
+
+}
+
+}
diff --git a/src/gromacs/correlationfunctions/tests/correlationdataset.cpp b/src/gromacs/correlationfunctions/tests/correlationdataset.cpp
new file mode 100644 (file)
index 0000000..371ba0e
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief
+ * Implements helper class for autocorrelation tests
+ *
+ * \author Anders G&auml;rden&auml;s <anders.gardenas@gmail.com>
+ * \ingroup module_correlationfunctions
+ */
+#include "gmxpre.h"
+
+#include "correlationdataset.h"
+
+#include <cmath>
+
+#include <sstream>
+
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/legacyheaders/oenv.h"
+#include "gromacs/utility/smalloc.h"
+
+#include "testutils/testfilemanager.h"
+
+CorrelationDataSet::CorrelationDataSet(const std::string &fileName)
+{
+    std::string fileNm = gmx::test::TestFileManager::getInputFilePath(fileName.c_str());
+    nrLines_    = read_xvg(fileNm.c_str(), &tempValues_, &nrColumns_);
+
+    dt_         = tempValues_[0][1] - tempValues_[0][0];
+    startTime_  = tempValues_[0][0];
+    endTime_    = tempValues_[0][nrLines_-1];
+}
+
+CorrelationDataSet::~CorrelationDataSet()
+{
+    // Allocated in read_xvg, destroyed here.
+    for (int i = 0; i < nrColumns_; i++)
+    {
+        sfree(tempValues_[i]);
+        tempValues_[i] = NULL;
+    }
+    sfree(tempValues_);
+    tempValues_ = NULL;
+}
+
+real CorrelationDataSet::getValue(int set, int time) const
+{
+    if (set+1 < nrColumns_)
+    {
+        return tempValues_[set+1][time];
+    }
+    else
+    {
+        return 0;
+    }
+}
diff --git a/src/gromacs/correlationfunctions/tests/correlationdataset.h b/src/gromacs/correlationfunctions/tests/correlationdataset.h
new file mode 100644 (file)
index 0000000..25af934
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief
+ * Declares helper class for autocorrelation tests
+ *
+ * \author Anders G&auml;rden&auml;s <anders.gardenas@gmail.com>
+ * \ingroup module_correlationfunctions
+ */
+#ifndef GMX_CORRELATIONDATASET_H
+#define GMX_CORRELATIONDATASET_H
+
+#include <string>
+#include <vector>
+
+#include "gromacs/utility/common.h"
+#include "gromacs/utility/real.h"
+
+class CorrelationDataSet
+{
+    double         ** tempValues_;
+
+    int               nrLines_;
+    int               nrColumns_;
+    double            startTime_;
+    double            endTime_;
+    double            dt_;
+
+    public:
+
+        /*! \brief
+         * Constructor
+         * \param[in] fileName containing function to test. *.xvg
+         */
+        explicit CorrelationDataSet(const std::string &fileName);
+
+        /*! \brief
+         * Return a value at an index
+         * \param[in] set the set number
+         * \param[in] t the time index of the value
+         */
+        real getValue(int set, int t) const;
+
+        /*! \brief
+         * Return the nummber of columns
+         */
+        int getNrColumns() const { return nrColumns_; }
+
+        /*! \brief
+         * Return the nummber of Lines
+         */
+        int getNrLines() const { return nrLines_; }
+
+        /*! \brief
+         * Return the time witch the function starts at
+         */
+        real getStartTime() const { return startTime_; }
+
+        /*! \brief
+         * Return the time the function ends at
+         */
+        real getEndTime() const { return endTime_; }
+
+        /*! \brief
+         * return delta time
+         */
+        real getDt() const { return dt_; }
+
+        /*! \brief
+         * Destructor
+         */
+        ~CorrelationDataSet();
+
+    private:
+        //! This class should not be copyable or assignable
+        GMX_DISALLOW_COPY_AND_ASSIGN(CorrelationDataSet);
+};
+
+#endif
diff --git a/src/gromacs/correlationfunctions/tests/expfit.cpp b/src/gromacs/correlationfunctions/tests/expfit.cpp
new file mode 100755 (executable)
index 0000000..4da4346
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \internal \file
+ * \brief
+ * Implements test of exponential fitting routines
+ *
+ * \author Anders G&auml;rden&auml;s <anders.gardenas@gmail.com>
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \ingroup module_correlationfunctions
+ */
+#include "gmxpre.h"
+
+#include "gromacs/correlationfunctions/expfit.h"
+
+#include <cmath>
+
+#include <gtest/gtest.h>
+
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/utility/smalloc.h"
+
+#include "testutils/refdata.h"
+#include "testutils/testasserts.h"
+#include "testutils/testfilemanager.h"
+
+//! Number of data files for testing.
+#define expTestNrTypes 3
+
+namespace gmx
+{
+
+namespace
+{
+
+class ExpfitTest : public ::testing::Test
+{
+
+    protected:
+        static int                 nrLines_;
+        static std::vector<real>   values_[expTestNrTypes];
+        static int                 nrColumns_;
+        static std::vector<real>   standardDev_;
+        static real                startTime_;
+        static real                endTime_;
+        static real                timeDeriv_;
+        test::TestReferenceData    refData_;
+        test::TestReferenceChecker checker_;
+        ExpfitTest( )
+            : checker_(refData_.rootChecker())
+        {
+        }
+
+        // Static initiation, only run once every test.
+        static void SetUpTestCase()
+        {
+            double   ** tempValues;
+            std::string fileName[expTestNrTypes];
+            fileName[0] = test::TestFileManager::getInputFilePath("testINVEXP.xvg");
+            fileName[1] = test::TestFileManager::getInputFilePath("testPRES.xvg");
+            fileName[2] = test::TestFileManager::getInputFilePath("testEXP.xvg");
+            for (int i = 0; i < expTestNrTypes; i++)
+            {
+                const char * name = fileName[i].c_str();
+                // TODO: this assumes all files have the same length.
+                nrLines_     = read_xvg(name, &tempValues, &nrColumns_);
+
+                // Generating standard deviation
+                if (i == 0)
+                {
+                    double fac = 1.0/nrLines_;
+                    for (int j = 0; j < nrLines_; j++)
+                    {
+                        standardDev_.push_back(fac);
+                    }
+                    timeDeriv_ = tempValues[0][1] - tempValues[0][0];
+                    startTime_ = tempValues[0][0];
+                    endTime_   = tempValues[0][nrLines_-1];
+                }
+
+                for (int j = 0; j  < nrLines_; j++)
+                {
+                    values_[i].push_back((real)tempValues[1][j]);
+                }
+
+                // Free memory that was allocated in read_xvg
+                for (int i = 0; i < nrColumns_; i++)
+                {
+                    sfree(tempValues[i]);
+                    tempValues[i] = NULL;
+                }
+                sfree(tempValues);
+                tempValues = NULL;
+            }
+        }
+
+        static void TearDownTestCase()
+        {
+        }
+
+        void test(int type, double result[], double tolerance, int testType)
+        {
+            int     nfitparm = effnNparams(type);
+
+            do_lmfit(nrLines_, &values_[testType][0], &standardDev_[0], timeDeriv_,
+                     NULL, startTime_, endTime_, NULL, false, type, result, 0);
+
+            checker_.setDefaultTolerance(test::relativeToleranceAsFloatingPoint(1, tolerance));
+            checker_.checkSequenceArray(nfitparm, result, "result");
+        }
+};
+
+
+//static var
+int               ExpfitTest::nrLines_;
+std::vector<real> ExpfitTest::values_[expTestNrTypes];
+int               ExpfitTest::nrColumns_;
+std::vector<real> ExpfitTest::standardDev_;
+real              ExpfitTest::startTime_;
+real              ExpfitTest::endTime_;
+real              ExpfitTest::timeDeriv_;
+
+TEST_F (ExpfitTest, EffnEXP1) {
+    double  param[] = {25};
+    test(effnEXP1, param, 1e-6, 0);
+}
+
+TEST_F (ExpfitTest, EffnEXP2) {
+    double  param[] = {35, 0.5};
+    test(effnEXP2, param, 1e-6, 0);
+}
+
+TEST_F (ExpfitTest, EffnEXP3) {
+    double param[] = {45, 0.5, 5};
+    test(effnEXP3, param, 1e-4, 0);
+}
+
+TEST_F (ExpfitTest, EffnEXP5) {
+    double  param[] = {0.5, 5, 0.5, 50, 0.002};
+    test(effnEXP5, param, 1e-4, 0);
+}
+
+TEST_F (ExpfitTest, EffnEXP7) {
+    double  param[] = {0.5, 5, -0.02, 0.5, 0.5, 50, -0.002};
+    test(effnEXP7, param, 1e-4, 0);
+}
+
+TEST_F (ExpfitTest, EffnEXP9) {
+    double  param[] = {2, 1200, -1, 300, 0.7, 70, 0.5, 6, -0.5};
+    test(effnEXP9, param, 4e-2, 0);
+}
+
+TEST_F (ExpfitTest, EffnERF) {
+    double  param[] = {0.5, 0.5, 0.5, 1};
+    test(effnERF, param, 1e-2, 0);
+}
+
+TEST_F (ExpfitTest, EffnERREST) {
+    double  param[] = {0.5, 0.7, 0.3};
+    test(effnERREST, param, 1e-4, 2);
+}
+
+TEST_F (ExpfitTest, EffnVAC) {
+    double param[] = {0.5, 0.05};
+    test(effnVAC, param, 1e-4, 0);
+}
+
+TEST_F (ExpfitTest, EffnPRES) {
+    double param[] = {0, 10, 4, 1, 0.5, 1};
+    test(effnPRES, param, 1e-4, 1);
+}
+
+}
+
+}
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacCos.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacCos.xml
new file mode 100644 (file)
index 0000000..34cba40
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>0.99659538</Real>
+    <Real>0.99595559</Real>
+    <Real>0.9944247</Real>
+    <Real>0.99254024</Real>
+    <Real>0.99074072</Real>
+    <Real>0.98782086</Real>
+    <Real>0.98476714</Real>
+    <Real>0.98145622</Real>
+    <Real>0.97775453</Real>
+    <Real>0.97388524</Real>
+    <Real>0.96959651</Real>
+    <Real>0.96521682</Real>
+    <Real>0.96071005</Real>
+    <Real>0.95656222</Real>
+    <Real>0.95218587</Real>
+    <Real>0.94799894</Real>
+    <Real>0.94426513</Real>
+    <Real>0.94049501</Real>
+    <Real>0.93681264</Real>
+    <Real>0.93319356</Real>
+    <Real>0.93034834</Real>
+    <Real>0.92801505</Real>
+    <Real>0.92570525</Real>
+    <Real>0.92359954</Real>
+    <Real>0.92197412</Real>
+    <Real>0.92073542</Real>
+    <Real>0.92040521</Real>
+    <Real>0.91959125</Real>
+    <Real>0.91971552</Real>
+    <Real>0.91937882</Real>
+    <Real>0.92004192</Real>
+    <Real>0.92134565</Real>
+    <Real>0.92249507</Real>
+    <Real>0.92415452</Real>
+    <Real>0.92598462</Real>
+    <Real>0.92835307</Real>
+    <Real>0.93056071</Real>
+    <Real>0.93232888</Real>
+    <Real>0.93553138</Real>
+    <Real>0.93841678</Real>
+    <Real>0.94149232</Real>
+    <Real>0.9445464</Real>
+    <Real>0.94751155</Real>
+    <Real>0.95099658</Real>
+    <Real>0.95437491</Real>
+    <Real>0.95766789</Real>
+    <Real>0.96085715</Real>
+    <Real>0.96405703</Real>
+    <Real>0.96722084</Real>
+    <Real>0.97044915</Real>
+    <Real>0.97360796</Real>
+    <Real>0.97608888</Real>
+    <Real>0.97839665</Real>
+    <Real>0.98092067</Real>
+    <Real>0.98309362</Real>
+    <Real>0.9850989</Real>
+    <Real>0.98661345</Real>
+    <Real>0.98806572</Real>
+    <Real>0.98921531</Real>
+    <Real>0.989797</Real>
+    <Real>0.99024576</Real>
+    <Real>0.99059737</Real>
+    <Real>0.99045819</Real>
+    <Real>0.99015921</Real>
+    <Real>0.98907006</Real>
+    <Real>0.98829621</Real>
+    <Real>0.98710001</Real>
+    <Real>0.98538107</Real>
+    <Real>0.98345906</Real>
+    <Real>0.98124063</Real>
+    <Real>0.97880316</Real>
+    <Real>0.97668463</Real>
+    <Real>0.97459376</Real>
+    <Real>0.97177458</Real>
+    <Real>0.9690451</Real>
+    <Real>0.96629435</Real>
+    <Real>0.96378684</Real>
+    <Real>0.96081358</Real>
+    <Real>0.95825708</Real>
+    <Real>0.95578271</Real>
+    <Real>0.95307195</Real>
+    <Real>0.95074266</Real>
+    <Real>0.94830912</Real>
+    <Real>0.94601887</Real>
+    <Real>0.94421709</Real>
+    <Real>0.94242907</Real>
+    <Real>0.94094354</Real>
+    <Real>0.93951678</Real>
+    <Real>0.93832368</Real>
+    <Real>0.93808126</Real>
+    <Real>0.93739355</Real>
+    <Real>0.93729556</Real>
+    <Real>0.93707997</Real>
+    <Real>0.93724543</Real>
+    <Real>0.93773413</Real>
+    <Real>0.93849856</Real>
+    <Real>0.93898928</Real>
+    <Real>0.94032645</Real>
+    <Real>0.94162965</Real>
+    <Real>0.94294119</Real>
+    <Real>0.94477904</Real>
+    <Real>0.94679701</Real>
+    <Real>0.94860345</Real>
+    <Real>0.95079654</Real>
+    <Real>0.95264018</Real>
+    <Real>0.95462155</Real>
+    <Real>0.95684212</Real>
+    <Real>0.95912236</Real>
+    <Real>0.96142673</Real>
+    <Real>0.96361393</Real>
+    <Real>0.96516949</Real>
+    <Real>0.96719009</Real>
+    <Real>0.96904653</Real>
+    <Real>0.97105813</Real>
+    <Real>0.97231489</Real>
+    <Real>0.97363442</Real>
+    <Real>0.9752683</Real>
+    <Real>0.97622961</Real>
+    <Real>0.97773701</Real>
+    <Real>0.9781059</Real>
+    <Real>0.97861946</Real>
+    <Real>0.97946876</Real>
+    <Real>0.97965133</Real>
+    <Real>0.98004115</Real>
+    <Real>0.97992533</Real>
+    <Real>0.97962075</Real>
+    <Real>0.97891223</Real>
+    <Real>0.97828108</Real>
+    <Real>0.97720605</Real>
+    <Real>0.97623944</Real>
+    <Real>0.97527778</Real>
+    <Real>0.97370166</Real>
+    <Real>0.97211659</Real>
+    <Real>0.97065586</Real>
+    <Real>0.96862853</Real>
+    <Real>0.96749282</Real>
+    <Real>0.96519589</Real>
+    <Real>0.96352464</Real>
+    <Real>0.96173507</Real>
+    <Real>0.9598251</Real>
+    <Real>0.9585008</Real>
+    <Real>0.95661891</Real>
+    <Real>0.95462286</Real>
+    <Real>0.95305181</Real>
+    <Real>0.951231</Real>
+    <Real>0.95024604</Real>
+    <Real>0.94892341</Real>
+    <Real>0.94788772</Real>
+    <Real>0.94696826</Real>
+    <Real>0.94605809</Real>
+    <Real>0.94519788</Real>
+    <Real>0.94469965</Real>
+    <Real>0.94453776</Real>
+    <Real>0.94388711</Real>
+    <Real>0.94351792</Real>
+    <Real>0.94364196</Real>
+    <Real>0.94375587</Real>
+    <Real>0.94424397</Real>
+    <Real>0.94460499</Real>
+    <Real>0.94499773</Real>
+    <Real>0.94563341</Real>
+    <Real>0.94637001</Real>
+    <Real>0.94729853</Real>
+    <Real>0.94789016</Real>
+    <Real>0.9492957</Real>
+    <Real>0.95013034</Real>
+    <Real>0.95128489</Real>
+    <Real>0.95289272</Real>
+    <Real>0.9538911</Real>
+    <Real>0.95517474</Real>
+    <Real>0.95651346</Real>
+    <Real>0.95739591</Real>
+    <Real>0.95905453</Real>
+    <Real>0.95995909</Real>
+    <Real>0.96129471</Real>
+    <Real>0.96225822</Real>
+    <Real>0.96320486</Real>
+    <Real>0.96370006</Real>
+    <Real>0.96436906</Real>
+    <Real>0.96505266</Real>
+    <Real>0.96569002</Real>
+    <Real>0.96630496</Real>
+    <Real>0.96670491</Real>
+    <Real>0.96745616</Real>
+    <Real>0.96741182</Real>
+    <Real>0.96750134</Real>
+    <Real>0.96715963</Real>
+    <Real>0.96682173</Real>
+    <Real>0.96666759</Real>
+    <Real>0.96608764</Real>
+    <Real>0.96583378</Real>
+    <Real>0.96554524</Real>
+    <Real>0.9645654</Real>
+    <Real>0.96389264</Real>
+    <Real>0.96256238</Real>
+    <Real>0.96151811</Real>
+    <Real>0.96107018</Real>
+    <Real>0.96008974</Real>
+    <Real>0.95841819</Real>
+    <Real>0.95736814</Real>
+    <Real>0.95627117</Real>
+    <Real>0.95525789</Real>
+    <Real>0.95427847</Real>
+    <Real>0.9530521</Real>
+    <Real>0.95182502</Real>
+    <Real>0.95049888</Real>
+    <Real>0.94935501</Real>
+    <Real>0.94850504</Real>
+    <Real>0.9477604</Real>
+    <Real>0.94666183</Real>
+    <Real>0.9459089</Real>
+    <Real>0.94507974</Real>
+    <Real>0.94467252</Real>
+    <Real>0.94344991</Real>
+    <Real>0.9432252</Real>
+    <Real>0.94265378</Real>
+    <Real>0.94217145</Real>
+    <Real>0.94254112</Real>
+    <Real>0.94218564</Real>
+    <Real>0.94258451</Real>
+    <Real>0.94247329</Real>
+    <Real>0.94219875</Real>
+    <Real>0.94211328</Real>
+    <Real>0.94299912</Real>
+    <Real>0.94275576</Real>
+    <Real>0.94383633</Real>
+    <Real>0.94452924</Real>
+    <Real>0.94524854</Real>
+    <Real>0.94583327</Real>
+    <Real>0.9464516</Real>
+    <Real>0.94671708</Real>
+    <Real>0.94742924</Real>
+    <Real>0.94788718</Real>
+    <Real>0.94856435</Real>
+    <Real>0.94880164</Real>
+    <Real>0.94944811</Real>
+    <Real>0.94974619</Real>
+    <Real>0.95041901</Real>
+    <Real>0.95081389</Real>
+    <Real>0.95117909</Real>
+    <Real>0.95128679</Real>
+    <Real>0.95191312</Real>
+    <Real>0.95196861</Real>
+    <Real>0.95284516</Real>
+    <Real>0.95309955</Real>
+    <Real>0.9532634</Real>
+    <Real>0.95333052</Real>
+    <Real>0.95380241</Real>
+    <Real>0.95404249</Real>
+    <Real>0.9541797</Real>
+    <Real>0.0019043376</Real>
+    <Real>0.0019041657</Real>
+    <Real>0.0019034834</Real>
+    <Real>0.00190268</Real>
+    <Real>0.0019021333</Real>
+    <Real>0.0019006877</Real>
+    <Real>0.0018999804</Real>
+    <Real>0.0018984226</Real>
+    <Real>0.0018965704</Real>
+    <Real>0.0018964604</Real>
+    <Real>0.0018947892</Real>
+    <Real>0.0018918787</Real>
+    <Real>0.0018907072</Real>
+    <Real>0.0018881153</Real>
+    <Real>0.0018871488</Real>
+    <Real>0.0018849894</Real>
+    <Real>0.0018837301</Real>
+    <Real>0.0018808114</Real>
+    <Real>0.0018789673</Real>
+    <Real>0.0018766357</Real>
+    <Real>0.0018757449</Real>
+    <Real>0.0018735129</Real>
+    <Real>0.0018722961</Real>
+    <Real>0.0018701779</Real>
+    <Real>0.001869004</Real>
+    <Real>0.0018674148</Real>
+    <Real>0.0018670724</Real>
+    <Real>0.0018658802</Real>
+    <Real>0.0018650054</Real>
+    <Real>0.0018644506</Real>
+    <Real>0.0018642544</Real>
+    <Real>0.0018643636</Real>
+    <Real>0.0018631493</Real>
+    <Real>0.0018632679</Real>
+    <Real>0.0018620805</Real>
+    <Real>0.0018617192</Real>
+    <Real>0.0018613907</Real>
+    <Real>0.0018620746</Real>
+    <Real>0.0018608437</Real>
+    <Real>0.0018616359</Real>
+    <Real>0.0018607891</Real>
+    <Real>0.001861356</Real>
+    <Real>0.0018617494</Real>
+    <Real>0.001862596</Real>
+    <Real>0.0018628497</Real>
+    <Real>0.0018639539</Real>
+    <Real>0.0018633736</Real>
+    <Real>0.0018630736</Real>
+    <Real>0.0018636734</Real>
+    <Real>0.001863839</Real>
+    <Real>0.0018648139</Real>
+    <Real>0.0018641106</Real>
+    <Real>0.0018644318</Real>
+    <Real>0.0018650938</Real>
+    <Real>0.0018654467</Real>
+    <Real>0.0018659889</Real>
+    <Real>0.0018662841</Real>
+    <Real>0.0018667069</Real>
+    <Real>0.0018669292</Real>
+    <Real>0.0018671628</Real>
+    <Real>0.0018675444</Real>
+    <Real>0.0018667035</Real>
+    <Real>0.0018655404</Real>
+    <Real>0.0018652284</Real>
+    <Real>0.0018667565</Real>
+    <Real>0.0018661944</Real>
+    <Real>0.0018663721</Real>
+    <Real>0.0018655302</Real>
+    <Real>0.0018643311</Real>
+    <Real>0.0018638286</Real>
+    <Real>0.0018621223</Real>
+    <Real>0.0018611329</Real>
+    <Real>0.0018599476</Real>
+    <Real>0.0018590478</Real>
+    <Real>0.0018587873</Real>
+    <Real>0.0018562102</Real>
+    <Real>0.0018557633</Real>
+    <Real>0.0018540745</Real>
+    <Real>0.001852081</Real>
+    <Real>0.0018499735</Real>
+    <Real>0.0018468326</Real>
+    <Real>0.0018452632</Real>
+    <Real>0.0018442717</Real>
+    <Real>0.0018425027</Real>
+    <Real>0.001839547</Real>
+    <Real>0.0018376643</Real>
+    <Real>0.001836191</Real>
+    <Real>0.0018344159</Real>
+    <Real>0.0018318044</Real>
+    <Real>0.0018301884</Real>
+    <Real>0.0018287364</Real>
+    <Real>0.0018269665</Real>
+    <Real>0.0018269968</Real>
+    <Real>0.0018270178</Real>
+    <Real>0.001825763</Real>
+    <Real>0.001825764</Real>
+    <Real>0.0018249867</Real>
+    <Real>0.0018219111</Real>
+    <Real>0.0018208193</Real>
+    <Real>0.0018213706</Real>
+    <Real>0.0018203714</Real>
+    <Real>0.0018217162</Real>
+    <Real>0.0018197326</Real>
+    <Real>0.0018210115</Real>
+    <Real>0.0018215602</Real>
+    <Real>0.0018208514</Real>
+    <Real>0.0018214376</Real>
+    <Real>0.0018191702</Real>
+    <Real>0.0018200848</Real>
+    <Real>0.0018206243</Real>
+    <Real>0.0018204382</Real>
+    <Real>0.001820185</Real>
+    <Real>0.0018186562</Real>
+    <Real>0.001817708</Real>
+    <Real>0.0018170066</Real>
+    <Real>0.0018171553</Real>
+    <Real>0.0018157695</Real>
+    <Real>0.0018159969</Real>
+    <Real>0.0018166977</Real>
+    <Real>0.0018168332</Real>
+    <Real>0.0018161659</Real>
+    <Real>0.0018163385</Real>
+    <Real>0.0018147173</Real>
+    <Real>0.0018156185</Real>
+    <Real>0.0018148925</Real>
+    <Real>0.0018124133</Real>
+    <Real>0.0018126937</Real>
+    <Real>0.0018113267</Real>
+    <Real>0.0018111287</Real>
+    <Real>0.0018093445</Real>
+    <Real>0.0018067171</Real>
+    <Real>0.0018067758</Real>
+    <Real>0.0018042427</Real>
+    <Real>0.0018018567</Real>
+    <Real>0.0017997391</Real>
+    <Real>0.0017981781</Real>
+    <Real>0.0017945498</Real>
+    <Real>0.001792311</Real>
+    <Real>0.0017904965</Real>
+    <Real>0.0017866502</Real>
+    <Real>0.0017860316</Real>
+    <Real>0.0017839982</Real>
+    <Real>0.0017814568</Real>
+    <Real>0.0017791466</Real>
+    <Real>0.0017781249</Real>
+    <Real>0.0017757714</Real>
+    <Real>0.0017761824</Real>
+    <Real>0.0017732615</Real>
+    <Real>0.0017709045</Real>
+    <Real>0.001768977</Real>
+    <Real>0.0017683667</Real>
+    <Real>0.0017667006</Real>
+    <Real>0.0017635585</Real>
+    <Real>0.0017620071</Real>
+    <Real>0.0017606486</Real>
+    <Real>0.0017580282</Real>
+    <Real>0.0017592428</Real>
+    <Real>0.0017556297</Real>
+    <Real>0.0017555061</Real>
+    <Real>0.001757534</Real>
+    <Real>0.0017574723</Real>
+    <Real>0.0017552145</Real>
+    <Real>0.0017545033</Real>
+    <Real>0.0017526622</Real>
+    <Real>0.0017496244</Real>
+    <Real>0.0017489279</Real>
+    <Real>0.0017457242</Real>
+    <Real>0.0017463452</Real>
+    <Real>0.0017450341</Real>
+    <Real>0.0017423715</Real>
+    <Real>0.001740228</Real>
+    <Real>0.0017355961</Real>
+    <Real>0.0017338913</Real>
+    <Real>0.0017318379</Real>
+    <Real>0.0017262439</Real>
+    <Real>0.0017226909</Real>
+    <Real>0.0017175399</Real>
+    <Real>0.0017158915</Real>
+    <Real>0.0017132005</Real>
+    <Real>0.0017120165</Real>
+    <Real>0.0017087469</Real>
+    <Real>0.0017068728</Real>
+    <Real>0.0017077745</Real>
+    <Real>0.0017095149</Real>
+    <Real>0.0017067558</Real>
+    <Real>0.0017066813</Real>
+    <Real>0.0017082159</Real>
+    <Real>0.0017052331</Real>
+    <Real>0.0017099206</Real>
+    <Real>0.0017054603</Real>
+    <Real>0.0017075579</Real>
+    <Real>0.001708627</Real>
+    <Real>0.0017047788</Real>
+    <Real>0.0017065253</Real>
+    <Real>0.0017045407</Real>
+    <Real>0.0017063328</Real>
+    <Real>0.001704243</Real>
+    <Real>0.001700534</Real>
+    <Real>0.0016963967</Real>
+    <Real>0.0016906861</Real>
+    <Real>0.0016869787</Real>
+    <Real>0.0016800896</Real>
+    <Real>0.001670838</Real>
+    <Real>0.0016614879</Real>
+    <Real>0.001651187</Real>
+    <Real>0.0016429743</Real>
+    <Real>0.0016380887</Real>
+    <Real>0.0016310038</Real>
+    <Real>0.0016253163</Real>
+    <Real>0.0016181563</Real>
+    <Real>0.0016086341</Real>
+    <Real>0.0016025983</Real>
+    <Real>0.0016049559</Real>
+    <Real>0.0016046603</Real>
+    <Real>0.0016040681</Real>
+    <Real>0.0016056809</Real>
+    <Real>0.0016082647</Real>
+    <Real>0.0016130897</Real>
+    <Real>0.0016240891</Real>
+    <Real>0.0016315721</Real>
+    <Real>0.0016403538</Real>
+    <Real>0.0016394467</Real>
+    <Real>0.0016503835</Real>
+    <Real>0.001656802</Real>
+    <Real>0.0016618307</Real>
+    <Real>0.0016678922</Real>
+    <Real>0.0016689304</Real>
+    <Real>0.0016764619</Real>
+    <Real>0.0016659491</Real>
+    <Real>0.0016657002</Real>
+    <Real>0.0016543285</Real>
+    <Real>0.0016382602</Real>
+    <Real>0.001622049</Real>
+    <Real>0.0015983427</Real>
+    <Real>0.00157369</Real>
+    <Real>0.0015392378</Real>
+    <Real>0.0014979994</Real>
+    <Real>0.0014626513</Real>
+    <Real>0.0014293678</Real>
+    <Real>0.0013948255</Real>
+    <Real>0.001376386</Real>
+    <Real>0.0013290521</Real>
+    <Real>0.0013200026</Real>
+    <Real>0.0012772934</Real>
+    <Real>0.0012205912</Real>
+    <Real>0.0011777489</Real>
+    <Real>0.0011112116</Real>
+    <Real>0.0010400851</Real>
+    <Real>0.00094952446</Real>
+    <Real>0.00096428557</Real>
+  </Sequence>
+  <Real Name="Integral">240.60057076136582</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacNormal.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacNormal.xml
new file mode 100644 (file)
index 0000000..415cf1f
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>0.92333996</Real>
+    <Real>0.89544791</Real>
+    <Real>0.85506064</Real>
+    <Real>0.80770195</Real>
+    <Real>0.76355565</Real>
+    <Real>0.70085573</Real>
+    <Real>0.63575351</Real>
+    <Real>0.56621635</Real>
+    <Real>0.49021092</Real>
+    <Real>0.41346616</Real>
+    <Real>0.32695487</Real>
+    <Real>0.23947404</Real>
+    <Real>0.15114491</Real>
+    <Real>0.068911292</Real>
+    <Real>-0.018343732</Real>
+    <Real>-0.10222372</Real>
+    <Real>-0.17851034</Real>
+    <Real>-0.2556752</Real>
+    <Real>-0.33233142</Real>
+    <Real>-0.40906069</Real>
+    <Real>-0.47129509</Real>
+    <Real>-0.52546626</Real>
+    <Real>-0.577564</Real>
+    <Real>-0.62862134</Real>
+    <Real>-0.66793829</Real>
+    <Real>-0.70031446</Real>
+    <Real>-0.71649045</Real>
+    <Real>-0.73871797</Real>
+    <Real>-0.74570811</Real>
+    <Real>-0.75775838</Real>
+    <Real>-0.75111836</Real>
+    <Real>-0.73185968</Real>
+    <Real>-0.71327382</Real>
+    <Real>-0.68468153</Real>
+    <Real>-0.65119308</Real>
+    <Real>-0.60643828</Real>
+    <Real>-0.56428039</Real>
+    <Real>-0.52878588</Real>
+    <Real>-0.46647781</Real>
+    <Real>-0.40880191</Real>
+    <Real>-0.34746397</Real>
+    <Real>-0.28559166</Real>
+    <Real>-0.22607948</Real>
+    <Real>-0.15521984</Real>
+    <Real>-0.087527938</Real>
+    <Real>-0.021420239</Real>
+    <Real>0.042880654</Real>
+    <Real>0.10628833</Real>
+    <Real>0.169659</Real>
+    <Real>0.23284768</Real>
+    <Real>0.29287171</Real>
+    <Real>0.33996987</Real>
+    <Real>0.3846795</Real>
+    <Real>0.4326345</Real>
+    <Real>0.47152123</Real>
+    <Real>0.50605392</Real>
+    <Real>0.53039247</Real>
+    <Real>0.552634</Real>
+    <Real>0.57193202</Real>
+    <Real>0.57857972</Real>
+    <Real>0.58289105</Real>
+    <Real>0.5867179</Real>
+    <Real>0.57858908</Real>
+    <Real>0.57083881</Real>
+    <Real>0.54604369</Real>
+    <Real>0.52723479</Real>
+    <Real>0.50264382</Real>
+    <Real>0.4660213</Real>
+    <Real>0.42628899</Real>
+    <Real>0.38307241</Real>
+    <Real>0.33706102</Real>
+    <Real>0.29605037</Real>
+    <Real>0.25652972</Real>
+    <Real>0.20322086</Real>
+    <Real>0.15179904</Real>
+    <Real>0.1005994</Real>
+    <Real>0.053715136</Real>
+    <Real>-0.0024519849</Real>
+    <Real>-0.051181242</Real>
+    <Real>-0.098006107</Real>
+    <Real>-0.15021549</Real>
+    <Real>-0.19438037</Real>
+    <Real>-0.2419212</Real>
+    <Real>-0.28681141</Real>
+    <Real>-0.32269096</Real>
+    <Real>-0.35785615</Real>
+    <Real>-0.38878986</Real>
+    <Real>-0.41733515</Real>
+    <Real>-0.44138661</Real>
+    <Real>-0.44811302</Real>
+    <Real>-0.46269119</Real>
+    <Real>-0.46645734</Real>
+    <Real>-0.47144547</Real>
+    <Real>-0.47026828</Real>
+    <Real>-0.46132591</Real>
+    <Real>-0.44804862</Real>
+    <Real>-0.43905067</Real>
+    <Real>-0.41386977</Real>
+    <Real>-0.38871932</Real>
+    <Real>-0.36298344</Real>
+    <Real>-0.32728449</Real>
+    <Real>-0.28807318</Real>
+    <Real>-0.25138158</Real>
+    <Real>-0.20809993</Real>
+    <Real>-0.17095725</Real>
+    <Real>-0.13121751</Real>
+    <Real>-0.086369112</Real>
+    <Real>-0.040557165</Real>
+    <Real>0.0057886061</Real>
+    <Real>0.050152354</Real>
+    <Real>0.082554683</Real>
+    <Real>0.12262377</Real>
+    <Real>0.15991174</Real>
+    <Real>0.19901413</Real>
+    <Real>0.22433081</Real>
+    <Real>0.25093538</Real>
+    <Real>0.28274411</Real>
+    <Real>0.30066779</Real>
+    <Real>0.33021459</Real>
+    <Real>0.33629516</Real>
+    <Real>0.34645689</Real>
+    <Real>0.3629137</Real>
+    <Real>0.36620525</Real>
+    <Real>0.37430125</Real>
+    <Real>0.37234989</Real>
+    <Real>0.36795545</Real>
+    <Real>0.35466814</Real>
+    <Real>0.34249428</Real>
+    <Real>0.32283241</Real>
+    <Real>0.30485228</Real>
+    <Real>0.28708842</Real>
+    <Real>0.25817123</Real>
+    <Real>0.22833388</Real>
+    <Real>0.20199309</Real>
+    <Real>0.16451561</Real>
+    <Real>0.14491151</Real>
+    <Real>0.10192882</Real>
+    <Real>0.071294688</Real>
+    <Real>0.03886297</Real>
+    <Real>0.0038909942</Real>
+    <Real>-0.020299936</Real>
+    <Real>-0.055376183</Real>
+    <Real>-0.092676423</Real>
+    <Real>-0.12172776</Real>
+    <Real>-0.15591128</Real>
+    <Real>-0.17435807</Real>
+    <Real>-0.19855703</Real>
+    <Real>-0.21759604</Real>
+    <Real>-0.2342567</Real>
+    <Real>-0.2501609</Real>
+    <Real>-0.26639262</Real>
+    <Real>-0.27480033</Real>
+    <Real>-0.2769354</Real>
+    <Real>-0.28888217</Real>
+    <Real>-0.29434624</Real>
+    <Real>-0.29110822</Real>
+    <Real>-0.28738263</Real>
+    <Real>-0.27644756</Real>
+    <Real>-0.26865044</Real>
+    <Real>-0.26017156</Real>
+    <Real>-0.24633232</Real>
+    <Real>-0.22993366</Real>
+    <Real>-0.21036342</Real>
+    <Real>-0.19680807</Real>
+    <Real>-0.16794714</Real>
+    <Real>-0.14982072</Real>
+    <Real>-0.1253354</Real>
+    <Real>-0.091874786</Real>
+    <Real>-0.070614971</Real>
+    <Real>-0.043464452</Real>
+    <Real>-0.01496042</Real>
+    <Real>0.0054097059</Real>
+    <Real>0.039536409</Real>
+    <Real>0.058995754</Real>
+    <Real>0.087431222</Real>
+    <Real>0.10856776</Real>
+    <Real>0.12864889</Real>
+    <Real>0.14001396</Real>
+    <Real>0.15372792</Real>
+    <Real>0.16890197</Real>
+    <Real>0.1832682</Real>
+    <Real>0.19547278</Real>
+    <Real>0.20601526</Real>
+    <Real>0.22224233</Real>
+    <Real>0.22276327</Real>
+    <Real>0.22658545</Real>
+    <Real>0.22071175</Real>
+    <Real>0.21529464</Real>
+    <Real>0.21472976</Real>
+    <Real>0.20628634</Real>
+    <Real>0.2043854</Real>
+    <Real>0.20099047</Real>
+    <Real>0.18452412</Real>
+    <Real>0.17380331</Real>
+    <Real>0.15045828</Real>
+    <Real>0.13115592</Real>
+    <Real>0.1251017</Real>
+    <Real>0.10887553</Real>
+    <Real>0.079097189</Real>
+    <Real>0.061385516</Real>
+    <Real>0.043582208</Real>
+    <Real>0.026112026</Real>
+    <Real>0.01028904</Real>
+    <Real>-0.011082372</Real>
+    <Real>-0.031485982</Real>
+    <Real>-0.055357713</Real>
+    <Real>-0.075118855</Real>
+    <Real>-0.088119961</Real>
+    <Real>-0.098915316</Real>
+    <Real>-0.11735611</Real>
+    <Real>-0.12887773</Real>
+    <Real>-0.14123638</Real>
+    <Real>-0.1465044</Real>
+    <Real>-0.16701357</Real>
+    <Real>-0.16918446</Real>
+    <Real>-0.17741001</Real>
+    <Real>-0.18355082</Real>
+    <Real>-0.17439707</Real>
+    <Real>-0.17841232</Real>
+    <Real>-0.16846335</Real>
+    <Real>-0.16889346</Real>
+    <Real>-0.17227842</Real>
+    <Real>-0.17070685</Real>
+    <Real>-0.15092036</Real>
+    <Real>-0.15334848</Real>
+    <Real>-0.12954405</Real>
+    <Real>-0.11295433</Real>
+    <Real>-0.09564729</Real>
+    <Real>-0.080270432</Real>
+    <Real>-0.06479656</Real>
+    <Real>-0.055495787</Real>
+    <Real>-0.03828676</Real>
+    <Real>-0.026680976</Real>
+    <Real>-0.0092150476</Real>
+    <Real>-0.0018779703</Real>
+    <Real>0.014258126</Real>
+    <Real>0.023644734</Real>
+    <Real>0.040185757</Real>
+    <Real>0.050761189</Real>
+    <Real>0.060287103</Real>
+    <Real>0.065608293</Real>
+    <Real>0.080362737</Real>
+    <Real>0.083356142</Real>
+    <Real>0.10414003</Real>
+    <Real>0.11332227</Real>
+    <Real>0.12000805</Real>
+    <Real>0.12286837</Real>
+    <Real>0.13463314</Real>
+    <Real>0.14336015</Real>
+    <Real>0.15017572</Real>
+    <Real>1.6947948e-05</Real>
+    <Real>1.720169e-05</Real>
+    <Real>1.6974916e-05</Real>
+    <Real>1.6350099e-05</Real>
+    <Real>1.6009559e-05</Real>
+    <Real>1.4935715e-05</Real>
+    <Real>1.4739877e-05</Real>
+    <Real>1.3568673e-05</Real>
+    <Real>1.1884022e-05</Real>
+    <Real>1.2356072e-05</Real>
+    <Real>1.0829273e-05</Real>
+    <Real>8.1364569e-06</Real>
+    <Real>7.3827168e-06</Real>
+    <Real>5.0695448e-06</Real>
+    <Real>4.5629454e-06</Real>
+    <Real>2.6695732e-06</Real>
+    <Real>1.858061e-06</Real>
+    <Real>-7.2692512e-07</Real>
+    <Real>-2.3541625e-06</Real>
+    <Real>-4.3265563e-06</Real>
+    <Real>-4.8195097e-06</Real>
+    <Real>-6.7002338e-06</Real>
+    <Real>-7.7089944e-06</Real>
+    <Real>-9.5448968e-06</Real>
+    <Real>-1.0355448e-05</Real>
+    <Real>-1.1747778e-05</Real>
+    <Real>-1.1522758e-05</Real>
+    <Real>-1.2354542e-05</Real>
+    <Real>-1.2857619e-05</Real>
+    <Real>-1.2877535e-05</Real>
+    <Real>-1.2482141e-05</Real>
+    <Real>-1.186068e-05</Real>
+    <Real>-1.2711519e-05</Real>
+    <Real>-1.2115619e-05</Real>
+    <Real>-1.2809192e-05</Real>
+    <Real>-1.266307e-05</Real>
+    <Real>-1.2433168e-05</Real>
+    <Real>-1.1129104e-05</Real>
+    <Real>-1.1863392e-05</Real>
+    <Real>-1.0522874e-05</Real>
+    <Real>-1.081662e-05</Real>
+    <Real>-9.6362273e-06</Real>
+    <Real>-8.5478041e-06</Real>
+    <Real>-7.0708343e-06</Real>
+    <Real>-6.063261e-06</Real>
+    <Real>-4.2370298e-06</Real>
+    <Real>-4.242017e-06</Real>
+    <Real>-3.9379211e-06</Real>
+    <Real>-2.6455057e-06</Real>
+    <Real>-1.8623408e-06</Real>
+    <Real>-1.7964911e-07</Real>
+    <Real>-3.1073461e-07</Real>
+    <Real>7.3710947e-07</Real>
+    <Real>2.2396036e-06</Real>
+    <Real>3.2355663e-06</Real>
+    <Real>4.1354356e-06</Real>
+    <Real>4.9965174e-06</Real>
+    <Real>6.2143517e-06</Real>
+    <Real>7.0087376e-06</Real>
+    <Real>7.9398487e-06</Real>
+    <Real>9.170898e-06</Real>
+    <Real>8.7619237e-06</Real>
+    <Real>8.1867083e-06</Real>
+    <Real>8.5060901e-06</Real>
+    <Real>1.0517992e-05</Real>
+    <Real>1.0658181e-05</Real>
+    <Real>1.1446352e-05</Real>
+    <Real>1.1257342e-05</Real>
+    <Real>1.0835259e-05</Real>
+    <Real>1.072865e-05</Real>
+    <Real>9.7357661e-06</Real>
+    <Real>9.4389143e-06</Real>
+    <Real>8.8261058e-06</Real>
+    <Real>8.7821072e-06</Real>
+    <Real>9.2549853e-06</Real>
+    <Real>7.5013804e-06</Real>
+    <Real>7.9371293e-06</Real>
+    <Real>6.941314e-06</Real>
+    <Real>5.6119507e-06</Real>
+    <Real>4.2042116e-06</Real>
+    <Real>1.5770001e-06</Real>
+    <Real>7.5386652e-07</Real>
+    <Real>8.054601e-07</Real>
+    <Real>-3.8413035e-07</Real>
+    <Real>-2.7380775e-06</Real>
+    <Real>-3.8733256e-06</Real>
+    <Real>-4.4854164e-06</Real>
+    <Real>-5.4874358e-06</Real>
+    <Real>-7.7627155e-06</Real>
+    <Real>-8.8810702e-06</Real>
+    <Real>-9.6242529e-06</Real>
+    <Real>-1.0713777e-05</Real>
+    <Real>-9.7594111e-06</Real>
+    <Real>-9.1061747e-06</Real>
+    <Real>-9.9740464e-06</Real>
+    <Real>-9.1629045e-06</Real>
+    <Real>-9.3594572e-06</Real>
+    <Real>-1.1867382e-05</Real>
+    <Real>-1.2593795e-05</Real>
+    <Real>-1.108304e-05</Real>
+    <Real>-1.1341308e-05</Real>
+    <Real>-9.0508356e-06</Real>
+    <Real>-1.0283045e-05</Real>
+    <Real>-7.9569845e-06</Real>
+    <Real>-6.1125238e-06</Real>
+    <Real>-5.6901622e-06</Real>
+    <Real>-3.8499225e-06</Real>
+    <Real>-5.0997382e-06</Real>
+    <Real>-2.6763032e-06</Real>
+    <Real>-6.1861641e-07</Real>
+    <Real>5.3073882e-07</Real>
+    <Real>1.6471934e-06</Real>
+    <Real>1.2461007e-06</Real>
+    <Real>1.3127881e-06</Real>
+    <Real>1.6117941e-06</Real>
+    <Real>3.1619384e-06</Real>
+    <Real>2.479977e-06</Real>
+    <Real>3.9845995e-06</Real>
+    <Real>5.5477849e-06</Real>
+    <Real>6.7357323e-06</Real>
+    <Real>6.96196e-06</Real>
+    <Real>8.1697226e-06</Real>
+    <Real>7.3396232e-06</Real>
+    <Real>9.1672227e-06</Real>
+    <Real>9.2835489e-06</Real>
+    <Real>7.8686735e-06</Real>
+    <Real>9.2934297e-06</Real>
+    <Real>9.3312292e-06</Real>
+    <Real>1.0179395e-05</Real>
+    <Real>9.534755e-06</Real>
+    <Real>7.9119627e-06</Real>
+    <Real>8.8005272e-06</Real>
+    <Real>7.683404e-06</Real>
+    <Real>6.0959087e-06</Real>
+    <Real>5.5420546e-06</Real>
+    <Real>5.3878371e-06</Real>
+    <Real>3.0048875e-06</Real>
+    <Real>2.3013924e-06</Real>
+    <Real>2.1645042e-06</Real>
+    <Real>-1.686885e-07</Real>
+    <Real>1.1400354e-06</Real>
+    <Real>8.5925473e-07</Real>
+    <Real>-9.5177079e-08</Real>
+    <Real>-4.9476733e-07</Real>
+    <Real>1.9566522e-07</Real>
+    <Real>-5.2322918e-07</Real>
+    <Real>1.5911113e-06</Real>
+    <Real>-2.2981799e-07</Real>
+    <Real>-1.546277e-06</Real>
+    <Real>-2.5809338e-06</Real>
+    <Real>-2.1874198e-06</Real>
+    <Real>-2.8447707e-06</Real>
+    <Real>-6.003168e-06</Real>
+    <Real>-7.5685598e-06</Real>
+    <Real>-7.4805835e-06</Real>
+    <Real>-9.8007476e-06</Real>
+    <Real>-7.5790431e-06</Real>
+    <Real>-1.0517209e-05</Real>
+    <Real>-9.3698382e-06</Real>
+    <Real>-6.0820844e-06</Real>
+    <Real>-4.513266e-06</Real>
+    <Real>-6.1426217e-06</Real>
+    <Real>-6.0664988e-06</Real>
+    <Real>-5.9408303e-06</Real>
+    <Real>-7.6888364e-06</Real>
+    <Real>-5.7454145e-06</Real>
+    <Real>-6.4514843e-06</Real>
+    <Real>-2.5307936e-06</Real>
+    <Real>-7.7979479e-07</Real>
+    <Real>-4.4557851e-07</Real>
+    <Real>5.4281566e-07</Real>
+    <Real>-1.0177969e-06</Real>
+    <Real>6.5963206e-07</Real>
+    <Real>2.0811055e-06</Real>
+    <Real>-2.8522754e-07</Real>
+    <Real>-6.4073208e-07</Real>
+    <Real>-2.8998365e-06</Real>
+    <Real>-1.901788e-06</Real>
+    <Real>-1.4455151e-06</Real>
+    <Real>-2.8910372e-07</Real>
+    <Real>-1.1323684e-06</Real>
+    <Real>-1.4292134e-06</Real>
+    <Real>5.0386113e-08</Real>
+    <Real>1.6381324e-06</Real>
+    <Real>-2.2276123e-07</Real>
+    <Real>-2.6079434e-07</Real>
+    <Real>8.866005e-07</Real>
+    <Real>-6.5319233e-07</Real>
+    <Real>3.4602701e-06</Real>
+    <Real>-1.2270907e-07</Real>
+    <Real>2.7422018e-06</Real>
+    <Real>4.2824836e-06</Real>
+    <Real>2.1185413e-06</Real>
+    <Real>4.1770027e-06</Real>
+    <Real>2.8447578e-06</Real>
+    <Real>6.3908592e-06</Real>
+    <Real>7.3948709e-06</Real>
+    <Real>8.2409342e-06</Real>
+    <Real>9.704383e-06</Real>
+    <Real>8.35023e-06</Real>
+    <Real>9.6003869e-06</Real>
+    <Real>9.2930559e-06</Real>
+    <Real>6.1146638e-06</Real>
+    <Real>3.3621252e-06</Real>
+    <Real>-9.8457065e-07</Real>
+    <Real>-1.8718846e-06</Real>
+    <Real>3.0094341e-07</Real>
+    <Real>4.6674396e-07</Real>
+    <Real>4.4797812e-07</Real>
+    <Real>-1.0786407e-06</Real>
+    <Real>-7.5938456e-06</Real>
+    <Real>-1.1059399e-05</Real>
+    <Real>-8.3233581e-06</Real>
+    <Real>-3.8355511e-06</Real>
+    <Real>-2.1474427e-06</Real>
+    <Real>-5.2963392e-06</Real>
+    <Real>-7.1621521e-06</Real>
+    <Real>-6.4974288e-06</Real>
+    <Real>-2.2986844e-06</Real>
+    <Real>-1.416352e-06</Real>
+    <Real>-2.1892388e-06</Real>
+    <Real>-7.1828599e-06</Real>
+    <Real>-2.4088042e-06</Real>
+    <Real>3.2049647e-06</Real>
+    <Real>7.2408707e-06</Real>
+    <Real>7.6889664e-06</Real>
+    <Real>8.6848986e-06</Real>
+    <Real>2.0444573e-05</Real>
+    <Real>1.4390439e-05</Real>
+    <Real>2.2760736e-05</Real>
+    <Real>2.4064513e-05</Real>
+    <Real>2.2546323e-05</Real>
+    <Real>2.7139242e-05</Real>
+    <Real>2.466367e-05</Real>
+    <Real>2.6582289e-05</Real>
+    <Real>1.9750434e-05</Real>
+    <Real>9.4496218e-06</Real>
+    <Real>6.6170951e-06</Real>
+    <Real>1.0806426e-05</Real>
+    <Real>7.6765937e-06</Real>
+    <Real>1.8425069e-05</Real>
+    <Real>1.2401573e-05</Real>
+    <Real>3.9162929e-05</Real>
+    <Real>2.2949267e-05</Real>
+    <Real>-6.7865421e-06</Real>
+    <Real>-1.1479357e-05</Real>
+    <Real>-5.3619879e-05</Real>
+    <Real>-0.00011380042</Real>
+    <Real>-0.00016269117</Real>
+    <Real>-0.00016905692</Real>
+  </Sequence>
+  <Real Name="Integral">0.049695708357404555</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP0.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP0.xml
new file mode 100644 (file)
index 0000000..d318d51
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>0.91440845</Real>
+    <Real>0.89127165</Real>
+    <Real>0.85387266</Real>
+    <Real>0.81370103</Real>
+    <Real>0.7681002</Real>
+    <Real>0.70884496</Real>
+    <Real>0.65127754</Real>
+    <Real>0.58396322</Real>
+    <Real>0.50845456</Real>
+    <Real>0.43051061</Real>
+    <Real>0.35105249</Real>
+    <Real>0.26587203</Real>
+    <Real>0.18143819</Real>
+    <Real>0.097567506</Real>
+    <Real>0.015512385</Real>
+    <Real>-0.068423927</Real>
+    <Real>-0.1456465</Real>
+    <Real>-0.22284648</Real>
+    <Real>-0.29907748</Real>
+    <Real>-0.37475094</Real>
+    <Real>-0.4380517</Real>
+    <Real>-0.49662268</Real>
+    <Real>-0.55154026</Real>
+    <Real>-0.60047692</Real>
+    <Real>-0.64397019</Real>
+    <Real>-0.67695993</Real>
+    <Real>-0.69747227</Real>
+    <Real>-0.71946371</Real>
+    <Real>-0.73064023</Real>
+    <Real>-0.73969084</Real>
+    <Real>-0.73910058</Real>
+    <Real>-0.72273451</Real>
+    <Real>-0.70480442</Real>
+    <Real>-0.68460542</Real>
+    <Real>-0.65121585</Real>
+    <Real>-0.61127657</Real>
+    <Real>-0.56959647</Real>
+    <Real>-0.53186774</Real>
+    <Real>-0.47233477</Real>
+    <Real>-0.42289308</Real>
+    <Real>-0.36013916</Real>
+    <Real>-0.30238953</Real>
+    <Real>-0.23851043</Real>
+    <Real>-0.17228492</Real>
+    <Real>-0.10760929</Real>
+    <Real>-0.038677685</Real>
+    <Real>0.023924842</Real>
+    <Real>0.085734844</Real>
+    <Real>0.14554502</Real>
+    <Real>0.21178007</Real>
+    <Real>0.26366264</Real>
+    <Real>0.31547186</Real>
+    <Real>0.36479235</Real>
+    <Real>0.41372058</Real>
+    <Real>0.45014268</Real>
+    <Real>0.48719069</Real>
+    <Real>0.51477271</Real>
+    <Real>0.54144377</Real>
+    <Real>0.55743951</Real>
+    <Real>0.56827539</Real>
+    <Real>0.57417756</Real>
+    <Real>0.57521474</Real>
+    <Real>0.57242984</Real>
+    <Real>0.56181103</Real>
+    <Real>0.54661202</Real>
+    <Real>0.5273785</Real>
+    <Real>0.49807823</Real>
+    <Real>0.46791199</Real>
+    <Real>0.43094185</Real>
+    <Real>0.39116937</Real>
+    <Real>0.34865311</Real>
+    <Real>0.30475527</Real>
+    <Real>0.26447845</Real>
+    <Real>0.20973703</Real>
+    <Real>0.16015707</Real>
+    <Real>0.10805874</Real>
+    <Real>0.059454329</Real>
+    <Real>0.0076480238</Real>
+    <Real>-0.045675594</Real>
+    <Real>-0.089126058</Real>
+    <Real>-0.14246953</Real>
+    <Real>-0.18825532</Real>
+    <Real>-0.22974341</Real>
+    <Real>-0.27582318</Real>
+    <Real>-0.30692092</Real>
+    <Real>-0.34222001</Real>
+    <Real>-0.37205994</Real>
+    <Real>-0.39867413</Real>
+    <Real>-0.42049485</Real>
+    <Real>-0.43268493</Real>
+    <Real>-0.446363</Real>
+    <Real>-0.45471677</Real>
+    <Real>-0.45743033</Real>
+    <Real>-0.45754004</Real>
+    <Real>-0.44663361</Real>
+    <Real>-0.43691492</Real>
+    <Real>-0.42143744</Real>
+    <Real>-0.39964595</Real>
+    <Real>-0.37948313</Real>
+    <Real>-0.35078076</Real>
+    <Real>-0.32291207</Real>
+    <Real>-0.28617722</Real>
+    <Real>-0.25431877</Real>
+    <Real>-0.21413048</Real>
+    <Real>-0.17472994</Real>
+    <Real>-0.13722105</Real>
+    <Real>-0.0940689</Real>
+    <Real>-0.050582096</Real>
+    <Real>-0.011372223</Real>
+    <Real>0.033095215</Real>
+    <Real>0.064681761</Real>
+    <Real>0.10605592</Real>
+    <Real>0.13676096</Real>
+    <Real>0.17619975</Real>
+    <Real>0.20634755</Real>
+    <Real>0.23424256</Real>
+    <Real>0.26192936</Real>
+    <Real>0.28315401</Real>
+    <Real>0.31159228</Real>
+    <Real>0.32296148</Real>
+    <Real>0.3337082</Real>
+    <Real>0.3472271</Real>
+    <Real>0.35520938</Real>
+    <Real>0.35884556</Real>
+    <Real>0.35598138</Real>
+    <Real>0.36070585</Real>
+    <Real>0.34978899</Real>
+    <Real>0.33616209</Real>
+    <Real>0.32133636</Real>
+    <Real>0.30463791</Real>
+    <Real>0.28434399</Real>
+    <Real>0.26060301</Real>
+    <Real>0.23513913</Real>
+    <Real>0.21211421</Real>
+    <Real>0.18200785</Real>
+    <Real>0.15506685</Real>
+    <Real>0.11292174</Real>
+    <Real>0.08485233</Real>
+    <Real>0.048554849</Real>
+    <Real>0.015430034</Real>
+    <Real>-0.0053237719</Real>
+    <Real>-0.043886948</Real>
+    <Real>-0.069251105</Real>
+    <Real>-0.099874027</Real>
+    <Real>-0.1318848</Real>
+    <Real>-0.15587749</Real>
+    <Real>-0.18213047</Real>
+    <Real>-0.19872877</Real>
+    <Real>-0.22116253</Real>
+    <Real>-0.23839074</Real>
+    <Real>-0.24964274</Real>
+    <Real>-0.25999296</Real>
+    <Real>-0.26915544</Real>
+    <Real>-0.28208914</Real>
+    <Real>-0.28375041</Real>
+    <Real>-0.2840305</Real>
+    <Real>-0.28654379</Real>
+    <Real>-0.27391881</Real>
+    <Real>-0.26717883</Real>
+    <Real>-0.25783545</Real>
+    <Real>-0.24391536</Real>
+    <Real>-0.23143035</Real>
+    <Real>-0.21355876</Real>
+    <Real>-0.19516303</Real>
+    <Real>-0.17305651</Real>
+    <Real>-0.14851433</Real>
+    <Real>-0.13391782</Real>
+    <Real>-0.10106573</Real>
+    <Real>-0.079669952</Real>
+    <Real>-0.054322001</Real>
+    <Real>-0.022567146</Real>
+    <Real>-0.0082916291</Real>
+    <Real>0.028239559</Real>
+    <Real>0.044842608</Real>
+    <Real>0.066723041</Real>
+    <Real>0.086818486</Real>
+    <Real>0.11206019</Real>
+    <Real>0.13034853</Real>
+    <Real>0.14292336</Real>
+    <Real>0.16384037</Real>
+    <Real>0.17437287</Real>
+    <Real>0.19422586</Real>
+    <Real>0.19642359</Real>
+    <Real>0.20773162</Real>
+    <Real>0.21621291</Real>
+    <Real>0.22017281</Real>
+    <Real>0.21870746</Real>
+    <Real>0.22144818</Real>
+    <Real>0.21968257</Real>
+    <Real>0.21284904</Real>
+    <Real>0.20909898</Real>
+    <Real>0.20217142</Real>
+    <Real>0.19360588</Real>
+    <Real>0.18018678</Real>
+    <Real>0.16507152</Real>
+    <Real>0.14102207</Real>
+    <Real>0.13159586</Real>
+    <Real>0.11218439</Real>
+    <Real>0.090035476</Real>
+    <Real>0.069503993</Real>
+    <Real>0.054288179</Real>
+    <Real>0.034861948</Real>
+    <Real>0.013234816</Real>
+    <Real>-0.0047988398</Real>
+    <Real>-0.024740862</Real>
+    <Real>-0.042112309</Real>
+    <Real>-0.057106286</Real>
+    <Real>-0.079133794</Real>
+    <Real>-0.08531253</Real>
+    <Real>-0.10183473</Real>
+    <Real>-0.11679</Real>
+    <Real>-0.13124378</Real>
+    <Real>-0.13978031</Real>
+    <Real>-0.15192363</Real>
+    <Real>-0.15962306</Real>
+    <Real>-0.16721499</Real>
+    <Real>-0.17583407</Real>
+    <Real>-0.17053062</Real>
+    <Real>-0.17783985</Real>
+    <Real>-0.17420124</Real>
+    <Real>-0.16439037</Real>
+    <Real>-0.16967009</Real>
+    <Real>-0.16545986</Real>
+    <Real>-0.15178227</Real>
+    <Real>-0.1513456</Real>
+    <Real>-0.13972749</Real>
+    <Real>-0.12844835</Real>
+    <Real>-0.11278458</Real>
+    <Real>-0.10008006</Real>
+    <Real>-0.084673822</Real>
+    <Real>-0.071988769</Real>
+    <Real>-0.055301242</Real>
+    <Real>-0.044846795</Real>
+    <Real>-0.024612129</Real>
+    <Real>-0.012670649</Real>
+    <Real>0.0064235702</Real>
+    <Real>0.017517105</Real>
+    <Real>0.032193232</Real>
+    <Real>0.05088919</Real>
+    <Real>0.059888519</Real>
+    <Real>0.073218867</Real>
+    <Real>0.084005043</Real>
+    <Real>0.097417012</Real>
+    <Real>0.11064502</Real>
+    <Real>0.11908618</Real>
+    <Real>0.12669091</Real>
+    <Real>0.12785465</Real>
+    <Real>0.13891017</Real>
+    <Real>0.14016822</Real>
+    <Real>0.15007298</Real>
+    <Real>4.4267403e-05</Real>
+    <Real>4.3514352e-05</Real>
+    <Real>4.3138727e-05</Real>
+    <Real>4.1891646e-05</Real>
+    <Real>4.0179297e-05</Real>
+    <Real>3.8032213e-05</Real>
+    <Real>3.7556416e-05</Real>
+    <Real>3.5218971e-05</Real>
+    <Real>3.1478037e-05</Real>
+    <Real>3.0895699e-05</Real>
+    <Real>2.615025e-05</Real>
+    <Real>2.0906495e-05</Real>
+    <Real>1.7488654e-05</Real>
+    <Real>1.3209424e-05</Real>
+    <Real>9.7491848e-06</Real>
+    <Real>6.3581501e-06</Real>
+    <Real>5.6303825e-06</Real>
+    <Real>-5.1143962e-07</Real>
+    <Real>-4.6430905e-06</Real>
+    <Real>-8.4661779e-06</Real>
+    <Real>-1.0448402e-05</Real>
+    <Real>-1.6193704e-05</Real>
+    <Real>-1.857411e-05</Real>
+    <Real>-2.250258e-05</Real>
+    <Real>-2.3523124e-05</Real>
+    <Real>-2.7104035e-05</Real>
+    <Real>-2.8832133e-05</Real>
+    <Real>-2.9649824e-05</Real>
+    <Real>-3.12257e-05</Real>
+    <Real>-3.2669741e-05</Real>
+    <Real>-3.3304954e-05</Real>
+    <Real>-3.3183347e-05</Real>
+    <Real>-3.4332639e-05</Real>
+    <Real>-3.3677767e-05</Real>
+    <Real>-3.4504159e-05</Real>
+    <Real>-3.454684e-05</Real>
+    <Real>-3.2467542e-05</Real>
+    <Real>-2.9868665e-05</Real>
+    <Real>-2.9505636e-05</Real>
+    <Real>-2.6500937e-05</Real>
+    <Real>-2.6333106e-05</Real>
+    <Real>-2.3109949e-05</Real>
+    <Real>-2.140675e-05</Real>
+    <Real>-1.6538143e-05</Real>
+    <Real>-1.4951454e-05</Real>
+    <Real>-1.0329346e-05</Real>
+    <Real>-8.6922209e-06</Real>
+    <Real>-6.4748251e-06</Real>
+    <Real>-2.4234089e-06</Real>
+    <Real>2.1927521e-07</Real>
+    <Real>2.7016404e-06</Real>
+    <Real>3.5660794e-06</Real>
+    <Real>6.7710325e-06</Real>
+    <Real>1.154716e-05</Real>
+    <Real>1.27539e-05</Real>
+    <Real>1.4957743e-05</Real>
+    <Real>1.8768704e-05</Real>
+    <Real>1.983804e-05</Real>
+    <Real>2.258397e-05</Real>
+    <Real>2.3245073e-05</Real>
+    <Real>2.5949555e-05</Real>
+    <Real>2.7714603e-05</Real>
+    <Real>2.4125953e-05</Real>
+    <Real>2.7313827e-05</Real>
+    <Real>2.6500267e-05</Real>
+    <Real>2.8872726e-05</Real>
+    <Real>2.8494722e-05</Real>
+    <Real>2.8652294e-05</Real>
+    <Real>2.6291838e-05</Real>
+    <Real>2.3836281e-05</Real>
+    <Real>2.2856551e-05</Real>
+    <Real>2.24215e-05</Real>
+    <Real>2.2928167e-05</Real>
+    <Real>2.0600462e-05</Real>
+    <Real>2.1569322e-05</Real>
+    <Real>1.8669114e-05</Real>
+    <Real>1.6274531e-05</Real>
+    <Real>1.3573073e-05</Real>
+    <Real>1.2755655e-05</Real>
+    <Real>9.1842421e-06</Real>
+    <Real>4.9424475e-06</Real>
+    <Real>1.9999163e-06</Real>
+    <Real>1.2401867e-06</Real>
+    <Real>-3.0244464e-06</Real>
+    <Real>-7.6198962e-06</Real>
+    <Real>-9.8329774e-06</Real>
+    <Real>-8.8280267e-06</Real>
+    <Real>-1.377236e-05</Real>
+    <Real>-1.6982995e-05</Real>
+    <Real>-1.9108473e-05</Real>
+    <Real>-2.0853575e-05</Real>
+    <Real>-2.3638708e-05</Real>
+    <Real>-2.4330864e-05</Real>
+    <Real>-2.3607576e-05</Real>
+    <Real>-2.3350785e-05</Real>
+    <Real>-2.4861311e-05</Real>
+    <Real>-2.4024377e-05</Real>
+    <Real>-2.7649214e-05</Real>
+    <Real>-3.0116586e-05</Real>
+    <Real>-2.7083521e-05</Real>
+    <Real>-2.6461454e-05</Real>
+    <Real>-2.5706378e-05</Real>
+    <Real>-2.3319637e-05</Real>
+    <Real>-2.2089596e-05</Real>
+    <Real>-1.7878658e-05</Real>
+    <Real>-1.7124203e-05</Real>
+    <Real>-1.5375375e-05</Real>
+    <Real>-1.5521959e-05</Real>
+    <Real>-1.172509e-05</Real>
+    <Real>-9.1009997e-06</Real>
+    <Real>-5.6435597e-06</Real>
+    <Real>-2.9174676e-06</Real>
+    <Real>-5.4268908e-06</Real>
+    <Real>-1.5508874e-06</Real>
+    <Real>-3.7975212e-07</Real>
+    <Real>3.1173399e-06</Real>
+    <Real>1.9381382e-06</Real>
+    <Real>5.5445184e-06</Real>
+    <Real>6.774098e-06</Real>
+    <Real>8.9054111e-06</Real>
+    <Real>1.0997211e-05</Real>
+    <Real>1.4307585e-05</Real>
+    <Real>1.3101091e-05</Real>
+    <Real>1.5396869e-05</Real>
+    <Real>1.3836742e-05</Real>
+    <Real>1.4298585e-05</Real>
+    <Real>1.65646e-05</Real>
+    <Real>1.5446933e-05</Real>
+    <Real>1.9028628e-05</Real>
+    <Real>2.0577343e-05</Real>
+    <Real>1.6241767e-05</Real>
+    <Real>1.6588914e-05</Real>
+    <Real>1.6793663e-05</Real>
+    <Real>1.5231977e-05</Real>
+    <Real>1.3574629e-05</Real>
+    <Real>1.3824551e-05</Real>
+    <Real>1.3580589e-05</Real>
+    <Real>8.8718243e-06</Real>
+    <Real>8.9766982e-06</Real>
+    <Real>4.874571e-06</Real>
+    <Real>6.1740734e-06</Real>
+    <Real>4.3778728e-06</Real>
+    <Real>3.0633016e-06</Real>
+    <Real>2.650128e-06</Real>
+    <Real>4.4499197e-06</Real>
+    <Real>5.2487553e-07</Real>
+    <Real>3.844505e-06</Real>
+    <Real>8.3970571e-07</Real>
+    <Real>-4.0378814e-06</Real>
+    <Real>-4.2863321e-06</Real>
+    <Real>-3.9477163e-06</Real>
+    <Real>-5.5808941e-06</Real>
+    <Real>-8.159157e-06</Real>
+    <Real>-1.07823e-05</Real>
+    <Real>-1.0445928e-05</Real>
+    <Real>-1.4758529e-05</Real>
+    <Real>-1.5891597e-05</Real>
+    <Real>-1.6962238e-05</Real>
+    <Real>-1.6818865e-05</Real>
+    <Real>-1.3153352e-05</Real>
+    <Real>-1.3562746e-05</Real>
+    <Real>-1.536158e-05</Real>
+    <Real>-1.6916658e-05</Real>
+    <Real>-1.5912401e-05</Real>
+    <Real>-1.9311357e-05</Real>
+    <Real>-1.3812277e-05</Real>
+    <Real>-1.7308477e-05</Real>
+    <Real>-1.1393254e-05</Real>
+    <Real>-6.9415369e-06</Real>
+    <Real>-8.5329793e-06</Real>
+    <Real>-7.3732735e-06</Real>
+    <Real>-8.2779943e-06</Real>
+    <Real>-4.1989624e-06</Real>
+    <Real>-4.0598088e-06</Real>
+    <Real>-6.2781332e-06</Real>
+    <Real>-6.1900923e-06</Real>
+    <Real>-9.3725657e-06</Real>
+    <Real>-9.9827339e-06</Real>
+    <Real>-9.6235508e-06</Real>
+    <Real>-4.7038488e-06</Real>
+    <Real>-3.4777854e-06</Real>
+    <Real>-2.7908015e-06</Real>
+    <Real>1.7161137e-06</Real>
+    <Real>2.1103369e-06</Real>
+    <Real>1.6298396e-06</Real>
+    <Real>5.1353272e-06</Real>
+    <Real>9.7297398e-06</Real>
+    <Real>7.9292831e-06</Real>
+    <Real>1.0491432e-05</Real>
+    <Real>8.7098369e-06</Real>
+    <Real>1.1306504e-05</Real>
+    <Real>1.2767204e-05</Real>
+    <Real>1.0523996e-05</Real>
+    <Real>1.5876185e-05</Real>
+    <Real>1.8240517e-05</Real>
+    <Real>1.7410239e-05</Real>
+    <Real>1.8709565e-05</Real>
+    <Real>2.0682788e-05</Real>
+    <Real>2.2414559e-05</Real>
+    <Real>2.3641453e-05</Real>
+    <Real>2.9956356e-05</Real>
+    <Real>3.1942258e-05</Real>
+    <Real>3.2165972e-05</Real>
+    <Real>2.3073231e-05</Real>
+    <Real>2.1864589e-05</Real>
+    <Real>2.3307522e-05</Real>
+    <Real>2.6105658e-05</Real>
+    <Real>3.0764437e-05</Real>
+    <Real>2.5258372e-05</Real>
+    <Real>2.4398061e-05</Real>
+    <Real>1.5440721e-05</Real>
+    <Real>7.2866023e-06</Real>
+    <Real>4.1072926e-06</Real>
+    <Real>1.3465999e-05</Real>
+    <Real>9.5875193e-06</Real>
+    <Real>3.303629e-06</Real>
+    <Real>-9.6435542e-06</Real>
+    <Real>-1.4834303e-05</Real>
+    <Real>-1.3345806e-05</Real>
+    <Real>-1.2496928e-05</Real>
+    <Real>-1.2373329e-05</Real>
+    <Real>-1.9174164e-05</Real>
+    <Real>-2.2750348e-05</Real>
+    <Real>-1.0412362e-05</Real>
+    <Real>-7.1453283e-06</Real>
+    <Real>-5.0996732e-06</Real>
+    <Real>-1.4278352e-06</Real>
+    <Real>1.091708e-05</Real>
+    <Real>6.6890452e-06</Real>
+    <Real>2.0174368e-05</Real>
+    <Real>1.0472003e-05</Real>
+    <Real>4.7418193e-06</Real>
+    <Real>9.2978889e-06</Real>
+    <Real>4.5979341e-06</Real>
+    <Real>1.164395e-05</Real>
+    <Real>-1.1824308e-05</Real>
+    <Real>-1.2670253e-05</Real>
+    <Real>-7.1008421e-06</Real>
+    <Real>4.0426371e-06</Real>
+    <Real>9.691882e-06</Real>
+    <Real>3.4888384e-05</Real>
+    <Real>2.3447481e-05</Real>
+    <Real>6.0634087e-05</Real>
+    <Real>4.6600537e-05</Real>
+    <Real>3.8806083e-05</Real>
+    <Real>4.0546623e-05</Real>
+    <Real>5.6960853e-05</Real>
+    <Real>1.7836719e-05</Real>
+    <Real>-8.4526189e-05</Real>
+    <Real>-0.00019142308</Real>
+  </Sequence>
+  <Real Name="Integral">0.54968381075777017</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP1.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP1.xml
new file mode 100644 (file)
index 0000000..f02426b
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>0.47994247</Real>
+    <Real>0.48478529</Real>
+    <Real>0.42015755</Real>
+    <Real>0.43633738</Real>
+    <Real>0.40917483</Real>
+    <Real>0.36798882</Real>
+    <Real>0.33975855</Real>
+    <Real>0.33914748</Real>
+    <Real>0.24553728</Real>
+    <Real>0.23165418</Real>
+    <Real>0.19017372</Real>
+    <Real>0.15800953</Real>
+    <Real>0.12168649</Real>
+    <Real>0.059838008</Real>
+    <Real>0.035983752</Real>
+    <Real>-0.0061296029</Real>
+    <Real>-0.027875844</Real>
+    <Real>-0.091517158</Real>
+    <Real>-0.13541557</Real>
+    <Real>-0.19742206</Real>
+    <Real>-0.22613534</Real>
+    <Real>-0.25163805</Real>
+    <Real>-0.28906253</Real>
+    <Real>-0.34219807</Real>
+    <Real>-0.39520577</Real>
+    <Real>-0.40806535</Real>
+    <Real>-0.38800871</Real>
+    <Real>-0.41812003</Real>
+    <Real>-0.39130437</Real>
+    <Real>-0.47249088</Real>
+    <Real>-0.50039351</Real>
+    <Real>-0.47069913</Real>
+    <Real>-0.44109708</Real>
+    <Real>-0.44801748</Real>
+    <Real>-0.44286934</Real>
+    <Real>-0.40633747</Real>
+    <Real>-0.38159758</Real>
+    <Real>-0.38471025</Real>
+    <Real>-0.28739071</Real>
+    <Real>-0.2954666</Real>
+    <Real>-0.22040513</Real>
+    <Real>-0.20538236</Real>
+    <Real>-0.17562716</Real>
+    <Real>-0.12331922</Real>
+    <Real>-0.10807745</Real>
+    <Real>-0.050659552</Real>
+    <Real>-0.016248262</Real>
+    <Real>0.025591634</Real>
+    <Real>0.048248891</Real>
+    <Real>0.14176746</Real>
+    <Real>0.1492541</Real>
+    <Real>0.19401339</Real>
+    <Real>0.2210024</Real>
+    <Real>0.27532429</Real>
+    <Real>0.30570927</Real>
+    <Real>0.3446942</Real>
+    <Real>0.39302194</Real>
+    <Real>0.42873836</Real>
+    <Real>0.42809039</Real>
+    <Real>0.43389183</Real>
+    <Real>0.45135197</Real>
+    <Real>0.46419406</Real>
+    <Real>0.4460637</Real>
+    <Real>0.45233327</Real>
+    <Real>0.42144969</Real>
+    <Real>0.45315924</Real>
+    <Real>0.39301997</Real>
+    <Real>0.40853813</Real>
+    <Real>0.34201711</Real>
+    <Real>0.3340483</Real>
+    <Real>0.28035039</Real>
+    <Real>0.23896335</Real>
+    <Real>0.28436226</Real>
+    <Real>0.17808978</Real>
+    <Real>0.14499563</Real>
+    <Real>0.06180751</Real>
+    <Real>0.092647187</Real>
+    <Real>0.027190113</Real>
+    <Real>-0.0080625331</Real>
+    <Real>-0.064187385</Real>
+    <Real>-0.10907344</Real>
+    <Real>-0.15446156</Real>
+    <Real>-0.16533569</Real>
+    <Real>-0.23526125</Real>
+    <Real>-0.2398034</Real>
+    <Real>-0.28330675</Real>
+    <Real>-0.30476564</Real>
+    <Real>-0.35689712</Real>
+    <Real>-0.38892877</Real>
+    <Real>-0.3612541</Real>
+    <Real>-0.39185265</Real>
+    <Real>-0.43028882</Real>
+    <Real>-0.45067519</Real>
+    <Real>-0.4342128</Real>
+    <Real>-0.41821808</Real>
+    <Real>-0.4186511</Real>
+    <Real>-0.40667656</Real>
+    <Real>-0.41434187</Real>
+    <Real>-0.40649354</Real>
+    <Real>-0.33379188</Real>
+    <Real>-0.33737326</Real>
+    <Real>-0.29176438</Real>
+    <Real>-0.26665944</Real>
+    <Real>-0.24745244</Real>
+    <Real>-0.20352092</Real>
+    <Real>-0.1578752</Real>
+    <Real>-0.086990885</Real>
+    <Real>-0.066635042</Real>
+    <Real>-0.042743091</Real>
+    <Real>0.00078681594</Real>
+    <Real>-0.0067911739</Real>
+    <Real>0.085896254</Real>
+    <Real>0.071024999</Real>
+    <Real>0.17950583</Real>
+    <Real>0.17651561</Real>
+    <Real>0.20058732</Real>
+    <Real>0.21677521</Real>
+    <Real>0.28812888</Real>
+    <Real>0.33220929</Real>
+    <Real>0.33306259</Real>
+    <Real>0.33927098</Real>
+    <Real>0.37198529</Real>
+    <Real>0.417128</Real>
+    <Real>0.4154191</Real>
+    <Real>0.39847392</Real>
+    <Real>0.44730949</Real>
+    <Real>0.4173483</Real>
+    <Real>0.37803513</Real>
+    <Real>0.37619099</Real>
+    <Real>0.3639302</Real>
+    <Real>0.33892557</Real>
+    <Real>0.32587534</Real>
+    <Real>0.28599876</Real>
+    <Real>0.27454555</Real>
+    <Real>0.24336377</Real>
+    <Real>0.198433</Real>
+    <Real>0.14513154</Real>
+    <Real>0.13489601</Real>
+    <Real>0.062797137</Real>
+    <Real>0.037670311</Real>
+    <Real>0.050498053</Real>
+    <Real>-0.033388019</Real>
+    <Real>-0.030411391</Real>
+    <Real>-0.084634274</Real>
+    <Real>-0.12620553</Real>
+    <Real>-0.15148365</Real>
+    <Real>-0.19281019</Real>
+    <Real>-0.18538459</Real>
+    <Real>-0.24954344</Real>
+    <Real>-0.26109678</Real>
+    <Real>-0.28819132</Real>
+    <Real>-0.29661107</Real>
+    <Real>-0.32724535</Real>
+    <Real>-0.35866067</Real>
+    <Real>-0.37147668</Real>
+    <Real>-0.38001916</Real>
+    <Real>-0.41183418</Real>
+    <Real>-0.39546514</Real>
+    <Real>-0.38687271</Real>
+    <Real>-0.34134433</Real>
+    <Real>-0.34561017</Real>
+    <Real>-0.34194723</Real>
+    <Real>-0.31308424</Real>
+    <Real>-0.27242407</Real>
+    <Real>-0.24386796</Real>
+    <Real>-0.20921478</Real>
+    <Real>-0.21119194</Real>
+    <Real>-0.17974477</Real>
+    <Real>-0.15848035</Real>
+    <Real>-0.12469824</Real>
+    <Real>-0.086453475</Real>
+    <Real>-0.080984168</Real>
+    <Real>0.005651589</Real>
+    <Real>0.003682811</Real>
+    <Real>0.018001949</Real>
+    <Real>0.05915371</Real>
+    <Real>0.12276107</Real>
+    <Real>0.13476479</Real>
+    <Real>0.16121536</Real>
+    <Real>0.2092976</Real>
+    <Real>0.22431286</Real>
+    <Real>0.27541709</Real>
+    <Real>0.24461982</Real>
+    <Real>0.29393646</Real>
+    <Real>0.3234759</Real>
+    <Real>0.31976876</Real>
+    <Real>0.31485754</Real>
+    <Real>0.32111084</Real>
+    <Real>0.35145399</Real>
+    <Real>0.32975963</Real>
+    <Real>0.30248013</Real>
+    <Real>0.33686966</Real>
+    <Real>0.31571227</Real>
+    <Real>0.31266999</Real>
+    <Real>0.25339827</Real>
+    <Real>0.25347894</Real>
+    <Real>0.23968148</Real>
+    <Real>0.18691608</Real>
+    <Real>0.17482249</Real>
+    <Real>0.14749897</Real>
+    <Real>0.12377977</Real>
+    <Real>0.1089068</Real>
+    <Real>0.063197732</Real>
+    <Real>0.026660295</Real>
+    <Real>-0.010755541</Real>
+    <Real>-0.037944749</Real>
+    <Real>-0.037892897</Real>
+    <Real>-0.10014877</Real>
+    <Real>-0.095640317</Real>
+    <Real>-0.13707285</Real>
+    <Real>-0.16875705</Real>
+    <Real>-0.18712473</Real>
+    <Real>-0.19054933</Real>
+    <Real>-0.20765278</Real>
+    <Real>-0.23237705</Real>
+    <Real>-0.25386557</Real>
+    <Real>-0.27768761</Real>
+    <Real>-0.25717878</Real>
+    <Real>-0.28340849</Real>
+    <Real>-0.27809283</Real>
+    <Real>-0.238038</Real>
+    <Real>-0.26776999</Real>
+    <Real>-0.27595633</Real>
+    <Real>-0.25788331</Real>
+    <Real>-0.2742697</Real>
+    <Real>-0.2293901</Real>
+    <Real>-0.25884274</Real>
+    <Real>-0.19792171</Real>
+    <Real>-0.17900355</Real>
+    <Real>-0.15930815</Real>
+    <Real>-0.17125751</Real>
+    <Real>-0.13059393</Real>
+    <Real>-0.10386769</Real>
+    <Real>-0.075353824</Real>
+    <Real>-0.065707266</Real>
+    <Real>-0.018131474</Real>
+    <Real>-0.014584285</Real>
+    <Real>0.0061852229</Real>
+    <Real>0.042538356</Real>
+    <Real>0.050294321</Real>
+    <Real>0.078784354</Real>
+    <Real>0.087153688</Real>
+    <Real>0.12855974</Real>
+    <Real>0.15673861</Real>
+    <Real>0.16491783</Real>
+    <Real>0.18010868</Real>
+    <Real>0.19055982</Real>
+    <Real>0.2284265</Real>
+    <Real>0.23438752</Real>
+    <Real>0.26127139</Real>
+    <Real>0.00051779405</Real>
+    <Real>0.00046002973</Real>
+    <Real>0.00049159979</Real>
+    <Real>0.00046070319</Real>
+    <Real>0.0005150768</Real>
+    <Real>0.00043054938</Real>
+    <Real>0.00045350095</Real>
+    <Real>0.00040957739</Real>
+    <Real>0.00034215208</Real>
+    <Real>0.00035906222</Real>
+    <Real>0.00033953731</Real>
+    <Real>0.00028457298</Real>
+    <Real>0.00030721581</Real>
+    <Real>0.00016524141</Real>
+    <Real>0.00017076859</Real>
+    <Real>0.00012973398</Real>
+    <Real>0.00016397034</Real>
+    <Real>4.7663285e-05</Real>
+    <Real>1.358061e-05</Real>
+    <Real>-2.7169301e-05</Real>
+    <Real>-2.7898577e-06</Real>
+    <Real>-0.00013654496</Real>
+    <Real>-9.7739423e-05</Real>
+    <Real>-0.0001642635</Real>
+    <Real>-0.00019529846</Real>
+    <Real>-0.00024131176</Real>
+    <Real>-0.00029883318</Real>
+    <Real>-0.0003162272</Real>
+    <Real>-0.00032828687</Real>
+    <Real>-0.00038343482</Real>
+    <Real>-0.00040526892</Real>
+    <Real>-0.00039040067</Real>
+    <Real>-0.0004144444</Real>
+    <Real>-0.00033617931</Real>
+    <Real>-0.00042994847</Real>
+    <Real>-0.00042565534</Real>
+    <Real>-0.0004040171</Real>
+    <Real>-0.00035610452</Real>
+    <Real>-0.00031678245</Real>
+    <Real>-0.00029163092</Real>
+    <Real>-0.00032491583</Real>
+    <Real>-0.00024466871</Real>
+    <Real>-0.00026350768</Real>
+    <Real>-0.00022657856</Real>
+    <Real>-0.00023745382</Real>
+    <Real>-0.00017040815</Real>
+    <Real>-0.00015178781</Real>
+    <Real>-0.00013567225</Real>
+    <Real>-0.00012801227</Real>
+    <Real>-5.3487096e-05</Real>
+    <Real>-3.4211818e-05</Real>
+    <Real>-6.9752728e-06</Real>
+    <Real>3.0836691e-05</Real>
+    <Real>5.3444957e-05</Real>
+    <Real>8.0782404e-05</Real>
+    <Real>0.00013846572</Real>
+    <Real>0.00016730832</Real>
+    <Real>0.00019705876</Real>
+    <Real>0.00022988698</Real>
+    <Real>0.00026496977</Real>
+    <Real>0.00027594061</Real>
+    <Real>0.00030931641</Real>
+    <Real>0.00025910389</Real>
+    <Real>0.0002923141</Real>
+    <Real>0.00027058041</Real>
+    <Real>0.00036504987</Real>
+    <Real>0.00032267233</Real>
+    <Real>0.00032371024</Real>
+    <Real>0.00030552977</Real>
+    <Real>0.00027583545</Real>
+    <Real>0.00025386945</Real>
+    <Real>0.00024303515</Real>
+    <Real>0.00026581573</Real>
+    <Real>0.0002071358</Real>
+    <Real>0.00023383345</Real>
+    <Real>0.00017728444</Real>
+    <Real>0.00017414079</Real>
+    <Real>0.00018484636</Real>
+    <Real>0.00018264132</Real>
+    <Real>0.00017436035</Real>
+    <Real>0.00010066917</Real>
+    <Real>6.8966023e-05</Real>
+    <Real>5.8083904e-05</Real>
+    <Real>1.8432511e-05</Real>
+    <Real>-5.5161676e-05</Real>
+    <Real>-7.3635965e-05</Real>
+    <Real>-5.5789766e-05</Real>
+    <Real>-9.8511002e-05</Real>
+    <Real>-0.00016468731</Real>
+    <Real>-0.00016649776</Real>
+    <Real>-0.0001994113</Real>
+    <Real>-0.00021746985</Real>
+    <Real>-0.00025234316</Real>
+    <Real>-0.00026447431</Real>
+    <Real>-0.00023566742</Real>
+    <Real>-0.0002863394</Real>
+    <Real>-0.00027145303</Real>
+    <Real>-0.00027926482</Real>
+    <Real>-0.00031412177</Real>
+    <Real>-0.00025063011</Real>
+    <Real>-0.00026088688</Real>
+    <Real>-0.00022227927</Real>
+    <Real>-0.00019989176</Real>
+    <Real>-0.00019884146</Real>
+    <Real>-0.00015387453</Real>
+    <Real>-0.00015428696</Real>
+    <Real>-0.00014001745</Real>
+    <Real>-0.00013479896</Real>
+    <Real>-0.00013827824</Real>
+    <Real>-0.00010479951</Real>
+    <Real>-9.2000962e-05</Real>
+    <Real>-6.305665e-05</Real>
+    <Real>-8.5287145e-05</Real>
+    <Real>-2.2435448e-05</Real>
+    <Real>-4.9504943e-05</Real>
+    <Real>7.0504911e-06</Real>
+    <Real>-3.8556545e-06</Real>
+    <Real>2.0939458e-05</Real>
+    <Real>4.0444185e-05</Real>
+    <Real>6.2464758e-05</Real>
+    <Real>8.4932581e-05</Real>
+    <Real>0.0001249061</Real>
+    <Real>0.00012059854</Real>
+    <Real>0.00016844175</Real>
+    <Real>0.00010705311</Real>
+    <Real>0.00012287036</Real>
+    <Real>0.00014456037</Real>
+    <Real>0.00010299935</Real>
+    <Real>0.00014447783</Real>
+    <Real>0.00016631189</Real>
+    <Real>0.00011951655</Real>
+    <Real>9.2054914e-05</Real>
+    <Real>7.7397526e-05</Real>
+    <Real>6.8027111e-05</Real>
+    <Real>4.7603451e-05</Real>
+    <Real>4.6011894e-05</Real>
+    <Real>8.9196699e-05</Real>
+    <Real>1.9264202e-05</Real>
+    <Real>5.8760601e-05</Real>
+    <Real>1.4962246e-05</Real>
+    <Real>5.5923185e-05</Real>
+    <Real>3.973005e-05</Real>
+    <Real>5.7783513e-05</Real>
+    <Real>7.4290845e-05</Real>
+    <Real>6.0946517e-05</Real>
+    <Real>3.0873391e-05</Real>
+    <Real>5.5158758e-05</Real>
+    <Real>3.5803965e-05</Real>
+    <Real>-2.1067415e-05</Real>
+    <Real>3.8682715e-06</Real>
+    <Real>-2.0667258e-06</Real>
+    <Real>-1.2632422e-05</Real>
+    <Real>-4.2208379e-05</Real>
+    <Real>-9.5042917e-05</Real>
+    <Real>-0.00010922949</Real>
+    <Real>-0.00013174933</Real>
+    <Real>-0.00014768293</Real>
+    <Real>-0.00012974846</Real>
+    <Real>-0.00013042323</Real>
+    <Real>-9.965428e-05</Real>
+    <Real>-8.2405808e-05</Real>
+    <Real>-9.2953065e-05</Real>
+    <Real>-7.6099925e-05</Real>
+    <Real>-6.2735577e-05</Real>
+    <Real>-7.770439e-05</Real>
+    <Real>-2.9663626e-05</Real>
+    <Real>-5.4733122e-05</Real>
+    <Real>-4.6981109e-05</Real>
+    <Real>1.8356723e-05</Real>
+    <Real>-4.4312477e-05</Real>
+    <Real>-2.5209471e-05</Real>
+    <Real>-6.2572442e-05</Real>
+    <Real>-2.3840879e-05</Real>
+    <Real>-6.1076091e-05</Real>
+    <Real>-9.3741124e-05</Real>
+    <Real>-7.945695e-05</Real>
+    <Real>-0.00011390245</Real>
+    <Real>-0.00013043737</Real>
+    <Real>-0.00012991235</Real>
+    <Real>-6.5812135e-05</Real>
+    <Real>-3.477887e-05</Real>
+    <Real>-2.9716135e-05</Real>
+    <Real>-7.4908535e-06</Real>
+    <Real>2.3869186e-05</Real>
+    <Real>4.6370671e-05</Real>
+    <Real>7.6261058e-05</Real>
+    <Real>7.8259094e-05</Real>
+    <Real>6.4048887e-05</Real>
+    <Real>7.6222859e-05</Real>
+    <Real>8.3034451e-05</Real>
+    <Real>6.315564e-05</Real>
+    <Real>6.9539514e-05</Real>
+    <Real>4.724467e-05</Real>
+    <Real>7.0027898e-05</Real>
+    <Real>7.6666351e-05</Real>
+    <Real>8.6733067e-05</Real>
+    <Real>8.0106831e-05</Real>
+    <Real>0.00010918936</Real>
+    <Real>0.00014464188</Real>
+    <Real>0.00017181516</Real>
+    <Real>0.0002254135</Real>
+    <Real>0.00024767048</Real>
+    <Real>0.00026707022</Real>
+    <Real>0.00019277025</Real>
+    <Real>0.00023908055</Real>
+    <Real>0.00024568432</Real>
+    <Real>0.00023091928</Real>
+    <Real>0.00029483382</Real>
+    <Real>0.00025279995</Real>
+    <Real>0.00024932221</Real>
+    <Real>0.00016185141</Real>
+    <Real>0.00012187717</Real>
+    <Real>8.6983739e-05</Real>
+    <Real>9.7002376e-05</Real>
+    <Real>1.2475208e-05</Real>
+    <Real>-6.0953054e-05</Real>
+    <Real>-0.00012379354</Real>
+    <Real>-0.00016237446</Real>
+    <Real>-0.00012646648</Real>
+    <Real>-0.00010655529</Real>
+    <Real>-6.7753019e-05</Real>
+    <Real>-7.6096891e-05</Real>
+    <Real>-6.1317194e-05</Real>
+    <Real>4.2310683e-05</Real>
+    <Real>7.8446574e-05</Real>
+    <Real>0.00011693679</Real>
+    <Real>0.00011118068</Real>
+    <Real>0.00019630734</Real>
+    <Real>0.00013006449</Real>
+    <Real>0.00020328228</Real>
+    <Real>9.4708485e-05</Real>
+    <Real>2.4244946e-05</Real>
+    <Real>2.0031335e-05</Real>
+    <Real>8.7780099e-06</Real>
+    <Real>8.5161257e-05</Real>
+    <Real>-3.2001142e-05</Real>
+    <Real>5.0963968e-06</Real>
+    <Real>5.9037811e-05</Real>
+    <Real>0.00016131309</Real>
+    <Real>0.00018575686</Real>
+    <Real>0.00038959685</Real>
+    <Real>0.00030655556</Real>
+    <Real>0.00055750855</Real>
+    <Real>0.00041609086</Real>
+    <Real>0.00041038837</Real>
+    <Real>0.00024904971</Real>
+    <Real>0.00032858923</Real>
+    <Real>-0.00012124365</Real>
+    <Real>-0.00067634159</Real>
+    <Real>-0.0014037765</Real>
+  </Sequence>
+  <Real Name="Integral">-0.13156737015469844</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP2.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP2.xml
new file mode 100644 (file)
index 0000000..e61b5e3
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>1.0026263</Real>
+    <Real>1.002813</Real>
+    <Real>1.0028353</Real>
+    <Real>1.00298</Real>
+    <Real>1.0031264</Real>
+    <Real>1.0033009</Real>
+    <Real>1.0034248</Real>
+    <Real>1.0034949</Real>
+    <Real>1.0036868</Real>
+    <Real>1.0038811</Real>
+    <Real>1.0039461</Real>
+    <Real>1.0039393</Real>
+    <Real>1.0039014</Real>
+    <Real>1.0041367</Real>
+    <Real>1.0040401</Real>
+    <Real>1.0039788</Real>
+    <Real>1.0041522</Real>
+    <Real>1.004038</Real>
+    <Real>1.00398</Real>
+    <Real>1.0038664</Real>
+    <Real>1.0038596</Real>
+    <Real>1.00374</Real>
+    <Real>1.0035481</Real>
+    <Real>1.0035183</Real>
+    <Real>1.003296</Real>
+    <Real>1.0031067</Real>
+    <Real>1.0031048</Real>
+    <Real>1.0029247</Real>
+    <Real>1.0029281</Real>
+    <Real>1.0027844</Real>
+    <Real>1.0024828</Real>
+    <Real>1.0026224</Real>
+    <Real>1.0028158</Real>
+    <Real>1.0028605</Real>
+    <Real>1.0029123</Real>
+    <Real>1.0031923</Real>
+    <Real>1.0032749</Real>
+    <Real>1.0033575</Real>
+    <Real>1.0034987</Real>
+    <Real>1.0035222</Real>
+    <Real>1.0038122</Real>
+    <Real>1.0038934</Real>
+    <Real>1.0038835</Real>
+    <Real>1.003985</Real>
+    <Real>1.0040591</Real>
+    <Real>1.0040226</Real>
+    <Real>1.004043</Real>
+    <Real>1.0039675</Real>
+    <Real>1.0040811</Real>
+    <Real>1.0039179</Real>
+    <Real>1.003891</Real>
+    <Real>1.0038245</Real>
+    <Real>1.0036744</Real>
+    <Real>1.0038064</Real>
+    <Real>1.0035872</Real>
+    <Real>1.003276</Real>
+    <Real>1.0033685</Real>
+    <Real>1.0032185</Real>
+    <Real>1.0030403</Real>
+    <Real>1.0028248</Real>
+    <Real>1.0028371</Real>
+    <Real>1.0028143</Real>
+    <Real>1.00263</Real>
+    <Real>1.002896</Real>
+    <Real>1.0029092</Real>
+    <Real>1.0029544</Real>
+    <Real>1.0030841</Real>
+    <Real>1.0033208</Real>
+    <Real>1.0033398</Real>
+    <Real>1.0034574</Real>
+    <Real>1.003602</Real>
+    <Real>1.0037988</Real>
+    <Real>1.0038297</Real>
+    <Real>1.0040625</Real>
+    <Real>1.0039389</Real>
+    <Real>1.0040179</Real>
+    <Real>1.0039594</Real>
+    <Real>1.0039961</Real>
+    <Real>1.0039948</Real>
+    <Real>1.0040424</Real>
+    <Real>1.0039783</Real>
+    <Real>1.0039077</Real>
+    <Real>1.003881</Real>
+    <Real>1.003885</Real>
+    <Real>1.0038402</Real>
+    <Real>1.0036588</Real>
+    <Real>1.0035746</Real>
+    <Real>1.0034667</Real>
+    <Real>1.0033582</Real>
+    <Real>1.0032606</Real>
+    <Real>1.0031298</Real>
+    <Real>1.0029531</Real>
+    <Real>1.0029762</Real>
+    <Real>1.0028747</Real>
+    <Real>1.0028256</Real>
+    <Real>1.0029508</Real>
+    <Real>1.0031258</Real>
+    <Real>1.0032694</Real>
+    <Real>1.0033274</Real>
+    <Real>1.0034236</Real>
+    <Real>1.0035467</Real>
+    <Real>1.0037386</Real>
+    <Real>1.0037678</Real>
+    <Real>1.0038179</Real>
+    <Real>1.003939</Real>
+    <Real>1.003979</Real>
+    <Real>1.00396</Real>
+    <Real>1.0039968</Real>
+    <Real>1.0040765</Real>
+    <Real>1.0039867</Real>
+    <Real>1.0040717</Real>
+    <Real>1.0039583</Real>
+    <Real>1.0038927</Real>
+    <Real>1.0039638</Real>
+    <Real>1.0038794</Real>
+    <Real>1.003749</Real>
+    <Real>1.0036877</Real>
+    <Real>1.0035897</Real>
+    <Real>1.0034268</Real>
+    <Real>1.0034192</Real>
+    <Real>1.0032343</Real>
+    <Real>1.0033185</Real>
+    <Real>1.0029762</Real>
+    <Real>1.0031357</Real>
+    <Real>1.003207</Real>
+    <Real>1.0029137</Real>
+    <Real>1.0030683</Real>
+    <Real>1.0031815</Real>
+    <Real>1.0033453</Real>
+    <Real>1.0033225</Real>
+    <Real>1.0034435</Real>
+    <Real>1.0035906</Real>
+    <Real>1.0036092</Real>
+    <Real>1.0037911</Real>
+    <Real>1.0038091</Real>
+    <Real>1.0039287</Real>
+    <Real>1.0040594</Real>
+    <Real>1.003963</Real>
+    <Real>1.0039438</Real>
+    <Real>1.004236</Real>
+    <Real>1.0041121</Real>
+    <Real>1.0039667</Real>
+    <Real>1.0039054</Real>
+    <Real>1.0039448</Real>
+    <Real>1.0038875</Real>
+    <Real>1.0039566</Real>
+    <Real>1.0037364</Real>
+    <Real>1.0038453</Real>
+    <Real>1.0036628</Real>
+    <Real>1.0036311</Real>
+    <Real>1.0035908</Real>
+    <Real>1.0035497</Real>
+    <Real>1.0035697</Real>
+    <Real>1.0033984</Real>
+    <Real>1.0034442</Real>
+    <Real>1.0033016</Real>
+    <Real>1.0032938</Real>
+    <Real>1.0032138</Real>
+    <Real>1.0033556</Real>
+    <Real>1.0033462</Real>
+    <Real>1.0034832</Real>
+    <Real>1.0035497</Real>
+    <Real>1.0036097</Real>
+    <Real>1.003722</Real>
+    <Real>1.003818</Real>
+    <Real>1.0037833</Real>
+    <Real>1.0038013</Real>
+    <Real>1.0039788</Real>
+    <Real>1.0039507</Real>
+    <Real>1.0040078</Real>
+    <Real>1.0040756</Real>
+    <Real>1.0040264</Real>
+    <Real>1.0038471</Real>
+    <Real>1.0039368</Real>
+    <Real>1.0040127</Real>
+    <Real>1.0038276</Real>
+    <Real>1.0038612</Real>
+    <Real>1.0038606</Real>
+    <Real>1.0038905</Real>
+    <Real>1.0039259</Real>
+    <Real>1.0036864</Real>
+    <Real>1.0036433</Real>
+    <Real>1.0036565</Real>
+    <Real>1.0036999</Real>
+    <Real>1.003649</Real>
+    <Real>1.0035149</Real>
+    <Real>1.0035567</Real>
+    <Real>1.0035112</Real>
+    <Real>1.003474</Real>
+    <Real>1.0034895</Real>
+    <Real>1.003518</Real>
+    <Real>1.0036062</Real>
+    <Real>1.0036708</Real>
+    <Real>1.0038066</Real>
+    <Real>1.0037796</Real>
+    <Real>1.0038444</Real>
+    <Real>1.0038437</Real>
+    <Real>1.0038533</Real>
+    <Real>1.0040073</Real>
+    <Real>1.0039427</Real>
+    <Real>1.0040594</Real>
+    <Real>1.0040133</Real>
+    <Real>1.0039896</Real>
+    <Real>1.0041509</Real>
+    <Real>1.0040509</Real>
+    <Real>1.0040835</Real>
+    <Real>1.0039433</Real>
+    <Real>1.0039626</Real>
+    <Real>1.0039417</Real>
+    <Real>1.0039464</Real>
+    <Real>1.0039327</Real>
+    <Real>1.0038795</Real>
+    <Real>1.0038284</Real>
+    <Real>1.0037864</Real>
+    <Real>1.0037988</Real>
+    <Real>1.0038092</Real>
+    <Real>1.0038675</Real>
+    <Real>1.0038058</Real>
+    <Real>1.0036768</Real>
+    <Real>1.0036308</Real>
+    <Real>1.0037299</Real>
+    <Real>1.003732</Real>
+    <Real>1.0038123</Real>
+    <Real>1.0038664</Real>
+    <Real>1.0037434</Real>
+    <Real>1.0037843</Real>
+    <Real>1.0037801</Real>
+    <Real>1.0039681</Real>
+    <Real>1.003965</Real>
+    <Real>1.0039586</Real>
+    <Real>1.0040132</Real>
+    <Real>1.0040785</Real>
+    <Real>1.004027</Real>
+    <Real>1.0039933</Real>
+    <Real>1.0040841</Real>
+    <Real>1.0040706</Real>
+    <Real>1.0040671</Real>
+    <Real>1.0040392</Real>
+    <Real>1.003906</Real>
+    <Real>1.0039387</Real>
+    <Real>1.0039802</Real>
+    <Real>1.0039933</Real>
+    <Real>1.0039399</Real>
+    <Real>1.0039351</Real>
+    <Real>1.0039452</Real>
+    <Real>1.0038861</Real>
+    <Real>1.0039293</Real>
+    <Real>1.0039737</Real>
+    <Real>1.0039887</Real>
+    <Real>1.0038258</Real>
+    <Real>-0.49893174</Real>
+    <Real>-0.49886957</Real>
+    <Real>-0.49892607</Real>
+    <Real>-0.49890354</Real>
+    <Real>-0.49890825</Real>
+    <Real>-0.49895376</Real>
+    <Real>-0.49898374</Real>
+    <Real>-0.4989509</Real>
+    <Real>-0.49897298</Real>
+    <Real>-0.49903247</Real>
+    <Real>-0.49904075</Real>
+    <Real>-0.49909836</Real>
+    <Real>-0.49908444</Real>
+    <Real>-0.49908859</Real>
+    <Real>-0.49905875</Real>
+    <Real>-0.49902666</Real>
+    <Real>-0.49906376</Real>
+    <Real>-0.49897763</Real>
+    <Real>-0.49900699</Real>
+    <Real>-0.49899176</Real>
+    <Real>-0.49896324</Real>
+    <Real>-0.4990257</Real>
+    <Real>-0.49898669</Real>
+    <Real>-0.49898905</Real>
+    <Real>-0.4989301</Real>
+    <Real>-0.49899307</Real>
+    <Real>-0.4989734</Real>
+    <Real>-0.49900821</Real>
+    <Real>-0.49903369</Real>
+    <Real>-0.49896592</Real>
+    <Real>-0.49899274</Real>
+    <Real>-0.49897274</Real>
+    <Real>-0.49891421</Real>
+    <Real>-0.49898604</Real>
+    <Real>-0.49893531</Real>
+    <Real>-0.49889025</Real>
+    <Real>-0.49898291</Real>
+    <Real>-0.49900803</Real>
+    <Real>-0.4990274</Real>
+    <Real>-0.49901819</Real>
+    <Real>-0.49902931</Real>
+    <Real>-0.49899384</Real>
+    <Real>-0.49903008</Real>
+    <Real>-0.49902987</Real>
+    <Real>-0.49906373</Real>
+    <Real>-0.49897286</Real>
+    <Real>-0.49903256</Real>
+    <Real>-0.4990426</Real>
+    <Real>-0.49899024</Real>
+    <Real>-0.49900568</Real>
+    <Real>-0.49897072</Real>
+    <Real>-0.49898463</Real>
+    <Real>-0.49899572</Real>
+    <Real>-0.49897897</Real>
+    <Real>-0.49897388</Real>
+    <Real>-0.498952</Real>
+    <Real>-0.49896869</Real>
+    <Real>-0.49902186</Real>
+    <Real>-0.49899849</Real>
+    <Real>-0.49902734</Real>
+    <Real>-0.49899837</Real>
+    <Real>-0.49893278</Real>
+    <Real>-0.49898127</Real>
+    <Real>-0.4989706</Real>
+    <Real>-0.49897298</Real>
+    <Real>-0.49895722</Real>
+    <Real>-0.49895576</Real>
+    <Real>-0.49900338</Real>
+    <Real>-0.49902055</Real>
+    <Real>-0.49900922</Real>
+    <Real>-0.49902984</Real>
+    <Real>-0.49903873</Real>
+    <Real>-0.49901998</Real>
+    <Real>-0.49906427</Real>
+    <Real>-0.49905005</Real>
+    <Real>-0.49904937</Real>
+    <Real>-0.49903309</Real>
+    <Real>-0.49906269</Real>
+    <Real>-0.49902761</Real>
+    <Real>-0.4989495</Real>
+    <Real>-0.49903408</Real>
+    <Real>-0.49898002</Real>
+    <Real>-0.49901122</Real>
+    <Real>-0.49896607</Real>
+    <Real>-0.49895996</Real>
+    <Real>-0.49893692</Real>
+    <Real>-0.49901545</Real>
+    <Real>-0.49897414</Real>
+    <Real>-0.49899518</Real>
+    <Real>-0.49900544</Real>
+    <Real>-0.49900562</Real>
+    <Real>-0.49902061</Real>
+    <Real>-0.49900696</Real>
+    <Real>-0.49901411</Real>
+    <Real>-0.49897903</Real>
+    <Real>-0.49896753</Real>
+    <Real>-0.49898955</Real>
+    <Real>-0.49894136</Real>
+    <Real>-0.49890041</Real>
+    <Real>-0.49896589</Real>
+    <Real>-0.49905798</Real>
+    <Real>-0.49901095</Real>
+    <Real>-0.49903458</Real>
+    <Real>-0.49901229</Real>
+    <Real>-0.49897078</Real>
+    <Real>-0.49899077</Real>
+    <Real>-0.49903148</Real>
+    <Real>-0.49900115</Real>
+    <Real>-0.49903333</Real>
+    <Real>-0.49893701</Real>
+    <Real>-0.49894023</Real>
+    <Real>-0.49889353</Real>
+    <Real>-0.49892846</Real>
+    <Real>-0.49893394</Real>
+    <Real>-0.49893048</Real>
+    <Real>-0.49895993</Real>
+    <Real>-0.49895453</Real>
+    <Real>-0.49897233</Real>
+    <Real>-0.49901488</Real>
+    <Real>-0.49897596</Real>
+    <Real>-0.49901453</Real>
+    <Real>-0.49898061</Real>
+    <Real>-0.49898961</Real>
+    <Real>-0.49896201</Real>
+    <Real>-0.49900386</Real>
+    <Real>-0.49896801</Real>
+    <Real>-0.49894783</Real>
+    <Real>-0.49898973</Real>
+    <Real>-0.49900243</Real>
+    <Real>-0.49898016</Real>
+    <Real>-0.4990072</Real>
+    <Real>-0.49901175</Real>
+    <Real>-0.49905095</Real>
+    <Real>-0.49902296</Real>
+    <Real>-0.49905404</Real>
+    <Real>-0.49907574</Real>
+    <Real>-0.49903113</Real>
+    <Real>-0.49899417</Real>
+    <Real>-0.49898854</Real>
+    <Real>-0.49898151</Real>
+    <Real>-0.49896878</Real>
+    <Real>-0.4989523</Real>
+    <Real>-0.49892372</Real>
+    <Real>-0.49893865</Real>
+    <Real>-0.49890816</Real>
+    <Real>-0.49890837</Real>
+    <Real>-0.49892312</Real>
+    <Real>-0.49893406</Real>
+    <Real>-0.49898854</Real>
+    <Real>-0.49900332</Real>
+    <Real>-0.49896649</Real>
+    <Real>-0.49897844</Real>
+    <Real>-0.49897742</Real>
+    <Real>-0.49898747</Real>
+    <Real>-0.49901125</Real>
+    <Real>-0.49901617</Real>
+    <Real>-0.49903822</Real>
+    <Real>-0.49900663</Real>
+    <Real>-0.49901626</Real>
+    <Real>-0.49898303</Real>
+    <Real>-0.49894875</Real>
+    <Real>-0.49897355</Real>
+    <Real>-0.49900821</Real>
+    <Real>-0.49900267</Real>
+    <Real>-0.49894786</Real>
+    <Real>-0.49896383</Real>
+    <Real>-0.49899969</Real>
+    <Real>-0.49897408</Real>
+    <Real>-0.49899754</Real>
+    <Real>-0.49899074</Real>
+    <Real>-0.4989655</Real>
+    <Real>-0.4989244</Real>
+    <Real>-0.49888101</Real>
+    <Real>-0.4989126</Real>
+    <Real>-0.49887562</Real>
+    <Real>-0.49887267</Real>
+    <Real>-0.4989208</Real>
+    <Real>-0.49892566</Real>
+    <Real>-0.49888468</Real>
+    <Real>-0.49895188</Real>
+    <Real>-0.49898317</Real>
+    <Real>-0.49898994</Real>
+    <Real>-0.499053</Real>
+    <Real>-0.49904776</Real>
+    <Real>-0.49901441</Real>
+    <Real>-0.49905989</Real>
+    <Real>-0.49906784</Real>
+    <Real>-0.49904436</Real>
+    <Real>-0.49905097</Real>
+    <Real>-0.49906713</Real>
+    <Real>-0.49905431</Real>
+    <Real>-0.49900526</Real>
+    <Real>-0.49893859</Real>
+    <Real>-0.49897069</Real>
+    <Real>-0.49897757</Real>
+    <Real>-0.49898547</Real>
+    <Real>-0.4989692</Real>
+    <Real>-0.49900842</Real>
+    <Real>-0.49897486</Real>
+    <Real>-0.49885672</Real>
+    <Real>-0.49891347</Real>
+    <Real>-0.49889705</Real>
+    <Real>-0.49882984</Real>
+    <Real>-0.49888229</Real>
+    <Real>-0.49882868</Real>
+    <Real>-0.49875924</Real>
+    <Real>-0.49873927</Real>
+    <Real>-0.49876097</Real>
+    <Real>-0.49878752</Real>
+    <Real>-0.4987694</Real>
+    <Real>-0.49884218</Real>
+    <Real>-0.49889925</Real>
+    <Real>-0.49895036</Real>
+    <Real>-0.4989852</Real>
+    <Real>-0.49903667</Real>
+    <Real>-0.49907553</Real>
+    <Real>-0.49912426</Real>
+    <Real>-0.49908084</Real>
+    <Real>-0.49905947</Real>
+    <Real>-0.49900791</Real>
+    <Real>-0.49891245</Real>
+    <Real>-0.49886835</Real>
+    <Real>-0.49882156</Real>
+    <Real>-0.49881804</Real>
+    <Real>-0.49885982</Real>
+    <Real>-0.4988803</Real>
+    <Real>-0.49897206</Real>
+    <Real>-0.49903926</Real>
+    <Real>-0.49898836</Real>
+    <Real>-0.49902949</Real>
+    <Real>-0.49892426</Real>
+    <Real>-0.49893805</Real>
+    <Real>-0.49871096</Real>
+    <Real>-0.49875355</Real>
+    <Real>-0.49870211</Real>
+    <Real>-0.49881226</Real>
+    <Real>-0.49883336</Real>
+    <Real>-0.49881047</Real>
+    <Real>-0.4987531</Real>
+    <Real>-0.49864075</Real>
+    <Real>-0.49877453</Real>
+    <Real>-0.49885714</Real>
+    <Real>-0.49892786</Real>
+    <Real>-0.49911681</Real>
+    <Real>-0.49893573</Real>
+    <Real>-0.49896306</Real>
+    <Real>-0.49876678</Real>
+    <Real>-0.4990873</Real>
+    <Real>-0.49923372</Real>
+    <Real>-0.49851903</Real>
+  </Sequence>
+  <Real Name="Integral">127.17098122835159</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP3.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP3.xml
new file mode 100644 (file)
index 0000000..ff8df50
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>0.24916932</Real>
+    <Real>0.26282433</Real>
+    <Real>0.21642341</Real>
+    <Real>0.15372278</Real>
+    <Real>0.11979742</Real>
+    <Real>0.092738658</Real>
+    <Real>0.050859306</Real>
+    <Real>0.074621499</Real>
+    <Real>0.037549708</Real>
+    <Real>0.022125257</Real>
+    <Real>0.01304414</Real>
+    <Real>0.0044885995</Real>
+    <Real>0.033661574</Real>
+    <Real>0.021974018</Real>
+    <Real>0.003042046</Real>
+    <Real>0.02771442</Real>
+    <Real>-0.024294494</Real>
+    <Real>-0.0089511611</Real>
+    <Real>-0.01425425</Real>
+    <Real>-0.018068291</Real>
+    <Real>-0.032646321</Real>
+    <Real>-0.020490842</Real>
+    <Real>-0.029507939</Real>
+    <Real>-0.053334761</Real>
+    <Real>-0.081523851</Real>
+    <Real>-0.11181895</Real>
+    <Real>-0.11998858</Real>
+    <Real>-0.19702718</Real>
+    <Real>-0.23862125</Real>
+    <Real>-0.23100108</Real>
+    <Real>-0.28396863</Real>
+    <Real>-0.25871417</Real>
+    <Real>-0.25871655</Real>
+    <Real>-0.23469536</Real>
+    <Real>-0.16978902</Real>
+    <Real>-0.11634055</Real>
+    <Real>-0.088878788</Real>
+    <Real>-0.090839922</Real>
+    <Real>-0.042584907</Real>
+    <Real>-0.049209379</Real>
+    <Real>-0.044580866</Real>
+    <Real>-0.061672501</Real>
+    <Real>-0.036852069</Real>
+    <Real>-0.060182665</Real>
+    <Real>-0.037425138</Real>
+    <Real>-0.023032969</Real>
+    <Real>-0.008587338</Real>
+    <Real>-0.0097123208</Real>
+    <Real>0.0093123093</Real>
+    <Real>0.0089723812</Real>
+    <Real>0.015222463</Real>
+    <Real>0.017061882</Real>
+    <Real>0.026156943</Real>
+    <Real>0.025765847</Real>
+    <Real>0.054910339</Real>
+    <Real>0.10248004</Real>
+    <Real>0.08782912</Real>
+    <Real>0.10213599</Real>
+    <Real>0.15908866</Real>
+    <Real>0.16958259</Real>
+    <Real>0.21099328</Real>
+    <Real>0.25954089</Real>
+    <Real>0.24664715</Real>
+    <Real>0.21735786</Real>
+    <Real>0.20271333</Real>
+    <Real>0.14929497</Real>
+    <Real>0.099971056</Real>
+    <Real>0.078323275</Real>
+    <Real>0.086109914</Real>
+    <Real>0.088238128</Real>
+    <Real>0.033936426</Real>
+    <Real>0.060482882</Real>
+    <Real>0.024708128</Real>
+    <Real>0.014221126</Real>
+    <Real>0.017057929</Real>
+    <Real>0.023793744</Real>
+    <Real>0.020157645</Real>
+    <Real>0.028095469</Real>
+    <Real>-0.0011269932</Real>
+    <Real>-0.0087106731</Real>
+    <Real>-0.015682038</Real>
+    <Real>-0.031383019</Real>
+    <Real>-0.040354021</Real>
+    <Real>-0.022688888</Real>
+    <Real>-0.029115962</Real>
+    <Real>-0.044007879</Real>
+    <Real>-0.047760032</Real>
+    <Real>-0.075893126</Real>
+    <Real>-0.081340298</Real>
+    <Real>-0.12698907</Real>
+    <Real>-0.12668371</Real>
+    <Real>-0.16949433</Real>
+    <Real>-0.17001522</Real>
+    <Real>-0.21445785</Real>
+    <Real>-0.19745404</Real>
+    <Real>-0.14944276</Real>
+    <Real>-0.15087374</Real>
+    <Real>-0.11744924</Real>
+    <Real>-0.095149398</Real>
+    <Real>-0.06332425</Real>
+    <Real>-0.036039084</Real>
+    <Real>-0.0081931204</Real>
+    <Real>-0.032258861</Real>
+    <Real>-0.051029101</Real>
+    <Real>-0.010478755</Real>
+    <Real>-0.046378605</Real>
+    <Real>-0.012759867</Real>
+    <Real>-0.045964837</Real>
+    <Real>-0.012755739</Real>
+    <Real>-0.0030502961</Real>
+    <Real>0.012351047</Real>
+    <Real>-0.0011214457</Real>
+    <Real>0.0090411613</Real>
+    <Real>0.032239337</Real>
+    <Real>0.03779193</Real>
+    <Real>0.023959428</Real>
+    <Real>0.024747973</Real>
+    <Real>0.024610961</Real>
+    <Real>0.061804209</Real>
+    <Real>0.062422201</Real>
+    <Real>0.073981203</Real>
+    <Real>0.11293139</Real>
+    <Real>0.13641046</Real>
+    <Real>0.14514221</Real>
+    <Real>0.1661052</Real>
+    <Real>0.16901226</Real>
+    <Real>0.13682093</Real>
+    <Real>0.14968935</Real>
+    <Real>0.096671052</Real>
+    <Real>0.091609098</Real>
+    <Real>0.038700294</Real>
+    <Real>0.050378289</Real>
+    <Real>0.0071525229</Real>
+    <Real>0.026320271</Real>
+    <Real>0.004891546</Real>
+    <Real>-0.0075392947</Real>
+    <Real>0.039158821</Real>
+    <Real>0.022921503</Real>
+    <Real>0.030754266</Real>
+    <Real>0.022782188</Real>
+    <Real>0.009197413</Real>
+    <Real>0.011712298</Real>
+    <Real>0.00042203636</Real>
+    <Real>0.0034940925</Real>
+    <Real>-0.034436598</Real>
+    <Real>-0.032315563</Real>
+    <Real>-0.016871653</Real>
+    <Real>-0.035277113</Real>
+    <Real>0.0017015081</Real>
+    <Real>0.0049509918</Real>
+    <Real>-0.057147924</Real>
+    <Real>-0.064407878</Real>
+    <Real>-0.045245171</Real>
+    <Real>-0.089002214</Real>
+    <Real>-0.071642399</Real>
+    <Real>-0.11470717</Real>
+    <Real>-0.11126412</Real>
+    <Real>-0.090277366</Real>
+    <Real>-0.094315536</Real>
+    <Real>-0.079579718</Real>
+    <Real>-0.047357906</Real>
+    <Real>-0.024927292</Real>
+    <Real>-0.034104288</Real>
+    <Real>-0.0096314782</Real>
+    <Real>-0.01172656</Real>
+    <Real>-0.0056364429</Real>
+    <Real>-0.040535823</Real>
+    <Real>-0.016774358</Real>
+    <Real>-0.014503113</Real>
+    <Real>-0.039290171</Real>
+    <Real>-0.014833414</Real>
+    <Real>-0.013736404</Real>
+    <Real>-0.012063603</Real>
+    <Real>-0.028713237</Real>
+    <Real>-0.015571943</Real>
+    <Real>0.0072697252</Real>
+    <Real>0.014094685</Real>
+    <Real>0.032336745</Real>
+    <Real>0.026830338</Real>
+    <Real>0.0048128823</Real>
+    <Real>-0.012038751</Real>
+    <Real>0.016595189</Real>
+    <Real>0.023860943</Real>
+    <Real>0.039478075</Real>
+    <Real>0.050808214</Real>
+    <Real>0.072448984</Real>
+    <Real>0.03044604</Real>
+    <Real>0.049967185</Real>
+    <Real>0.048776053</Real>
+    <Real>0.01749002</Real>
+    <Real>0.045520712</Real>
+    <Real>0.021682752</Real>
+    <Real>0.030495429</Real>
+    <Real>-0.009275022</Real>
+    <Real>0.0020285225</Real>
+    <Real>-0.0010389222</Real>
+    <Real>0.030749684</Real>
+    <Real>0.030424479</Real>
+    <Real>0.017310664</Real>
+    <Real>0.021767529</Real>
+    <Real>0.01571149</Real>
+    <Real>0.029586872</Real>
+    <Real>0.013801512</Real>
+    <Real>0.04165978</Real>
+    <Real>-0.0018744577</Real>
+    <Real>0.01699499</Real>
+    <Real>-0.0014720967</Real>
+    <Real>0.0059610172</Real>
+    <Real>-0.0066657215</Real>
+    <Real>-0.0048435708</Real>
+    <Real>-0.014292663</Real>
+    <Real>0.024748452</Real>
+    <Real>0.0096782139</Real>
+    <Real>0.0025369956</Real>
+    <Real>-0.020823359</Real>
+    <Real>0.017876782</Real>
+    <Real>-0.015183195</Real>
+    <Real>-0.015656698</Real>
+    <Real>-0.0028440207</Real>
+    <Real>0.014280689</Real>
+    <Real>-0.026562925</Real>
+    <Real>-0.014578264</Real>
+    <Real>-0.03152569</Real>
+    <Real>-0.0090835607</Real>
+    <Real>0.01867128</Real>
+    <Real>-0.024373746</Real>
+    <Real>0.02396073</Real>
+    <Real>0.023200441</Real>
+    <Real>0.017668812</Real>
+    <Real>-0.0162716</Real>
+    <Real>-0.0095616225</Real>
+    <Real>-0.0094661694</Real>
+    <Real>-0.006648181</Real>
+    <Real>0.009075908</Real>
+    <Real>0.0092385337</Real>
+    <Real>0.0098444149</Real>
+    <Real>-0.01935043</Real>
+    <Real>-0.0044980175</Real>
+    <Real>-0.024686264</Real>
+    <Real>0.00012611978</Real>
+    <Real>-0.0078650564</Real>
+    <Real>-0.025699897</Real>
+    <Real>-0.019722866</Real>
+    <Real>-0.003895215</Real>
+    <Real>-0.015588136</Real>
+    <Real>-0.014491427</Real>
+    <Real>-0.016194995</Real>
+    <Real>-0.0062554618</Real>
+    <Real>-0.010720518</Real>
+    <Real>0.0040345192</Real>
+    <Real>-0.294002</Real>
+    <Real>-0.177398</Real>
+    <Real>-0.39839</Real>
+    <Real>-0.48773</Real>
+    <Real>-0.172094</Real>
+    <Real>-0.41209301</Real>
+    <Real>-0.408075</Real>
+    <Real>-0.30323401</Real>
+    <Real>-0.31504101</Real>
+    <Real>-0.36764601</Real>
+    <Real>-0.22680099</Real>
+    <Real>-0.362151</Real>
+    <Real>-0.37852699</Real>
+    <Real>-0.41337499</Real>
+    <Real>-0.42870599</Real>
+    <Real>-0.370096</Real>
+    <Real>-0.39703399</Real>
+    <Real>-0.43473601</Real>
+    <Real>-0.35783899</Real>
+    <Real>-0.31582201</Real>
+    <Real>-0.398561</Real>
+    <Real>-0.209665</Real>
+    <Real>-0.403451</Real>
+    <Real>-0.45481399</Real>
+    <Real>-0.29749301</Real>
+    <Real>-0.32480201</Real>
+    <Real>-0.386527</Real>
+    <Real>-0.19479001</Real>
+    <Real>-0.36277401</Real>
+    <Real>-0.33375701</Real>
+    <Real>-0.28211099</Real>
+    <Real>-0.394546</Real>
+    <Real>-0.406385</Real>
+    <Real>-0.114484</Real>
+    <Real>-0.42001301</Real>
+    <Real>-0.403752</Real>
+    <Real>-0.20651101</Real>
+    <Real>-0.30948099</Real>
+    <Real>-0.34128401</Real>
+    <Real>-0.120096</Real>
+    <Real>-0.45341599</Real>
+    <Real>-0.31077701</Real>
+    <Real>-0.119248</Real>
+    <Real>-0.43382999</Real>
+    <Real>-0.175929</Real>
+    <Real>0.033982199</Real>
+    <Real>-0.33926401</Real>
+    <Real>-0.195425</Real>
+    <Real>-0.071849696</Real>
+    <Real>-0.37102601</Real>
+    <Real>-0.21621799</Real>
+    <Real>0.0139881</Real>
+    <Real>-0.35108399</Real>
+    <Real>-0.138989</Real>
+    <Real>0.052345399</Real>
+    <Real>-0.32499999</Real>
+    <Real>-0.14821599</Real>
+    <Real>0.042676602</Real>
+    <Real>-0.28181201</Real>
+    <Real>-0.126936</Real>
+    <Real>0.0222029</Real>
+    <Real>-0.287808</Real>
+    <Real>-0.071663201</Real>
+    <Real>0.13822199</Real>
+    <Real>-0.185139</Real>
+    <Real>-0.0152797</Real>
+    <Real>0.230471</Real>
+    <Real>-0.22155701</Real>
+    <Real>0.0130399</Real>
+    <Real>0.208427</Real>
+    <Real>-0.127197</Real>
+    <Real>0.0064887698</Real>
+    <Real>0.236035</Real>
+    <Real>-0.140938</Real>
+    <Real>0.192555</Real>
+    <Real>0.148371</Real>
+    <Real>-0.121454</Real>
+    <Real>0.073920898</Real>
+    <Real>0.32382101</Real>
+    <Real>-0.075303599</Real>
+    <Real>0.187121</Real>
+    <Real>0.197079</Real>
+    <Real>0.088469401</Real>
+    <Real>0.14371</Real>
+    <Real>0.346057</Real>
+    <Real>0.072195202</Real>
+    <Real>0.120678</Real>
+    <Real>0.37142599</Real>
+    <Real>0.134703</Real>
+    <Real>0.161566</Real>
+    <Real>0.34491301</Real>
+    <Real>0.110235</Real>
+    <Real>0.223032</Real>
+    <Real>0.215381</Real>
+    <Real>0.15115701</Real>
+    <Real>0.337161</Real>
+    <Real>0.34478301</Real>
+    <Real>0.154284</Real>
+    <Real>0.217981</Real>
+    <Real>0.31849399</Real>
+    <Real>0.27069601</Real>
+    <Real>0.32320201</Real>
+    <Real>0.201975</Real>
+    <Real>0.13255</Real>
+    <Real>0.19012199</Real>
+    <Real>0.22415</Real>
+    <Real>0.33738399</Real>
+    <Real>0.24033999</Real>
+    <Real>0.292528</Real>
+    <Real>0.231969</Real>
+    <Real>0.26378</Real>
+    <Real>0.30350101</Real>
+    <Real>0.23063</Real>
+    <Real>0.299878</Real>
+    <Real>0.15784501</Real>
+    <Real>0.276788</Real>
+    <Real>0.36825699</Real>
+    <Real>0.193731</Real>
+    <Real>0.21615</Real>
+    <Real>0.207757</Real>
+    <Real>0.136564</Real>
+    <Real>0.26222599</Real>
+    <Real>0.210265</Real>
+    <Real>0.13002799</Real>
+    <Real>0.20605899</Real>
+    <Real>0.152711</Real>
+    <Real>0.195077</Real>
+    <Real>0.29734299</Real>
+    <Real>0.237324</Real>
+    <Real>0.118121</Real>
+    <Real>0.29328901</Real>
+    <Real>0.22663499</Real>
+    <Real>0.075010903</Real>
+    <Real>0.26577801</Real>
+    <Real>0.119711</Real>
+    <Real>0.106759</Real>
+    <Real>0.27516001</Real>
+    <Real>0.105753</Real>
+    <Real>0.093085699</Real>
+    <Real>0.25944301</Real>
+    <Real>0.195959</Real>
+    <Real>0.0504844</Real>
+    <Real>0.237343</Real>
+    <Real>0.142589</Real>
+    <Real>-0.089643501</Real>
+    <Real>0.282426</Real>
+    <Real>0.148966</Real>
+    <Real>-0.0323091</Real>
+    <Real>0.160483</Real>
+    <Real>0.035948101</Real>
+    <Real>-0.078566097</Real>
+    <Real>0.21877199</Real>
+    <Real>0.129273</Real>
+    <Real>-0.15982699</Real>
+    <Real>0.0853457</Real>
+    <Real>0.116802</Real>
+    <Real>-0.041748598</Real>
+    <Real>0.20506001</Real>
+    <Real>0.082346298</Real>
+    <Real>-0.033599202</Real>
+    <Real>0.094616003</Real>
+    <Real>0.019920699</Real>
+    <Real>-0.046248399</Real>
+    <Real>0.024650799</Real>
+    <Real>-0.0416026</Real>
+    <Real>-0.098334201</Real>
+    <Real>0.063990101</Real>
+    <Real>-0.13928699</Real>
+    <Real>-0.242319</Real>
+    <Real>0.024995901</Real>
+    <Real>-0.18093801</Real>
+    <Real>-0.249294</Real>
+    <Real>0.032946199</Real>
+    <Real>-0.159826</Real>
+    <Real>-0.23584101</Real>
+    <Real>0.016282201</Real>
+    <Real>-0.196504</Real>
+    <Real>-0.23710801</Real>
+    <Real>-0.0406349</Real>
+    <Real>-0.11625</Real>
+    <Real>-0.115526</Real>
+    <Real>0.035594702</Real>
+    <Real>-0.100031</Real>
+    <Real>-0.131438</Real>
+    <Real>-0.148066</Real>
+    <Real>-0.246914</Real>
+    <Real>-0.228278</Real>
+    <Real>-0.128664</Real>
+    <Real>-0.151379</Real>
+    <Real>-0.120204</Real>
+    <Real>-0.20564</Real>
+    <Real>-0.19493499</Real>
+    <Real>-0.223316</Real>
+    <Real>-0.20992599</Real>
+    <Real>-0.293475</Real>
+    <Real>-0.181631</Real>
+    <Real>-0.15154199</Real>
+    <Real>-0.18523701</Real>
+    <Real>-0.277973</Real>
+    <Real>-0.212514</Real>
+    <Real>-0.25714999</Real>
+    <Real>-0.106606</Real>
+    <Real>-0.17149</Real>
+    <Real>-0.28705299</Real>
+    <Real>-0.17783999</Real>
+    <Real>-0.288715</Real>
+    <Real>-0.13793799</Real>
+    <Real>-0.15577</Real>
+    <Real>-0.101648</Real>
+    <Real>-0.29286501</Real>
+    <Real>-0.15349799</Real>
+    <Real>-0.196582</Real>
+    <Real>-0.151655</Real>
+    <Real>-0.105669</Real>
+    <Real>-0.233206</Real>
+    <Real>-0.205688</Real>
+    <Real>-0.120301</Real>
+    <Real>-0.30407101</Real>
+    <Real>-0.27380499</Real>
+    <Real>-0.0567232</Real>
+    <Real>-0.26257399</Real>
+    <Real>-0.213572</Real>
+    <Real>-0.188062</Real>
+    <Real>-0.234014</Real>
+    <Real>-0.147396</Real>
+    <Real>-0.130597</Real>
+    <Real>-0.127922</Real>
+    <Real>-0.16339099</Real>
+    <Real>-0.141241</Real>
+    <Real>-0.14472499</Real>
+    <Real>-0.10392</Real>
+    <Real>-0.0510807</Real>
+    <Real>-0.247492</Real>
+    <Real>-0.058272298</Real>
+    <Real>-0.0082769198</Real>
+    <Real>-0.25879499</Real>
+    <Real>-0.19123399</Real>
+    <Real>0.077861302</Real>
+    <Real>-0.074387997</Real>
+    <Real>-0.142011</Real>
+    <Real>0.081611998</Real>
+    <Real>-0.12735599</Real>
+    <Real>-0.153745</Real>
+    <Real>0.078688301</Real>
+    <Real>-0.12088</Real>
+    <Real>-0.122613</Real>
+    <Real>0.067525104</Real>
+    <Real>-0.13781101</Real>
+    <Real>0.023367999</Real>
+    <Real>0.057603098</Real>
+  </Sequence>
+  <Real Name="Integral">-13.63323055645742</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP4.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP4.xml
new file mode 100644 (file)
index 0000000..d318d51
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>0.91440845</Real>
+    <Real>0.89127165</Real>
+    <Real>0.85387266</Real>
+    <Real>0.81370103</Real>
+    <Real>0.7681002</Real>
+    <Real>0.70884496</Real>
+    <Real>0.65127754</Real>
+    <Real>0.58396322</Real>
+    <Real>0.50845456</Real>
+    <Real>0.43051061</Real>
+    <Real>0.35105249</Real>
+    <Real>0.26587203</Real>
+    <Real>0.18143819</Real>
+    <Real>0.097567506</Real>
+    <Real>0.015512385</Real>
+    <Real>-0.068423927</Real>
+    <Real>-0.1456465</Real>
+    <Real>-0.22284648</Real>
+    <Real>-0.29907748</Real>
+    <Real>-0.37475094</Real>
+    <Real>-0.4380517</Real>
+    <Real>-0.49662268</Real>
+    <Real>-0.55154026</Real>
+    <Real>-0.60047692</Real>
+    <Real>-0.64397019</Real>
+    <Real>-0.67695993</Real>
+    <Real>-0.69747227</Real>
+    <Real>-0.71946371</Real>
+    <Real>-0.73064023</Real>
+    <Real>-0.73969084</Real>
+    <Real>-0.73910058</Real>
+    <Real>-0.72273451</Real>
+    <Real>-0.70480442</Real>
+    <Real>-0.68460542</Real>
+    <Real>-0.65121585</Real>
+    <Real>-0.61127657</Real>
+    <Real>-0.56959647</Real>
+    <Real>-0.53186774</Real>
+    <Real>-0.47233477</Real>
+    <Real>-0.42289308</Real>
+    <Real>-0.36013916</Real>
+    <Real>-0.30238953</Real>
+    <Real>-0.23851043</Real>
+    <Real>-0.17228492</Real>
+    <Real>-0.10760929</Real>
+    <Real>-0.038677685</Real>
+    <Real>0.023924842</Real>
+    <Real>0.085734844</Real>
+    <Real>0.14554502</Real>
+    <Real>0.21178007</Real>
+    <Real>0.26366264</Real>
+    <Real>0.31547186</Real>
+    <Real>0.36479235</Real>
+    <Real>0.41372058</Real>
+    <Real>0.45014268</Real>
+    <Real>0.48719069</Real>
+    <Real>0.51477271</Real>
+    <Real>0.54144377</Real>
+    <Real>0.55743951</Real>
+    <Real>0.56827539</Real>
+    <Real>0.57417756</Real>
+    <Real>0.57521474</Real>
+    <Real>0.57242984</Real>
+    <Real>0.56181103</Real>
+    <Real>0.54661202</Real>
+    <Real>0.5273785</Real>
+    <Real>0.49807823</Real>
+    <Real>0.46791199</Real>
+    <Real>0.43094185</Real>
+    <Real>0.39116937</Real>
+    <Real>0.34865311</Real>
+    <Real>0.30475527</Real>
+    <Real>0.26447845</Real>
+    <Real>0.20973703</Real>
+    <Real>0.16015707</Real>
+    <Real>0.10805874</Real>
+    <Real>0.059454329</Real>
+    <Real>0.0076480238</Real>
+    <Real>-0.045675594</Real>
+    <Real>-0.089126058</Real>
+    <Real>-0.14246953</Real>
+    <Real>-0.18825532</Real>
+    <Real>-0.22974341</Real>
+    <Real>-0.27582318</Real>
+    <Real>-0.30692092</Real>
+    <Real>-0.34222001</Real>
+    <Real>-0.37205994</Real>
+    <Real>-0.39867413</Real>
+    <Real>-0.42049485</Real>
+    <Real>-0.43268493</Real>
+    <Real>-0.446363</Real>
+    <Real>-0.45471677</Real>
+    <Real>-0.45743033</Real>
+    <Real>-0.45754004</Real>
+    <Real>-0.44663361</Real>
+    <Real>-0.43691492</Real>
+    <Real>-0.42143744</Real>
+    <Real>-0.39964595</Real>
+    <Real>-0.37948313</Real>
+    <Real>-0.35078076</Real>
+    <Real>-0.32291207</Real>
+    <Real>-0.28617722</Real>
+    <Real>-0.25431877</Real>
+    <Real>-0.21413048</Real>
+    <Real>-0.17472994</Real>
+    <Real>-0.13722105</Real>
+    <Real>-0.0940689</Real>
+    <Real>-0.050582096</Real>
+    <Real>-0.011372223</Real>
+    <Real>0.033095215</Real>
+    <Real>0.064681761</Real>
+    <Real>0.10605592</Real>
+    <Real>0.13676096</Real>
+    <Real>0.17619975</Real>
+    <Real>0.20634755</Real>
+    <Real>0.23424256</Real>
+    <Real>0.26192936</Real>
+    <Real>0.28315401</Real>
+    <Real>0.31159228</Real>
+    <Real>0.32296148</Real>
+    <Real>0.3337082</Real>
+    <Real>0.3472271</Real>
+    <Real>0.35520938</Real>
+    <Real>0.35884556</Real>
+    <Real>0.35598138</Real>
+    <Real>0.36070585</Real>
+    <Real>0.34978899</Real>
+    <Real>0.33616209</Real>
+    <Real>0.32133636</Real>
+    <Real>0.30463791</Real>
+    <Real>0.28434399</Real>
+    <Real>0.26060301</Real>
+    <Real>0.23513913</Real>
+    <Real>0.21211421</Real>
+    <Real>0.18200785</Real>
+    <Real>0.15506685</Real>
+    <Real>0.11292174</Real>
+    <Real>0.08485233</Real>
+    <Real>0.048554849</Real>
+    <Real>0.015430034</Real>
+    <Real>-0.0053237719</Real>
+    <Real>-0.043886948</Real>
+    <Real>-0.069251105</Real>
+    <Real>-0.099874027</Real>
+    <Real>-0.1318848</Real>
+    <Real>-0.15587749</Real>
+    <Real>-0.18213047</Real>
+    <Real>-0.19872877</Real>
+    <Real>-0.22116253</Real>
+    <Real>-0.23839074</Real>
+    <Real>-0.24964274</Real>
+    <Real>-0.25999296</Real>
+    <Real>-0.26915544</Real>
+    <Real>-0.28208914</Real>
+    <Real>-0.28375041</Real>
+    <Real>-0.2840305</Real>
+    <Real>-0.28654379</Real>
+    <Real>-0.27391881</Real>
+    <Real>-0.26717883</Real>
+    <Real>-0.25783545</Real>
+    <Real>-0.24391536</Real>
+    <Real>-0.23143035</Real>
+    <Real>-0.21355876</Real>
+    <Real>-0.19516303</Real>
+    <Real>-0.17305651</Real>
+    <Real>-0.14851433</Real>
+    <Real>-0.13391782</Real>
+    <Real>-0.10106573</Real>
+    <Real>-0.079669952</Real>
+    <Real>-0.054322001</Real>
+    <Real>-0.022567146</Real>
+    <Real>-0.0082916291</Real>
+    <Real>0.028239559</Real>
+    <Real>0.044842608</Real>
+    <Real>0.066723041</Real>
+    <Real>0.086818486</Real>
+    <Real>0.11206019</Real>
+    <Real>0.13034853</Real>
+    <Real>0.14292336</Real>
+    <Real>0.16384037</Real>
+    <Real>0.17437287</Real>
+    <Real>0.19422586</Real>
+    <Real>0.19642359</Real>
+    <Real>0.20773162</Real>
+    <Real>0.21621291</Real>
+    <Real>0.22017281</Real>
+    <Real>0.21870746</Real>
+    <Real>0.22144818</Real>
+    <Real>0.21968257</Real>
+    <Real>0.21284904</Real>
+    <Real>0.20909898</Real>
+    <Real>0.20217142</Real>
+    <Real>0.19360588</Real>
+    <Real>0.18018678</Real>
+    <Real>0.16507152</Real>
+    <Real>0.14102207</Real>
+    <Real>0.13159586</Real>
+    <Real>0.11218439</Real>
+    <Real>0.090035476</Real>
+    <Real>0.069503993</Real>
+    <Real>0.054288179</Real>
+    <Real>0.034861948</Real>
+    <Real>0.013234816</Real>
+    <Real>-0.0047988398</Real>
+    <Real>-0.024740862</Real>
+    <Real>-0.042112309</Real>
+    <Real>-0.057106286</Real>
+    <Real>-0.079133794</Real>
+    <Real>-0.08531253</Real>
+    <Real>-0.10183473</Real>
+    <Real>-0.11679</Real>
+    <Real>-0.13124378</Real>
+    <Real>-0.13978031</Real>
+    <Real>-0.15192363</Real>
+    <Real>-0.15962306</Real>
+    <Real>-0.16721499</Real>
+    <Real>-0.17583407</Real>
+    <Real>-0.17053062</Real>
+    <Real>-0.17783985</Real>
+    <Real>-0.17420124</Real>
+    <Real>-0.16439037</Real>
+    <Real>-0.16967009</Real>
+    <Real>-0.16545986</Real>
+    <Real>-0.15178227</Real>
+    <Real>-0.1513456</Real>
+    <Real>-0.13972749</Real>
+    <Real>-0.12844835</Real>
+    <Real>-0.11278458</Real>
+    <Real>-0.10008006</Real>
+    <Real>-0.084673822</Real>
+    <Real>-0.071988769</Real>
+    <Real>-0.055301242</Real>
+    <Real>-0.044846795</Real>
+    <Real>-0.024612129</Real>
+    <Real>-0.012670649</Real>
+    <Real>0.0064235702</Real>
+    <Real>0.017517105</Real>
+    <Real>0.032193232</Real>
+    <Real>0.05088919</Real>
+    <Real>0.059888519</Real>
+    <Real>0.073218867</Real>
+    <Real>0.084005043</Real>
+    <Real>0.097417012</Real>
+    <Real>0.11064502</Real>
+    <Real>0.11908618</Real>
+    <Real>0.12669091</Real>
+    <Real>0.12785465</Real>
+    <Real>0.13891017</Real>
+    <Real>0.14016822</Real>
+    <Real>0.15007298</Real>
+    <Real>4.4267403e-05</Real>
+    <Real>4.3514352e-05</Real>
+    <Real>4.3138727e-05</Real>
+    <Real>4.1891646e-05</Real>
+    <Real>4.0179297e-05</Real>
+    <Real>3.8032213e-05</Real>
+    <Real>3.7556416e-05</Real>
+    <Real>3.5218971e-05</Real>
+    <Real>3.1478037e-05</Real>
+    <Real>3.0895699e-05</Real>
+    <Real>2.615025e-05</Real>
+    <Real>2.0906495e-05</Real>
+    <Real>1.7488654e-05</Real>
+    <Real>1.3209424e-05</Real>
+    <Real>9.7491848e-06</Real>
+    <Real>6.3581501e-06</Real>
+    <Real>5.6303825e-06</Real>
+    <Real>-5.1143962e-07</Real>
+    <Real>-4.6430905e-06</Real>
+    <Real>-8.4661779e-06</Real>
+    <Real>-1.0448402e-05</Real>
+    <Real>-1.6193704e-05</Real>
+    <Real>-1.857411e-05</Real>
+    <Real>-2.250258e-05</Real>
+    <Real>-2.3523124e-05</Real>
+    <Real>-2.7104035e-05</Real>
+    <Real>-2.8832133e-05</Real>
+    <Real>-2.9649824e-05</Real>
+    <Real>-3.12257e-05</Real>
+    <Real>-3.2669741e-05</Real>
+    <Real>-3.3304954e-05</Real>
+    <Real>-3.3183347e-05</Real>
+    <Real>-3.4332639e-05</Real>
+    <Real>-3.3677767e-05</Real>
+    <Real>-3.4504159e-05</Real>
+    <Real>-3.454684e-05</Real>
+    <Real>-3.2467542e-05</Real>
+    <Real>-2.9868665e-05</Real>
+    <Real>-2.9505636e-05</Real>
+    <Real>-2.6500937e-05</Real>
+    <Real>-2.6333106e-05</Real>
+    <Real>-2.3109949e-05</Real>
+    <Real>-2.140675e-05</Real>
+    <Real>-1.6538143e-05</Real>
+    <Real>-1.4951454e-05</Real>
+    <Real>-1.0329346e-05</Real>
+    <Real>-8.6922209e-06</Real>
+    <Real>-6.4748251e-06</Real>
+    <Real>-2.4234089e-06</Real>
+    <Real>2.1927521e-07</Real>
+    <Real>2.7016404e-06</Real>
+    <Real>3.5660794e-06</Real>
+    <Real>6.7710325e-06</Real>
+    <Real>1.154716e-05</Real>
+    <Real>1.27539e-05</Real>
+    <Real>1.4957743e-05</Real>
+    <Real>1.8768704e-05</Real>
+    <Real>1.983804e-05</Real>
+    <Real>2.258397e-05</Real>
+    <Real>2.3245073e-05</Real>
+    <Real>2.5949555e-05</Real>
+    <Real>2.7714603e-05</Real>
+    <Real>2.4125953e-05</Real>
+    <Real>2.7313827e-05</Real>
+    <Real>2.6500267e-05</Real>
+    <Real>2.8872726e-05</Real>
+    <Real>2.8494722e-05</Real>
+    <Real>2.8652294e-05</Real>
+    <Real>2.6291838e-05</Real>
+    <Real>2.3836281e-05</Real>
+    <Real>2.2856551e-05</Real>
+    <Real>2.24215e-05</Real>
+    <Real>2.2928167e-05</Real>
+    <Real>2.0600462e-05</Real>
+    <Real>2.1569322e-05</Real>
+    <Real>1.8669114e-05</Real>
+    <Real>1.6274531e-05</Real>
+    <Real>1.3573073e-05</Real>
+    <Real>1.2755655e-05</Real>
+    <Real>9.1842421e-06</Real>
+    <Real>4.9424475e-06</Real>
+    <Real>1.9999163e-06</Real>
+    <Real>1.2401867e-06</Real>
+    <Real>-3.0244464e-06</Real>
+    <Real>-7.6198962e-06</Real>
+    <Real>-9.8329774e-06</Real>
+    <Real>-8.8280267e-06</Real>
+    <Real>-1.377236e-05</Real>
+    <Real>-1.6982995e-05</Real>
+    <Real>-1.9108473e-05</Real>
+    <Real>-2.0853575e-05</Real>
+    <Real>-2.3638708e-05</Real>
+    <Real>-2.4330864e-05</Real>
+    <Real>-2.3607576e-05</Real>
+    <Real>-2.3350785e-05</Real>
+    <Real>-2.4861311e-05</Real>
+    <Real>-2.4024377e-05</Real>
+    <Real>-2.7649214e-05</Real>
+    <Real>-3.0116586e-05</Real>
+    <Real>-2.7083521e-05</Real>
+    <Real>-2.6461454e-05</Real>
+    <Real>-2.5706378e-05</Real>
+    <Real>-2.3319637e-05</Real>
+    <Real>-2.2089596e-05</Real>
+    <Real>-1.7878658e-05</Real>
+    <Real>-1.7124203e-05</Real>
+    <Real>-1.5375375e-05</Real>
+    <Real>-1.5521959e-05</Real>
+    <Real>-1.172509e-05</Real>
+    <Real>-9.1009997e-06</Real>
+    <Real>-5.6435597e-06</Real>
+    <Real>-2.9174676e-06</Real>
+    <Real>-5.4268908e-06</Real>
+    <Real>-1.5508874e-06</Real>
+    <Real>-3.7975212e-07</Real>
+    <Real>3.1173399e-06</Real>
+    <Real>1.9381382e-06</Real>
+    <Real>5.5445184e-06</Real>
+    <Real>6.774098e-06</Real>
+    <Real>8.9054111e-06</Real>
+    <Real>1.0997211e-05</Real>
+    <Real>1.4307585e-05</Real>
+    <Real>1.3101091e-05</Real>
+    <Real>1.5396869e-05</Real>
+    <Real>1.3836742e-05</Real>
+    <Real>1.4298585e-05</Real>
+    <Real>1.65646e-05</Real>
+    <Real>1.5446933e-05</Real>
+    <Real>1.9028628e-05</Real>
+    <Real>2.0577343e-05</Real>
+    <Real>1.6241767e-05</Real>
+    <Real>1.6588914e-05</Real>
+    <Real>1.6793663e-05</Real>
+    <Real>1.5231977e-05</Real>
+    <Real>1.3574629e-05</Real>
+    <Real>1.3824551e-05</Real>
+    <Real>1.3580589e-05</Real>
+    <Real>8.8718243e-06</Real>
+    <Real>8.9766982e-06</Real>
+    <Real>4.874571e-06</Real>
+    <Real>6.1740734e-06</Real>
+    <Real>4.3778728e-06</Real>
+    <Real>3.0633016e-06</Real>
+    <Real>2.650128e-06</Real>
+    <Real>4.4499197e-06</Real>
+    <Real>5.2487553e-07</Real>
+    <Real>3.844505e-06</Real>
+    <Real>8.3970571e-07</Real>
+    <Real>-4.0378814e-06</Real>
+    <Real>-4.2863321e-06</Real>
+    <Real>-3.9477163e-06</Real>
+    <Real>-5.5808941e-06</Real>
+    <Real>-8.159157e-06</Real>
+    <Real>-1.07823e-05</Real>
+    <Real>-1.0445928e-05</Real>
+    <Real>-1.4758529e-05</Real>
+    <Real>-1.5891597e-05</Real>
+    <Real>-1.6962238e-05</Real>
+    <Real>-1.6818865e-05</Real>
+    <Real>-1.3153352e-05</Real>
+    <Real>-1.3562746e-05</Real>
+    <Real>-1.536158e-05</Real>
+    <Real>-1.6916658e-05</Real>
+    <Real>-1.5912401e-05</Real>
+    <Real>-1.9311357e-05</Real>
+    <Real>-1.3812277e-05</Real>
+    <Real>-1.7308477e-05</Real>
+    <Real>-1.1393254e-05</Real>
+    <Real>-6.9415369e-06</Real>
+    <Real>-8.5329793e-06</Real>
+    <Real>-7.3732735e-06</Real>
+    <Real>-8.2779943e-06</Real>
+    <Real>-4.1989624e-06</Real>
+    <Real>-4.0598088e-06</Real>
+    <Real>-6.2781332e-06</Real>
+    <Real>-6.1900923e-06</Real>
+    <Real>-9.3725657e-06</Real>
+    <Real>-9.9827339e-06</Real>
+    <Real>-9.6235508e-06</Real>
+    <Real>-4.7038488e-06</Real>
+    <Real>-3.4777854e-06</Real>
+    <Real>-2.7908015e-06</Real>
+    <Real>1.7161137e-06</Real>
+    <Real>2.1103369e-06</Real>
+    <Real>1.6298396e-06</Real>
+    <Real>5.1353272e-06</Real>
+    <Real>9.7297398e-06</Real>
+    <Real>7.9292831e-06</Real>
+    <Real>1.0491432e-05</Real>
+    <Real>8.7098369e-06</Real>
+    <Real>1.1306504e-05</Real>
+    <Real>1.2767204e-05</Real>
+    <Real>1.0523996e-05</Real>
+    <Real>1.5876185e-05</Real>
+    <Real>1.8240517e-05</Real>
+    <Real>1.7410239e-05</Real>
+    <Real>1.8709565e-05</Real>
+    <Real>2.0682788e-05</Real>
+    <Real>2.2414559e-05</Real>
+    <Real>2.3641453e-05</Real>
+    <Real>2.9956356e-05</Real>
+    <Real>3.1942258e-05</Real>
+    <Real>3.2165972e-05</Real>
+    <Real>2.3073231e-05</Real>
+    <Real>2.1864589e-05</Real>
+    <Real>2.3307522e-05</Real>
+    <Real>2.6105658e-05</Real>
+    <Real>3.0764437e-05</Real>
+    <Real>2.5258372e-05</Real>
+    <Real>2.4398061e-05</Real>
+    <Real>1.5440721e-05</Real>
+    <Real>7.2866023e-06</Real>
+    <Real>4.1072926e-06</Real>
+    <Real>1.3465999e-05</Real>
+    <Real>9.5875193e-06</Real>
+    <Real>3.303629e-06</Real>
+    <Real>-9.6435542e-06</Real>
+    <Real>-1.4834303e-05</Real>
+    <Real>-1.3345806e-05</Real>
+    <Real>-1.2496928e-05</Real>
+    <Real>-1.2373329e-05</Real>
+    <Real>-1.9174164e-05</Real>
+    <Real>-2.2750348e-05</Real>
+    <Real>-1.0412362e-05</Real>
+    <Real>-7.1453283e-06</Real>
+    <Real>-5.0996732e-06</Real>
+    <Real>-1.4278352e-06</Real>
+    <Real>1.091708e-05</Real>
+    <Real>6.6890452e-06</Real>
+    <Real>2.0174368e-05</Real>
+    <Real>1.0472003e-05</Real>
+    <Real>4.7418193e-06</Real>
+    <Real>9.2978889e-06</Real>
+    <Real>4.5979341e-06</Real>
+    <Real>1.164395e-05</Real>
+    <Real>-1.1824308e-05</Real>
+    <Real>-1.2670253e-05</Real>
+    <Real>-7.1008421e-06</Real>
+    <Real>4.0426371e-06</Real>
+    <Real>9.691882e-06</Real>
+    <Real>3.4888384e-05</Real>
+    <Real>2.3447481e-05</Real>
+    <Real>6.0634087e-05</Real>
+    <Real>4.6600537e-05</Real>
+    <Real>3.8806083e-05</Real>
+    <Real>4.0546623e-05</Real>
+    <Real>5.6960853e-05</Real>
+    <Real>1.7836719e-05</Real>
+    <Real>-8.4526189e-05</Real>
+    <Real>-0.00019142308</Real>
+  </Sequence>
+  <Real Name="Integral">0.54968381075777017</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacRcross.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacRcross.xml
new file mode 100644 (file)
index 0000000..a08bdab
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>0</Real>
+    <Real>0.0022387446</Real>
+    <Real>0.0035028025</Real>
+    <Real>0.0056085354</Real>
+    <Real>0.0086741624</Real>
+    <Real>0.011819702</Real>
+    <Real>0.015920334</Real>
+    <Real>0.020022845</Real>
+    <Real>0.024242017</Real>
+    <Real>0.028022908</Real>
+    <Real>0.032008588</Real>
+    <Real>0.034803107</Real>
+    <Real>0.037513334</Real>
+    <Real>0.039289925</Real>
+    <Real>0.039613295</Real>
+    <Real>0.040232945</Real>
+    <Real>0.039999284</Real>
+    <Real>0.038773619</Real>
+    <Real>0.037022036</Real>
+    <Real>0.03395154</Real>
+    <Real>0.030716933</Real>
+    <Real>0.027687127</Real>
+    <Real>0.024219509</Real>
+    <Real>0.020108201</Real>
+    <Real>0.01619355</Real>
+    <Real>0.013057033</Real>
+    <Real>0.0098494859</Real>
+    <Real>0.0073886877</Real>
+    <Real>0.0050956123</Real>
+    <Real>0.0031476091</Real>
+    <Real>0.0022303942</Real>
+    <Real>0.0014421673</Real>
+    <Real>0.0015605417</Real>
+    <Real>0.0023478915</Real>
+    <Real>0.0032595003</Real>
+    <Real>0.0048598177</Real>
+    <Real>0.0068661571</Real>
+    <Real>0.0093070166</Real>
+    <Real>0.01151516</Real>
+    <Real>0.014135026</Real>
+    <Real>0.015877407</Real>
+    <Real>0.017582361</Real>
+    <Real>0.020061353</Real>
+    <Real>0.021256194</Real>
+    <Real>0.022746835</Real>
+    <Real>0.023190113</Real>
+    <Real>0.023767922</Real>
+    <Real>0.023968713</Real>
+    <Real>0.023062855</Real>
+    <Real>0.022064622</Real>
+    <Real>0.020306958</Real>
+    <Real>0.019000532</Real>
+    <Real>0.017193301</Real>
+    <Real>0.014820882</Real>
+    <Real>0.012806546</Real>
+    <Real>0.01087003</Real>
+    <Real>0.0087013068</Real>
+    <Real>0.006995955</Real>
+    <Real>0.0053816945</Real>
+    <Real>0.0039921342</Real>
+    <Real>0.0027184775</Real>
+    <Real>0.0019667295</Real>
+    <Real>0.0015231621</Real>
+    <Real>0.0012839382</Real>
+    <Real>0.0015572251</Real>
+    <Real>0.0018984043</Real>
+    <Real>0.0027348096</Real>
+    <Real>0.0038960488</Real>
+    <Real>0.0049909945</Real>
+    <Real>0.0061516701</Real>
+    <Real>0.0075028935</Real>
+    <Real>0.0090615265</Real>
+    <Real>0.010369415</Real>
+    <Real>0.011767319</Real>
+    <Real>0.012683169</Real>
+    <Real>0.013795277</Real>
+    <Real>0.014282157</Real>
+    <Real>0.014870015</Real>
+    <Real>0.014935284</Real>
+    <Real>0.01447196</Real>
+    <Real>0.014191067</Real>
+    <Real>0.013750138</Real>
+    <Real>0.012850181</Real>
+    <Real>0.011913967</Real>
+    <Real>0.010623846</Real>
+    <Real>0.0090860547</Real>
+    <Real>0.0075213881</Real>
+    <Real>0.0063633667</Real>
+    <Real>0.0050101974</Real>
+    <Real>0.0040042601</Real>
+    <Real>0.0031182179</Real>
+    <Real>0.0022295942</Real>
+    <Real>0.0017177914</Real>
+    <Real>0.0013426655</Real>
+    <Real>0.0011556742</Real>
+    <Real>0.0012329743</Real>
+    <Real>0.0015336524</Real>
+    <Real>0.0020214748</Real>
+    <Real>0.002688495</Real>
+    <Real>0.003164774</Real>
+    <Real>0.0040248022</Real>
+    <Real>0.0049421801</Real>
+    <Real>0.0056449943</Real>
+    <Real>0.0064900178</Real>
+    <Real>0.0073318691</Real>
+    <Real>0.0079388851</Real>
+    <Real>0.008348099</Real>
+    <Real>0.0085937753</Real>
+    <Real>0.0088053253</Real>
+    <Real>0.0089643188</Real>
+    <Real>0.008462159</Real>
+    <Real>0.0081677679</Real>
+    <Real>0.0077010952</Real>
+    <Real>0.0069283829</Real>
+    <Real>0.006470554</Real>
+    <Real>0.005889717</Real>
+    <Real>0.0050404803</Real>
+    <Real>0.0043520979</Real>
+    <Real>0.0038374509</Real>
+    <Real>0.0031289412</Real>
+    <Real>0.0025550255</Real>
+    <Real>0.0020456621</Real>
+    <Real>0.001599103</Real>
+    <Real>0.0014034451</Real>
+    <Real>0.0012568776</Real>
+    <Real>0.0012050986</Real>
+    <Real>0.0012863051</Real>
+    <Real>0.0015274084</Real>
+    <Real>0.0017116911</Real>
+    <Real>0.0021996475</Real>
+    <Real>0.0025582563</Real>
+    <Real>0.0031697224</Real>
+    <Real>0.0036516772</Real>
+    <Real>0.0039112582</Real>
+    <Real>0.004503814</Real>
+    <Real>0.0045496449</Real>
+    <Real>0.0050086039</Real>
+    <Real>0.0053778985</Real>
+    <Real>0.0057354039</Real>
+    <Real>0.0060177911</Real>
+    <Real>0.0058440645</Real>
+    <Real>0.0055686114</Real>
+    <Real>0.0052352445</Real>
+    <Real>0.0049270913</Real>
+    <Real>0.0048669502</Real>
+    <Real>0.0044287615</Real>
+    <Real>0.0041116709</Real>
+    <Real>0.0037526242</Real>
+    <Real>0.0034778048</Real>
+    <Real>0.0031402872</Real>
+    <Real>0.0026885001</Real>
+    <Real>0.0022954869</Real>
+    <Real>0.0020505243</Real>
+    <Real>0.0017681995</Real>
+    <Real>0.001462435</Real>
+    <Real>0.0014559019</Real>
+    <Real>0.0014701682</Real>
+    <Real>0.0013319635</Real>
+    <Real>0.0015024599</Real>
+    <Real>0.0015520391</Real>
+    <Real>0.0018194491</Real>
+    <Real>0.0021310409</Real>
+    <Real>0.0023092343</Real>
+    <Real>0.0024470286</Real>
+    <Real>0.0026841904</Real>
+    <Real>0.0029517743</Real>
+    <Real>0.0030204616</Real>
+    <Real>0.0031903982</Real>
+    <Real>0.0035431373</Real>
+    <Real>0.0036453719</Real>
+    <Real>0.0038470726</Real>
+    <Real>0.003884491</Real>
+    <Real>0.003770831</Real>
+    <Real>0.0036215147</Real>
+    <Real>0.0034913709</Real>
+    <Real>0.0032639375</Real>
+    <Real>0.0030114818</Real>
+    <Real>0.0029031846</Real>
+    <Real>0.0027138728</Real>
+    <Real>0.0025935557</Real>
+    <Real>0.0024792887</Real>
+    <Real>0.0023132155</Real>
+    <Real>0.0020489933</Real>
+    <Real>0.0017954031</Real>
+    <Real>0.0016809653</Real>
+    <Real>0.0016296633</Real>
+    <Real>0.0015161918</Real>
+    <Real>0.0015554987</Real>
+    <Real>0.0015267093</Real>
+    <Real>0.0014726454</Real>
+    <Real>0.0015520853</Real>
+    <Real>0.0015158142</Real>
+    <Real>0.0017054193</Real>
+    <Real>0.0017699038</Real>
+    <Real>0.0020224431</Real>
+    <Real>0.0020263321</Real>
+    <Real>0.0022970943</Real>
+    <Real>0.0024474261</Real>
+    <Real>0.0025665488</Real>
+    <Real>0.002722204</Real>
+    <Real>0.0026923788</Real>
+    <Real>0.0027975827</Real>
+    <Real>0.0029700601</Real>
+    <Real>0.0029943788</Real>
+    <Real>0.0029474057</Real>
+    <Real>0.0027856492</Real>
+    <Real>0.002572892</Real>
+    <Real>0.0024962148</Real>
+    <Real>0.0024007454</Real>
+    <Real>0.0024167555</Real>
+    <Real>0.0022556121</Real>
+    <Real>0.0022061216</Real>
+    <Real>0.0021027932</Real>
+    <Real>0.0019645824</Real>
+    <Real>0.001897946</Real>
+    <Real>0.0017563587</Real>
+    <Real>0.0016798339</Real>
+    <Real>0.0016300865</Real>
+    <Real>0.0016609513</Real>
+    <Real>0.0016948835</Real>
+    <Real>0.0016175172</Real>
+    <Real>0.0016812063</Real>
+    <Real>0.0017271228</Real>
+    <Real>0.00175084</Real>
+    <Real>0.0019140517</Real>
+    <Real>0.0019397533</Real>
+    <Real>0.0018281466</Real>
+    <Real>0.0019714897</Real>
+    <Real>0.0020356507</Real>
+    <Real>0.0018801339</Real>
+    <Real>0.0020357326</Real>
+    <Real>0.0021443837</Real>
+    <Real>0.0021825135</Real>
+    <Real>0.0021718931</Real>
+    <Real>0.0022797454</Real>
+    <Real>0.0023199783</Real>
+    <Real>0.0023760132</Real>
+    <Real>0.002417963</Real>
+    <Real>0.0024605121</Real>
+    <Real>0.0024108223</Real>
+    <Real>0.0024090286</Real>
+    <Real>0.0024217165</Real>
+    <Real>0.0023988171</Real>
+    <Real>0.0022688324</Real>
+    <Real>0.0023057433</Real>
+    <Real>0.0022299876</Real>
+    <Real>0.0021526574</Real>
+    <Real>0.0022378063</Real>
+    <Real>0.0020277784</Real>
+    <Real>0.002016233</Real>
+    <Real>0.0020046735</Real>
+    <Real>-0.294002</Real>
+    <Real>-0.177398</Real>
+    <Real>-0.39839</Real>
+    <Real>-0.48773</Real>
+    <Real>-0.172094</Real>
+    <Real>-0.41209301</Real>
+    <Real>-0.408075</Real>
+    <Real>-0.30323401</Real>
+    <Real>-0.31504101</Real>
+    <Real>-0.36764601</Real>
+    <Real>-0.22680099</Real>
+    <Real>-0.362151</Real>
+    <Real>-0.37852699</Real>
+    <Real>-0.41337499</Real>
+    <Real>-0.42870599</Real>
+    <Real>-0.370096</Real>
+    <Real>-0.39703399</Real>
+    <Real>-0.43473601</Real>
+    <Real>-0.35783899</Real>
+    <Real>-0.31582201</Real>
+    <Real>-0.398561</Real>
+    <Real>-0.209665</Real>
+    <Real>-0.403451</Real>
+    <Real>-0.45481399</Real>
+    <Real>-0.29749301</Real>
+    <Real>-0.32480201</Real>
+    <Real>-0.386527</Real>
+    <Real>-0.19479001</Real>
+    <Real>-0.36277401</Real>
+    <Real>-0.33375701</Real>
+    <Real>-0.28211099</Real>
+    <Real>-0.394546</Real>
+    <Real>-0.406385</Real>
+    <Real>-0.114484</Real>
+    <Real>-0.42001301</Real>
+    <Real>-0.403752</Real>
+    <Real>-0.20651101</Real>
+    <Real>-0.30948099</Real>
+    <Real>-0.34128401</Real>
+    <Real>-0.120096</Real>
+    <Real>-0.45341599</Real>
+    <Real>-0.31077701</Real>
+    <Real>-0.119248</Real>
+    <Real>-0.43382999</Real>
+    <Real>-0.175929</Real>
+    <Real>0.033982199</Real>
+    <Real>-0.33926401</Real>
+    <Real>-0.195425</Real>
+    <Real>-0.071849696</Real>
+    <Real>-0.37102601</Real>
+    <Real>-0.21621799</Real>
+    <Real>0.0139881</Real>
+    <Real>-0.35108399</Real>
+    <Real>-0.138989</Real>
+    <Real>0.052345399</Real>
+    <Real>-0.32499999</Real>
+    <Real>-0.14821599</Real>
+    <Real>0.042676602</Real>
+    <Real>-0.28181201</Real>
+    <Real>-0.126936</Real>
+    <Real>0.0222029</Real>
+    <Real>-0.287808</Real>
+    <Real>-0.071663201</Real>
+    <Real>0.13822199</Real>
+    <Real>-0.185139</Real>
+    <Real>-0.0152797</Real>
+    <Real>0.230471</Real>
+    <Real>-0.22155701</Real>
+    <Real>0.0130399</Real>
+    <Real>0.208427</Real>
+    <Real>-0.127197</Real>
+    <Real>0.0064887698</Real>
+    <Real>0.236035</Real>
+    <Real>-0.140938</Real>
+    <Real>0.192555</Real>
+    <Real>0.148371</Real>
+    <Real>-0.121454</Real>
+    <Real>0.073920898</Real>
+    <Real>0.32382101</Real>
+    <Real>-0.075303599</Real>
+    <Real>0.187121</Real>
+    <Real>0.197079</Real>
+    <Real>0.088469401</Real>
+    <Real>0.14371</Real>
+    <Real>0.346057</Real>
+    <Real>0.072195202</Real>
+    <Real>0.120678</Real>
+    <Real>0.37142599</Real>
+    <Real>0.134703</Real>
+    <Real>0.161566</Real>
+    <Real>0.34491301</Real>
+    <Real>0.110235</Real>
+    <Real>0.223032</Real>
+    <Real>0.215381</Real>
+    <Real>0.15115701</Real>
+    <Real>0.337161</Real>
+    <Real>0.34478301</Real>
+    <Real>0.154284</Real>
+    <Real>0.217981</Real>
+    <Real>0.31849399</Real>
+    <Real>0.27069601</Real>
+    <Real>0.32320201</Real>
+    <Real>0.201975</Real>
+    <Real>0.13255</Real>
+    <Real>0.19012199</Real>
+    <Real>0.22415</Real>
+    <Real>0.33738399</Real>
+    <Real>0.24033999</Real>
+    <Real>0.292528</Real>
+    <Real>0.231969</Real>
+    <Real>0.26378</Real>
+    <Real>0.30350101</Real>
+    <Real>0.23063</Real>
+    <Real>0.299878</Real>
+    <Real>0.15784501</Real>
+    <Real>0.276788</Real>
+    <Real>0.36825699</Real>
+    <Real>0.193731</Real>
+    <Real>0.21615</Real>
+    <Real>0.207757</Real>
+    <Real>0.136564</Real>
+    <Real>0.26222599</Real>
+    <Real>0.210265</Real>
+    <Real>0.13002799</Real>
+    <Real>0.20605899</Real>
+    <Real>0.152711</Real>
+    <Real>0.195077</Real>
+    <Real>0.29734299</Real>
+    <Real>0.237324</Real>
+    <Real>0.118121</Real>
+    <Real>0.29328901</Real>
+    <Real>0.22663499</Real>
+    <Real>0.075010903</Real>
+    <Real>0.26577801</Real>
+    <Real>0.119711</Real>
+    <Real>0.106759</Real>
+    <Real>0.27516001</Real>
+    <Real>0.105753</Real>
+    <Real>0.093085699</Real>
+    <Real>0.25944301</Real>
+    <Real>0.195959</Real>
+    <Real>0.0504844</Real>
+    <Real>0.237343</Real>
+    <Real>0.142589</Real>
+    <Real>-0.089643501</Real>
+    <Real>0.282426</Real>
+    <Real>0.148966</Real>
+    <Real>-0.0323091</Real>
+    <Real>0.160483</Real>
+    <Real>0.035948101</Real>
+    <Real>-0.078566097</Real>
+    <Real>0.21877199</Real>
+    <Real>0.129273</Real>
+    <Real>-0.15982699</Real>
+    <Real>0.0853457</Real>
+    <Real>0.116802</Real>
+    <Real>-0.041748598</Real>
+    <Real>0.20506001</Real>
+    <Real>0.082346298</Real>
+    <Real>-0.033599202</Real>
+    <Real>0.094616003</Real>
+    <Real>0.019920699</Real>
+    <Real>-0.046248399</Real>
+    <Real>0.024650799</Real>
+    <Real>-0.0416026</Real>
+    <Real>-0.098334201</Real>
+    <Real>0.063990101</Real>
+    <Real>-0.13928699</Real>
+    <Real>-0.242319</Real>
+    <Real>0.024995901</Real>
+    <Real>-0.18093801</Real>
+    <Real>-0.249294</Real>
+    <Real>0.032946199</Real>
+    <Real>-0.159826</Real>
+    <Real>-0.23584101</Real>
+    <Real>0.016282201</Real>
+    <Real>-0.196504</Real>
+    <Real>-0.23710801</Real>
+    <Real>-0.0406349</Real>
+    <Real>-0.11625</Real>
+    <Real>-0.115526</Real>
+    <Real>0.035594702</Real>
+    <Real>-0.100031</Real>
+    <Real>-0.131438</Real>
+    <Real>-0.148066</Real>
+    <Real>-0.246914</Real>
+    <Real>-0.228278</Real>
+    <Real>-0.128664</Real>
+    <Real>-0.151379</Real>
+    <Real>-0.120204</Real>
+    <Real>-0.20564</Real>
+    <Real>-0.19493499</Real>
+    <Real>-0.223316</Real>
+    <Real>-0.20992599</Real>
+    <Real>-0.293475</Real>
+    <Real>-0.181631</Real>
+    <Real>-0.15154199</Real>
+    <Real>-0.18523701</Real>
+    <Real>-0.277973</Real>
+    <Real>-0.212514</Real>
+    <Real>-0.25714999</Real>
+    <Real>-0.106606</Real>
+    <Real>-0.17149</Real>
+    <Real>-0.28705299</Real>
+    <Real>-0.17783999</Real>
+    <Real>-0.288715</Real>
+    <Real>-0.13793799</Real>
+    <Real>-0.15577</Real>
+    <Real>-0.101648</Real>
+    <Real>-0.29286501</Real>
+    <Real>-0.15349799</Real>
+    <Real>-0.196582</Real>
+    <Real>-0.151655</Real>
+    <Real>-0.105669</Real>
+    <Real>-0.233206</Real>
+    <Real>-0.205688</Real>
+    <Real>-0.120301</Real>
+    <Real>-0.30407101</Real>
+    <Real>-0.27380499</Real>
+    <Real>-0.0567232</Real>
+    <Real>-0.26257399</Real>
+    <Real>-0.213572</Real>
+    <Real>-0.188062</Real>
+    <Real>-0.234014</Real>
+    <Real>-0.147396</Real>
+    <Real>-0.130597</Real>
+    <Real>-0.127922</Real>
+    <Real>-0.16339099</Real>
+    <Real>-0.141241</Real>
+    <Real>-0.14472499</Real>
+    <Real>-0.10392</Real>
+    <Real>-0.0510807</Real>
+    <Real>-0.247492</Real>
+    <Real>-0.058272298</Real>
+    <Real>-0.0082769198</Real>
+    <Real>-0.25879499</Real>
+    <Real>-0.19123399</Real>
+    <Real>0.077861302</Real>
+    <Real>-0.074387997</Real>
+    <Real>-0.142011</Real>
+    <Real>0.081611998</Real>
+    <Real>-0.12735599</Real>
+    <Real>-0.153745</Real>
+    <Real>0.078688301</Real>
+    <Real>-0.12088</Real>
+    <Real>-0.122613</Real>
+    <Real>0.067525104</Real>
+    <Real>-0.13781101</Real>
+    <Real>0.023367999</Real>
+    <Real>0.057603098</Real>
+  </Sequence>
+  <Real Name="Integral">-12.673485642531887</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacVector.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacVector.xml
new file mode 100644 (file)
index 0000000..d318d51
--- /dev/null
@@ -0,0 +1,509 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="AutocorrelationFunction">
+    <Int Name="Length">501</Int>
+    <Real>1</Real>
+    <Real>0.91440845</Real>
+    <Real>0.89127165</Real>
+    <Real>0.85387266</Real>
+    <Real>0.81370103</Real>
+    <Real>0.7681002</Real>
+    <Real>0.70884496</Real>
+    <Real>0.65127754</Real>
+    <Real>0.58396322</Real>
+    <Real>0.50845456</Real>
+    <Real>0.43051061</Real>
+    <Real>0.35105249</Real>
+    <Real>0.26587203</Real>
+    <Real>0.18143819</Real>
+    <Real>0.097567506</Real>
+    <Real>0.015512385</Real>
+    <Real>-0.068423927</Real>
+    <Real>-0.1456465</Real>
+    <Real>-0.22284648</Real>
+    <Real>-0.29907748</Real>
+    <Real>-0.37475094</Real>
+    <Real>-0.4380517</Real>
+    <Real>-0.49662268</Real>
+    <Real>-0.55154026</Real>
+    <Real>-0.60047692</Real>
+    <Real>-0.64397019</Real>
+    <Real>-0.67695993</Real>
+    <Real>-0.69747227</Real>
+    <Real>-0.71946371</Real>
+    <Real>-0.73064023</Real>
+    <Real>-0.73969084</Real>
+    <Real>-0.73910058</Real>
+    <Real>-0.72273451</Real>
+    <Real>-0.70480442</Real>
+    <Real>-0.68460542</Real>
+    <Real>-0.65121585</Real>
+    <Real>-0.61127657</Real>
+    <Real>-0.56959647</Real>
+    <Real>-0.53186774</Real>
+    <Real>-0.47233477</Real>
+    <Real>-0.42289308</Real>
+    <Real>-0.36013916</Real>
+    <Real>-0.30238953</Real>
+    <Real>-0.23851043</Real>
+    <Real>-0.17228492</Real>
+    <Real>-0.10760929</Real>
+    <Real>-0.038677685</Real>
+    <Real>0.023924842</Real>
+    <Real>0.085734844</Real>
+    <Real>0.14554502</Real>
+    <Real>0.21178007</Real>
+    <Real>0.26366264</Real>
+    <Real>0.31547186</Real>
+    <Real>0.36479235</Real>
+    <Real>0.41372058</Real>
+    <Real>0.45014268</Real>
+    <Real>0.48719069</Real>
+    <Real>0.51477271</Real>
+    <Real>0.54144377</Real>
+    <Real>0.55743951</Real>
+    <Real>0.56827539</Real>
+    <Real>0.57417756</Real>
+    <Real>0.57521474</Real>
+    <Real>0.57242984</Real>
+    <Real>0.56181103</Real>
+    <Real>0.54661202</Real>
+    <Real>0.5273785</Real>
+    <Real>0.49807823</Real>
+    <Real>0.46791199</Real>
+    <Real>0.43094185</Real>
+    <Real>0.39116937</Real>
+    <Real>0.34865311</Real>
+    <Real>0.30475527</Real>
+    <Real>0.26447845</Real>
+    <Real>0.20973703</Real>
+    <Real>0.16015707</Real>
+    <Real>0.10805874</Real>
+    <Real>0.059454329</Real>
+    <Real>0.0076480238</Real>
+    <Real>-0.045675594</Real>
+    <Real>-0.089126058</Real>
+    <Real>-0.14246953</Real>
+    <Real>-0.18825532</Real>
+    <Real>-0.22974341</Real>
+    <Real>-0.27582318</Real>
+    <Real>-0.30692092</Real>
+    <Real>-0.34222001</Real>
+    <Real>-0.37205994</Real>
+    <Real>-0.39867413</Real>
+    <Real>-0.42049485</Real>
+    <Real>-0.43268493</Real>
+    <Real>-0.446363</Real>
+    <Real>-0.45471677</Real>
+    <Real>-0.45743033</Real>
+    <Real>-0.45754004</Real>
+    <Real>-0.44663361</Real>
+    <Real>-0.43691492</Real>
+    <Real>-0.42143744</Real>
+    <Real>-0.39964595</Real>
+    <Real>-0.37948313</Real>
+    <Real>-0.35078076</Real>
+    <Real>-0.32291207</Real>
+    <Real>-0.28617722</Real>
+    <Real>-0.25431877</Real>
+    <Real>-0.21413048</Real>
+    <Real>-0.17472994</Real>
+    <Real>-0.13722105</Real>
+    <Real>-0.0940689</Real>
+    <Real>-0.050582096</Real>
+    <Real>-0.011372223</Real>
+    <Real>0.033095215</Real>
+    <Real>0.064681761</Real>
+    <Real>0.10605592</Real>
+    <Real>0.13676096</Real>
+    <Real>0.17619975</Real>
+    <Real>0.20634755</Real>
+    <Real>0.23424256</Real>
+    <Real>0.26192936</Real>
+    <Real>0.28315401</Real>
+    <Real>0.31159228</Real>
+    <Real>0.32296148</Real>
+    <Real>0.3337082</Real>
+    <Real>0.3472271</Real>
+    <Real>0.35520938</Real>
+    <Real>0.35884556</Real>
+    <Real>0.35598138</Real>
+    <Real>0.36070585</Real>
+    <Real>0.34978899</Real>
+    <Real>0.33616209</Real>
+    <Real>0.32133636</Real>
+    <Real>0.30463791</Real>
+    <Real>0.28434399</Real>
+    <Real>0.26060301</Real>
+    <Real>0.23513913</Real>
+    <Real>0.21211421</Real>
+    <Real>0.18200785</Real>
+    <Real>0.15506685</Real>
+    <Real>0.11292174</Real>
+    <Real>0.08485233</Real>
+    <Real>0.048554849</Real>
+    <Real>0.015430034</Real>
+    <Real>-0.0053237719</Real>
+    <Real>-0.043886948</Real>
+    <Real>-0.069251105</Real>
+    <Real>-0.099874027</Real>
+    <Real>-0.1318848</Real>
+    <Real>-0.15587749</Real>
+    <Real>-0.18213047</Real>
+    <Real>-0.19872877</Real>
+    <Real>-0.22116253</Real>
+    <Real>-0.23839074</Real>
+    <Real>-0.24964274</Real>
+    <Real>-0.25999296</Real>
+    <Real>-0.26915544</Real>
+    <Real>-0.28208914</Real>
+    <Real>-0.28375041</Real>
+    <Real>-0.2840305</Real>
+    <Real>-0.28654379</Real>
+    <Real>-0.27391881</Real>
+    <Real>-0.26717883</Real>
+    <Real>-0.25783545</Real>
+    <Real>-0.24391536</Real>
+    <Real>-0.23143035</Real>
+    <Real>-0.21355876</Real>
+    <Real>-0.19516303</Real>
+    <Real>-0.17305651</Real>
+    <Real>-0.14851433</Real>
+    <Real>-0.13391782</Real>
+    <Real>-0.10106573</Real>
+    <Real>-0.079669952</Real>
+    <Real>-0.054322001</Real>
+    <Real>-0.022567146</Real>
+    <Real>-0.0082916291</Real>
+    <Real>0.028239559</Real>
+    <Real>0.044842608</Real>
+    <Real>0.066723041</Real>
+    <Real>0.086818486</Real>
+    <Real>0.11206019</Real>
+    <Real>0.13034853</Real>
+    <Real>0.14292336</Real>
+    <Real>0.16384037</Real>
+    <Real>0.17437287</Real>
+    <Real>0.19422586</Real>
+    <Real>0.19642359</Real>
+    <Real>0.20773162</Real>
+    <Real>0.21621291</Real>
+    <Real>0.22017281</Real>
+    <Real>0.21870746</Real>
+    <Real>0.22144818</Real>
+    <Real>0.21968257</Real>
+    <Real>0.21284904</Real>
+    <Real>0.20909898</Real>
+    <Real>0.20217142</Real>
+    <Real>0.19360588</Real>
+    <Real>0.18018678</Real>
+    <Real>0.16507152</Real>
+    <Real>0.14102207</Real>
+    <Real>0.13159586</Real>
+    <Real>0.11218439</Real>
+    <Real>0.090035476</Real>
+    <Real>0.069503993</Real>
+    <Real>0.054288179</Real>
+    <Real>0.034861948</Real>
+    <Real>0.013234816</Real>
+    <Real>-0.0047988398</Real>
+    <Real>-0.024740862</Real>
+    <Real>-0.042112309</Real>
+    <Real>-0.057106286</Real>
+    <Real>-0.079133794</Real>
+    <Real>-0.08531253</Real>
+    <Real>-0.10183473</Real>
+    <Real>-0.11679</Real>
+    <Real>-0.13124378</Real>
+    <Real>-0.13978031</Real>
+    <Real>-0.15192363</Real>
+    <Real>-0.15962306</Real>
+    <Real>-0.16721499</Real>
+    <Real>-0.17583407</Real>
+    <Real>-0.17053062</Real>
+    <Real>-0.17783985</Real>
+    <Real>-0.17420124</Real>
+    <Real>-0.16439037</Real>
+    <Real>-0.16967009</Real>
+    <Real>-0.16545986</Real>
+    <Real>-0.15178227</Real>
+    <Real>-0.1513456</Real>
+    <Real>-0.13972749</Real>
+    <Real>-0.12844835</Real>
+    <Real>-0.11278458</Real>
+    <Real>-0.10008006</Real>
+    <Real>-0.084673822</Real>
+    <Real>-0.071988769</Real>
+    <Real>-0.055301242</Real>
+    <Real>-0.044846795</Real>
+    <Real>-0.024612129</Real>
+    <Real>-0.012670649</Real>
+    <Real>0.0064235702</Real>
+    <Real>0.017517105</Real>
+    <Real>0.032193232</Real>
+    <Real>0.05088919</Real>
+    <Real>0.059888519</Real>
+    <Real>0.073218867</Real>
+    <Real>0.084005043</Real>
+    <Real>0.097417012</Real>
+    <Real>0.11064502</Real>
+    <Real>0.11908618</Real>
+    <Real>0.12669091</Real>
+    <Real>0.12785465</Real>
+    <Real>0.13891017</Real>
+    <Real>0.14016822</Real>
+    <Real>0.15007298</Real>
+    <Real>4.4267403e-05</Real>
+    <Real>4.3514352e-05</Real>
+    <Real>4.3138727e-05</Real>
+    <Real>4.1891646e-05</Real>
+    <Real>4.0179297e-05</Real>
+    <Real>3.8032213e-05</Real>
+    <Real>3.7556416e-05</Real>
+    <Real>3.5218971e-05</Real>
+    <Real>3.1478037e-05</Real>
+    <Real>3.0895699e-05</Real>
+    <Real>2.615025e-05</Real>
+    <Real>2.0906495e-05</Real>
+    <Real>1.7488654e-05</Real>
+    <Real>1.3209424e-05</Real>
+    <Real>9.7491848e-06</Real>
+    <Real>6.3581501e-06</Real>
+    <Real>5.6303825e-06</Real>
+    <Real>-5.1143962e-07</Real>
+    <Real>-4.6430905e-06</Real>
+    <Real>-8.4661779e-06</Real>
+    <Real>-1.0448402e-05</Real>
+    <Real>-1.6193704e-05</Real>
+    <Real>-1.857411e-05</Real>
+    <Real>-2.250258e-05</Real>
+    <Real>-2.3523124e-05</Real>
+    <Real>-2.7104035e-05</Real>
+    <Real>-2.8832133e-05</Real>
+    <Real>-2.9649824e-05</Real>
+    <Real>-3.12257e-05</Real>
+    <Real>-3.2669741e-05</Real>
+    <Real>-3.3304954e-05</Real>
+    <Real>-3.3183347e-05</Real>
+    <Real>-3.4332639e-05</Real>
+    <Real>-3.3677767e-05</Real>
+    <Real>-3.4504159e-05</Real>
+    <Real>-3.454684e-05</Real>
+    <Real>-3.2467542e-05</Real>
+    <Real>-2.9868665e-05</Real>
+    <Real>-2.9505636e-05</Real>
+    <Real>-2.6500937e-05</Real>
+    <Real>-2.6333106e-05</Real>
+    <Real>-2.3109949e-05</Real>
+    <Real>-2.140675e-05</Real>
+    <Real>-1.6538143e-05</Real>
+    <Real>-1.4951454e-05</Real>
+    <Real>-1.0329346e-05</Real>
+    <Real>-8.6922209e-06</Real>
+    <Real>-6.4748251e-06</Real>
+    <Real>-2.4234089e-06</Real>
+    <Real>2.1927521e-07</Real>
+    <Real>2.7016404e-06</Real>
+    <Real>3.5660794e-06</Real>
+    <Real>6.7710325e-06</Real>
+    <Real>1.154716e-05</Real>
+    <Real>1.27539e-05</Real>
+    <Real>1.4957743e-05</Real>
+    <Real>1.8768704e-05</Real>
+    <Real>1.983804e-05</Real>
+    <Real>2.258397e-05</Real>
+    <Real>2.3245073e-05</Real>
+    <Real>2.5949555e-05</Real>
+    <Real>2.7714603e-05</Real>
+    <Real>2.4125953e-05</Real>
+    <Real>2.7313827e-05</Real>
+    <Real>2.6500267e-05</Real>
+    <Real>2.8872726e-05</Real>
+    <Real>2.8494722e-05</Real>
+    <Real>2.8652294e-05</Real>
+    <Real>2.6291838e-05</Real>
+    <Real>2.3836281e-05</Real>
+    <Real>2.2856551e-05</Real>
+    <Real>2.24215e-05</Real>
+    <Real>2.2928167e-05</Real>
+    <Real>2.0600462e-05</Real>
+    <Real>2.1569322e-05</Real>
+    <Real>1.8669114e-05</Real>
+    <Real>1.6274531e-05</Real>
+    <Real>1.3573073e-05</Real>
+    <Real>1.2755655e-05</Real>
+    <Real>9.1842421e-06</Real>
+    <Real>4.9424475e-06</Real>
+    <Real>1.9999163e-06</Real>
+    <Real>1.2401867e-06</Real>
+    <Real>-3.0244464e-06</Real>
+    <Real>-7.6198962e-06</Real>
+    <Real>-9.8329774e-06</Real>
+    <Real>-8.8280267e-06</Real>
+    <Real>-1.377236e-05</Real>
+    <Real>-1.6982995e-05</Real>
+    <Real>-1.9108473e-05</Real>
+    <Real>-2.0853575e-05</Real>
+    <Real>-2.3638708e-05</Real>
+    <Real>-2.4330864e-05</Real>
+    <Real>-2.3607576e-05</Real>
+    <Real>-2.3350785e-05</Real>
+    <Real>-2.4861311e-05</Real>
+    <Real>-2.4024377e-05</Real>
+    <Real>-2.7649214e-05</Real>
+    <Real>-3.0116586e-05</Real>
+    <Real>-2.7083521e-05</Real>
+    <Real>-2.6461454e-05</Real>
+    <Real>-2.5706378e-05</Real>
+    <Real>-2.3319637e-05</Real>
+    <Real>-2.2089596e-05</Real>
+    <Real>-1.7878658e-05</Real>
+    <Real>-1.7124203e-05</Real>
+    <Real>-1.5375375e-05</Real>
+    <Real>-1.5521959e-05</Real>
+    <Real>-1.172509e-05</Real>
+    <Real>-9.1009997e-06</Real>
+    <Real>-5.6435597e-06</Real>
+    <Real>-2.9174676e-06</Real>
+    <Real>-5.4268908e-06</Real>
+    <Real>-1.5508874e-06</Real>
+    <Real>-3.7975212e-07</Real>
+    <Real>3.1173399e-06</Real>
+    <Real>1.9381382e-06</Real>
+    <Real>5.5445184e-06</Real>
+    <Real>6.774098e-06</Real>
+    <Real>8.9054111e-06</Real>
+    <Real>1.0997211e-05</Real>
+    <Real>1.4307585e-05</Real>
+    <Real>1.3101091e-05</Real>
+    <Real>1.5396869e-05</Real>
+    <Real>1.3836742e-05</Real>
+    <Real>1.4298585e-05</Real>
+    <Real>1.65646e-05</Real>
+    <Real>1.5446933e-05</Real>
+    <Real>1.9028628e-05</Real>
+    <Real>2.0577343e-05</Real>
+    <Real>1.6241767e-05</Real>
+    <Real>1.6588914e-05</Real>
+    <Real>1.6793663e-05</Real>
+    <Real>1.5231977e-05</Real>
+    <Real>1.3574629e-05</Real>
+    <Real>1.3824551e-05</Real>
+    <Real>1.3580589e-05</Real>
+    <Real>8.8718243e-06</Real>
+    <Real>8.9766982e-06</Real>
+    <Real>4.874571e-06</Real>
+    <Real>6.1740734e-06</Real>
+    <Real>4.3778728e-06</Real>
+    <Real>3.0633016e-06</Real>
+    <Real>2.650128e-06</Real>
+    <Real>4.4499197e-06</Real>
+    <Real>5.2487553e-07</Real>
+    <Real>3.844505e-06</Real>
+    <Real>8.3970571e-07</Real>
+    <Real>-4.0378814e-06</Real>
+    <Real>-4.2863321e-06</Real>
+    <Real>-3.9477163e-06</Real>
+    <Real>-5.5808941e-06</Real>
+    <Real>-8.159157e-06</Real>
+    <Real>-1.07823e-05</Real>
+    <Real>-1.0445928e-05</Real>
+    <Real>-1.4758529e-05</Real>
+    <Real>-1.5891597e-05</Real>
+    <Real>-1.6962238e-05</Real>
+    <Real>-1.6818865e-05</Real>
+    <Real>-1.3153352e-05</Real>
+    <Real>-1.3562746e-05</Real>
+    <Real>-1.536158e-05</Real>
+    <Real>-1.6916658e-05</Real>
+    <Real>-1.5912401e-05</Real>
+    <Real>-1.9311357e-05</Real>
+    <Real>-1.3812277e-05</Real>
+    <Real>-1.7308477e-05</Real>
+    <Real>-1.1393254e-05</Real>
+    <Real>-6.9415369e-06</Real>
+    <Real>-8.5329793e-06</Real>
+    <Real>-7.3732735e-06</Real>
+    <Real>-8.2779943e-06</Real>
+    <Real>-4.1989624e-06</Real>
+    <Real>-4.0598088e-06</Real>
+    <Real>-6.2781332e-06</Real>
+    <Real>-6.1900923e-06</Real>
+    <Real>-9.3725657e-06</Real>
+    <Real>-9.9827339e-06</Real>
+    <Real>-9.6235508e-06</Real>
+    <Real>-4.7038488e-06</Real>
+    <Real>-3.4777854e-06</Real>
+    <Real>-2.7908015e-06</Real>
+    <Real>1.7161137e-06</Real>
+    <Real>2.1103369e-06</Real>
+    <Real>1.6298396e-06</Real>
+    <Real>5.1353272e-06</Real>
+    <Real>9.7297398e-06</Real>
+    <Real>7.9292831e-06</Real>
+    <Real>1.0491432e-05</Real>
+    <Real>8.7098369e-06</Real>
+    <Real>1.1306504e-05</Real>
+    <Real>1.2767204e-05</Real>
+    <Real>1.0523996e-05</Real>
+    <Real>1.5876185e-05</Real>
+    <Real>1.8240517e-05</Real>
+    <Real>1.7410239e-05</Real>
+    <Real>1.8709565e-05</Real>
+    <Real>2.0682788e-05</Real>
+    <Real>2.2414559e-05</Real>
+    <Real>2.3641453e-05</Real>
+    <Real>2.9956356e-05</Real>
+    <Real>3.1942258e-05</Real>
+    <Real>3.2165972e-05</Real>
+    <Real>2.3073231e-05</Real>
+    <Real>2.1864589e-05</Real>
+    <Real>2.3307522e-05</Real>
+    <Real>2.6105658e-05</Real>
+    <Real>3.0764437e-05</Real>
+    <Real>2.5258372e-05</Real>
+    <Real>2.4398061e-05</Real>
+    <Real>1.5440721e-05</Real>
+    <Real>7.2866023e-06</Real>
+    <Real>4.1072926e-06</Real>
+    <Real>1.3465999e-05</Real>
+    <Real>9.5875193e-06</Real>
+    <Real>3.303629e-06</Real>
+    <Real>-9.6435542e-06</Real>
+    <Real>-1.4834303e-05</Real>
+    <Real>-1.3345806e-05</Real>
+    <Real>-1.2496928e-05</Real>
+    <Real>-1.2373329e-05</Real>
+    <Real>-1.9174164e-05</Real>
+    <Real>-2.2750348e-05</Real>
+    <Real>-1.0412362e-05</Real>
+    <Real>-7.1453283e-06</Real>
+    <Real>-5.0996732e-06</Real>
+    <Real>-1.4278352e-06</Real>
+    <Real>1.091708e-05</Real>
+    <Real>6.6890452e-06</Real>
+    <Real>2.0174368e-05</Real>
+    <Real>1.0472003e-05</Real>
+    <Real>4.7418193e-06</Real>
+    <Real>9.2978889e-06</Real>
+    <Real>4.5979341e-06</Real>
+    <Real>1.164395e-05</Real>
+    <Real>-1.1824308e-05</Real>
+    <Real>-1.2670253e-05</Real>
+    <Real>-7.1008421e-06</Real>
+    <Real>4.0426371e-06</Real>
+    <Real>9.691882e-06</Real>
+    <Real>3.4888384e-05</Real>
+    <Real>2.3447481e-05</Real>
+    <Real>6.0634087e-05</Real>
+    <Real>4.6600537e-05</Real>
+    <Real>3.8806083e-05</Real>
+    <Real>4.0546623e-05</Real>
+    <Real>5.6960853e-05</Real>
+    <Real>1.7836719e-05</Real>
+    <Real>-8.4526189e-05</Real>
+    <Real>-0.00019142308</Real>
+  </Sequence>
+  <Real Name="Integral">0.54968381075777017</Real>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERF.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERF.xml
new file mode 100644 (file)
index 0000000..f968c0c
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">4</Int>
+    <Real>7.8450705641969325</Real>
+    <Real>2.6181457557146546</Real>
+    <Real>-124.26093946666471</Real>
+    <Real>10.991394787222672</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERREST.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERREST.xml
new file mode 100644 (file)
index 0000000..05f9939
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">3</Int>
+    <Real>3.7998256591705597</Real>
+    <Real>0.82432886141340755</Real>
+    <Real>1.5224332184919882</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP1.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP1.xml
new file mode 100644 (file)
index 0000000..b39c373
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">1</Int>
+    <Real>28.790295709638542</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP2.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP2.xml
new file mode 100644 (file)
index 0000000..e30564e
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">2</Int>
+    <Real>38.159752015476776</Real>
+    <Real>0.7956683286568571</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP3.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP3.xml
new file mode 100644 (file)
index 0000000..74d4d3a
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">3</Int>
+    <Real>49.669368440495347</Real>
+    <Real>0.58492964998546348</Real>
+    <Real>6.4814246273214478</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP5.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP5.xml
new file mode 100644 (file)
index 0000000..9dd9a8b
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">5</Int>
+    <Real>0.4874505859136089</Real>
+    <Real>5.593512789216291</Real>
+    <Real>0.5859548866294173</Real>
+    <Real>50.639858390563305</Real>
+    <Real>-0.002429583757534859</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP7.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP7.xml
new file mode 100644 (file)
index 0000000..20c5871
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">7</Int>
+    <Real>0.5512395081799536</Real>
+    <Real>6.5183422896301373</Real>
+    <Real>-0.67296121974350642</Real>
+    <Real>31.927951035981206</Real>
+    <Real>1.186708933085455</Real>
+    <Real>42.008654192804514</Real>
+    <Real>-0.0015455112108527936</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP9.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP9.xml
new file mode 100644 (file)
index 0000000..e9ecccc
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">9</Int>
+    <Real>15.957817686967116</Real>
+    <Real>221006.78653735726</Real>
+    <Real>114.88630569000553</Real>
+    <Real>-33734.142061366547</Real>
+    <Real>7.6914607460936715</Real>
+    <Real>1876.2303193471271</Real>
+    <Real>0.75265207702909753</Real>
+    <Real>24.572552704802391</Real>
+    <Real>-138.40801944191745</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnPRES.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnPRES.xml
new file mode 100644 (file)
index 0000000..fe3d48e
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">6</Int>
+    <Real>0.2214172263311579</Real>
+    <Real>10.066519430470473</Real>
+    <Real>3.7707829256907712</Real>
+    <Real>0.72109681793857272</Real>
+    <Real>0.49886880345093437</Real>
+    <Real>1.000154618776814</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnVAC.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnVAC.xml
new file mode 100644 (file)
index 0000000..35f0f01
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <Sequence Name="result">
+    <Int Name="Length">2</Int>
+    <Real>1.3759034165632673</Real>
+    <Real>0.20054113811854915</Real>
+  </Sequence>
+</ReferenceData>
diff --git a/src/gromacs/correlationfunctions/tests/testCOS3.xvg b/src/gromacs/correlationfunctions/tests/testCOS3.xvg
new file mode 100644 (file)
index 0000000..6f41600
--- /dev/null
@@ -0,0 +1,501 @@
+0 0.980215 0.84786 0.55111
+1 1.00563 0.766732 0.345733
+2 0.901045 0.646807 0.342314
+3 0.911231 0.637477 0.183936
+4 0.849712 0.50242 0.0810423
+5 0.77696 0.493325 0.0698848
+6 0.755667 0.444941 0.00746138
+7 0.724674 0.250751 -0.0151029
+8 0.663689 0.319373 -0.210542
+9 0.515147 0.109105 -0.192153
+10 0.579059 0.151557 -0.32202
+11 0.486462 0.0196987 -0.367642
+12 0.306271 -0.117139 -0.533263
+13 0.286981 -0.262968 -0.578647
+14 0.128506 -0.288335 -0.520779
+15 0.106801 -0.336168 -0.54033
+16 -0.0342238 -0.438876 -0.690429
+17 -0.189242 -0.517065 -0.733008
+18 -0.102822 -0.533843 -0.761297
+19 -0.286696 -0.492504 -0.764118
+20 -0.312994 -0.626441 -0.694044
+21 -0.433176 -0.582163 -0.738222
+22 -0.473521 -0.753763 -0.794075
+23 -0.514416 -0.784329 -0.710094
+24 -0.602884 -0.627913 -0.693283
+25 -0.701922 -0.788765 -0.697599
+26 -0.624715 -0.803903 -0.603359
+27 -0.633136 -0.62592 -0.542414
+28 -0.748294 -0.610642 -0.525884
+29 -0.681519 -0.726425 -0.554219
+30 -0.818801 -0.736255 -0.477194
+31 -0.779091 -0.683083 -0.439122
+32 -0.799431 -0.537976 -0.386361
+33 -0.74211 -0.458832 -0.25837
+34 -0.734999 -0.586292 -0.291565
+35 -0.752422 -0.409693 -0.224274
+36 -0.567355 -0.318048 -0.042563
+37 -0.48962 -0.259037 0.0429618
+38 -0.631321 -0.218146 -0.0215977
+39 -0.510246 -0.104216 0.203877
+40 -0.467046 -0.120795 0.271951
+41 -0.354142 -0.147802 0.153328
+42 -0.35987 0.0901972 0.278751
+43 -0.218068 0.0617962 0.315153
+44 -0.251885 0.0498296 0.449551
+45 -0.0739778 0.10528 0.330027
+46 -0.158898 0.306042 0.352122
+47 -0.0354126 0.365281 0.461546
+48 0.0111098 0.344993 0.553061
+49 0.0293386 0.465325 0.51471
+50 0.263435 0.412229 0.581141
+51 0.26077 0.489539 0.532995
+52 0.191436 0.406404 0.59817
+53 0.239305 0.500526 0.455499
+54 0.393089 0.560054 0.428476
+55 0.459268 0.625471 0.586418
+56 0.506983 0.521062 0.464051
+57 0.548327 0.567689 0.40065
+58 0.409701 0.619339 0.369207
+59 0.532969 0.56424 0.353377
+60 0.52379 0.565401 0.446169
+61 0.448233 0.514478 0.350512
+62 0.596133 0.396408 0.225304
+63 0.437427 0.400799 0.245919
+64 0.566243 0.388444 0.133041
+65 0.549138 0.427644 0.253539
+66 0.44934 0.344726 0.191529
+67 0.562821 0.276727 0.122273
+68 0.521943 0.253548 -0.0264084
+69 0.43181 0.298105 0.00961045
+70 0.319108 0.0887345 -0.123015
+71 0.366678 0.19142 -0.058703
+72 0.233041 0.111129 -0.126821
+73 0.29502 -0.0515529 -0.179635
+74 0.190305 0.0720675 -0.211369
+75 0.0935705 -0.146145 -0.316849
+76 0.0717608 -0.0630276 -0.268758
+77 0.0181038 -0.0806319 -0.393499
+78 0.0992837 -0.160283 -0.363726
+79 -0.075659 -0.169269 -0.390363
+80 -0.0234965 -0.246341 -0.275014
+81 -0.110975 -0.346189 -0.364672
+82 -0.0849593 -0.408301 -0.351602
+83 -0.0912708 -0.434549 -0.294002
+84 -0.177398 -0.39839 -0.48773
+85 -0.172094 -0.412093 -0.408075
+86 -0.303234 -0.315041 -0.367646
+87 -0.226801 -0.362151 -0.378527
+88 -0.413375 -0.428706 -0.370096
+89 -0.397034 -0.434736 -0.357839
+90 -0.315822 -0.398561 -0.209665
+91 -0.403451 -0.454814 -0.297493
+92 -0.324802 -0.386527 -0.19479
+93 -0.362774 -0.333757 -0.282111
+94 -0.394546 -0.406385 -0.114484
+95 -0.420013 -0.403752 -0.206511
+96 -0.309481 -0.341284 -0.120096
+97 -0.453416 -0.310777 -0.119248
+98 -0.43383 -0.175929 0.0339822
+99 -0.339264 -0.195425 -0.0718497
+100 -0.371026 -0.216218 0.0139881
+101 -0.351084 -0.138989 0.0523454
+102 -0.325 -0.148216 0.0426766
+103 -0.281812 -0.126936 0.0222029
+104 -0.287808 -0.0716632 0.138222
+105 -0.185139 -0.0152797 0.230471
+106 -0.221557 0.0130399 0.208427
+107 -0.127197 0.00648877 0.236035
+108 -0.140938 0.192555 0.148371
+109 -0.121454 0.0739209 0.323821
+110 -0.0753036 0.187121 0.197079
+111 0.0884694 0.14371 0.346057
+112 0.0721952 0.120678 0.371426
+113 0.134703 0.161566 0.344913
+114 0.110235 0.223032 0.215381
+115 0.151157 0.337161 0.344783
+116 0.154284 0.217981 0.318494
+117 0.270696 0.323202 0.201975
+118 0.13255 0.190122 0.22415
+119 0.337384 0.24034 0.292528
+120 0.231969 0.26378 0.303501
+121 0.23063 0.299878 0.157845
+122 0.276788 0.368257 0.193731
+123 0.21615 0.207757 0.136564
+124 0.262226 0.210265 0.130028
+125 0.206059 0.152711 0.195077
+126 0.297343 0.237324 0.118121
+127 0.293289 0.226635 0.0750109
+128 0.265778 0.119711 0.106759
+129 0.27516 0.105753 0.0930857
+130 0.259443 0.195959 0.0504844
+131 0.237343 0.142589 -0.0896435
+132 0.282426 0.148966 -0.0323091
+133 0.160483 0.0359481 -0.0785661
+134 0.218772 0.129273 -0.159827
+135 0.0853457 0.116802 -0.0417486
+136 0.20506 0.0823463 -0.0335992
+137 0.094616 0.0199207 -0.0462484
+138 0.0246508 -0.0416026 -0.0983342
+139 0.0639901 -0.139287 -0.242319
+140 0.0249959 -0.180938 -0.249294
+141 0.0329462 -0.159826 -0.235841
+142 0.0162822 -0.196504 -0.237108
+143 -0.0406349 -0.11625 -0.115526
+144 0.0355947 -0.100031 -0.131438
+145 -0.148066 -0.246914 -0.228278
+146 -0.128664 -0.151379 -0.120204
+147 -0.20564 -0.194935 -0.223316
+148 -0.209926 -0.293475 -0.181631
+149 -0.151542 -0.185237 -0.277973
+150 -0.212514 -0.25715 -0.106606
+151 -0.17149 -0.287053 -0.17784
+152 -0.288715 -0.137938 -0.15577
+153 -0.101648 -0.292865 -0.153498
+154 -0.196582 -0.151655 -0.105669
+155 -0.233206 -0.205688 -0.120301
+156 -0.304071 -0.273805 -0.0567232
+157 -0.262574 -0.213572 -0.188062
+158 -0.234014 -0.147396 -0.130597
+159 -0.127922 -0.163391 -0.141241
+160 -0.144725 -0.10392 -0.0510807
+161 -0.247492 -0.0582723 -0.00827692
+162 -0.258795 -0.191234 0.0778613
+163 -0.074388 -0.142011 0.081612
+164 -0.127356 -0.153745 0.0786883
+165 -0.12088 -0.122613 0.0675251
+166 -0.137811 0.023368 0.0576031
+167 -0.189745 -0.0722396 0.018102
+168 -0.0595371 -0.0306057 0.0829234
+169 -0.078322 0.0656503 0.0512902
+170 -0.132692 -0.0462057 0.0294912
+171 -0.0740977 0.073898 0.19823
+172 -0.0558499 0.0752766 0.142552
+173 0.0759637 0.123402 0.232148
+174 -0.0360002 0.145455 0.160842
+175 0.0436169 0.160745 0.162525
+176 0.0858365 0.100668 0.179054
+177 0.13627 0.0892889 0.0655269
+178 0.161949 0.17863 0.197206
+179 0.106877 0.177517 0.0546804
+180 0.0593105 0.149241 0.142748
+181 0.214126 0.0766684 0.0810017
+182 0.0547008 0.21327 0.177475
+183 0.0717283 0.0736023 0.154865
+184 0.191727 0.172906 0.119034
+185 0.14478 0.087557 0.0742026
+186 0.23908 0.132729 0.0355024
+187 0.203703 0.073267 0.0143013
+188 0.122586 0.213276 0.0651469
+189 0.0835698 0.0487019 0.133766
+190 0.0917354 0.169554 -0.041977
+191 0.113556 0.110627 0.110535
+192 0.183147 0.0180818 -0.0115564
+193 0.128454 0.100595 0.0386712
+194 0.163301 0.132653 -0.0680352
+195 0.196114 0.152816 0.0859278
+196 0.0286079 0.0400758 -0.0260642
+197 0.0880536 0.0830662 -0.0696107
+198 0.0915375 0.0893299 -0.0358353
+199 0.0509963 -0.0207323 -0.143666
+200 0.0416355 -0.092149 -0.0664544
+201 0.0468225 0.0383251 -0.0613309
+202 0.0107274 0.0410744 -0.0949562
+203 0.00933228 -0.0911049 -0.160811
+204 0.0217787 -0.144363 -0.101096
+205 0.0698741 -0.16287 -0.175699
+206 -0.0222541 -0.0185677 -0.0613003
+207 -0.10017 -0.0874568 -0.183911
+208 -0.124739 -0.176242 -0.0730185
+209 0.00860095 -0.158835 -0.0638301
+210 -0.0753048 -0.0403158 -0.0791765
+211 -0.121974 -0.0898573 -0.160381
+212 -0.0300112 -0.161479 -0.106232
+213 -0.0072594 -0.118346 -0.013073
+214 -0.140189 -0.123004 -0.1696
+215 -0.0339676 -0.0278884 -0.147712
+216 -0.110571 -0.120261 -0.0271705
+217 -0.137256 -0.0305097 -0.0102887
+218 -0.104694 -0.0970638 -0.0492807
+219 -0.15725 -0.0387797 -0.0991524
+220 -0.0535873 -0.189848 -0.0629756
+221 -0.0447722 -0.113558 0.00994687
+222 -0.0972935 -0.0299721 -0.118869
+223 -0.143216 -0.150272 -0.0945565
+224 -0.0342238 0.0223487 0.0838931
+225 -0.189588 0.0427961 0.0480686
+226 -0.150381 -0.0581302 -0.00364323
+227 -0.138787 0.0093412 -0.0574481
+228 -0.153102 -0.0615975 0.116143
+229 -0.060412 -0.0513939 -0.0577417
+230 0.0202902 -0.0246957 0.0801256
+231 -0.0200033 0.0275668 -0.0043169
+232 0.0293085 0.0427626 0.15295
+233 -0.0519639 -0.0702145 -0.0396086
+234 0.0761017 0.0374428 0.051298
+235 -0.0159578 0.0792842 0.0497498
+236 0.034143 0.0416644 -0.00292247
+237 0.0390065 0.144795 0.0173019
+238 0.0785221 -0.0182246 0.0322779
+239 0.08855 0.049747 0.094665
+240 0.0907667 0.00867691 0.0256048
+241 0.0713141 0.0126793 0.121408
+242 0.130155 0.131182 0.162077
+243 -0.0251589 0.0344113 0.061318
+244 0.00263686 0.116403 0.0435752
+245 0.0601417 0.0605919 0.122334
+246 0.140309 0.115836 0.0823734
+247 0.016011 0.0486162 0.148154
+248 0.00262091 0.0737306 0.072526
+249 0.0104423 0.122525 0.0314302
+250 -0.0121604 0.0365901 -0.00125785
+251 0.057694 0.0796572 0.0780739
+252 0.0105251 0.0256032 0.0185461
+253 0.176984 -0.0236614 0.0373487
+254 0.130621 0.0946323 0.0871696
+255 0.0184087 -0.0344569 -0.0683991
+256 -0.0285362 0.0517099 -0.0466689
+257 0.0359978 -0.0290421 -0.00906326
+258 0.139413 0.0805375 0.0462067
+259 -0.0417211 0.0459312 0.0709178
+260 0.131659 0.0797177 0.069449
+261 0.12139 -0.0308921 0.0236481
+262 -0.0473358 0.0443106 -0.072358
+263 0.084628 -0.0945129 0.0475128
+264 -0.071014 -0.0498558 0.0574321
+265 0.0737743 -0.0154591 -0.137914
+266 -0.0568069 -0.124133 -0.124654
+267 0.0666604 0.0191854 -0.119743
+268 0.041571 -0.0896298 -0.136019
+269 0.0326789 0.0194811 -0.137027
+270 -0.0600132 -0.0246257 -0.103282
+271 0.0021657 -0.0392893 0.0165702
+272 -0.0265276 0.0358137 -0.109032
+273 -0.00980905 -0.126957 0.0070903
+274 -0.112373 -0.142977 -0.0603599
+275 -0.0156997 -0.0061422 -0.0778784
+276 -0.141867 -0.0276022 -0.10555
+277 -0.0537075 -0.118422 -0.0688021
+278 -0.021912 0.0395811 -0.122468
+279 -0.142235 0.0242776 -0.131142
+280 -0.153856 -0.0539371 0.0487173
+281 -0.150066 0.0260706 -0.0484171
+282 0.0276874 -0.126691 -0.034534
+283 -0.0827422 -0.0664515 0.0509452
+284 -0.0961105 0.00643995 -0.0932914
+285 -0.0274402 -0.0195262 -0.0658101
+286 -0.134431 -0.0642967 -0.0574195
+287 0.00743148 -0.0152639 -0.0931265
+288 -0.00423643 0.0615726 -0.0341869
+289 -0.00121529 -0.0691136 0.0208955
+290 -0.0341773 0.00765812 0.0634719
+291 -0.0623566 -0.0894382 0.0760852
+292 -0.0612666 0.0517529 -0.0649392
+293 -0.101927 -0.0570001 -0.059353
+294 -0.0932661 -0.0140564 0.0587881
+295 -0.0342204 0.05115 -0.0077483
+296 0.00962707 0.0205178 -0.00930554
+297 0.086751 0.0407356 -0.0366705
+298 -0.0619837 0.0756976 -0.0100863
+299 0.0570416 0.0740328 -0.00593619
+300 0.0302965 0.121386 0.0437065
+301 0.0361282 -0.0495037 0.123276
+302 -0.062523 0.075657 -0.0168684
+303 -0.0562189 0.00751898 0.00902153
+304 0.0530975 0.0861497 0.0635998
+305 0.123772 0.103072 0.0125279
+306 0.046479 -0.0338678 0.135673
+307 -0.0563367 0.0694053 0.0863605
+308 -0.00974361 0.0449466 -0.00726647
+309 0.0645008 0.130862 -0.0300805
+310 -0.0102122 0.0417346 -0.0178576
+311 0.112372 -0.0570851 0.0815094
+312 0.0688116 0.0848637 0.0273649
+313 -0.0419733 0.085479 -0.0461803
+314 0.0577574 0.113394 0.0193587
+315 -0.0251148 0.00416879 0.0452759
+316 0.0129669 0.0516217 0.063999
+317 0.12351 0.0856708 0.0512581
+318 0.00205911 0.0124627 0.106923
+319 0.0915276 0.050777 0.0746293
+320 0.0447759 0.0116996 -0.061127
+321 -0.0109667 -0.0846675 -0.0540089
+322 0.0618661 -0.0517726 -0.0919522
+323 -0.0485281 -0.0735097 0.0261627
+324 0.0108828 0.00799162 -0.00281248
+325 0.00692862 -0.0243732 -0.07108
+326 -0.0159341 0.0429378 0.000305988
+327 0.0612861 0.0363946 0.0751722
+328 0.0682336 -0.0468204 -0.113224
+329 0.074241 0.0751501 -0.0933165
+330 0.0640157 -0.0512504 -0.119017
+331 0.00823924 0.0518188 -0.0208047
+332 -0.0522299 0.0381819 -0.00512094
+333 0.0609206 -0.0391507 0.0530922
+334 0.0448167 -0.0484483 0.000356115
+335 0.0603005 -0.0881785 -0.059333
+336 -0.0634416 -0.100544 -0.0499614
+337 0.0555596 0.0650417 -0.00739016
+338 0.0521511 -0.0904961 -0.015789
+339 0.0345315 0.0335526 -0.0157579
+340 0.0218467 -0.0659198 0.0542071
+341 0.00794727 0.00734579 -0.071046
+342 -0.115605 -0.059259 0.0317368
+343 -0.125382 -0.111452 0.00489641
+344 -0.00661221 -0.0946826 0.0502072
+345 -0.0828954 0.0533706 -0.106901
+346 0.0468269 0.0559098 -0.103946
+347 0.0627571 0.0246041 -0.00290758
+348 0.0430174 -0.0919724 0.0707788
+349 -0.0701459 -0.0746821 0.0259014
+350 -0.0659695 -0.0228015 0.0433118
+351 0.021503 -0.101376 0.0464046
+352 -0.00511543 -0.0885198 -0.0413994
+353 -0.115176 0.08576 -0.0920088
+354 -0.107332 0.0558678 -0.0642828
+355 -0.00758383 -0.0829995 0.0157428
+356 -0.0203309 0.0498391 0.0397182
+357 0.0759063 -0.000820063 0.0646244
+358 -0.0988938 0.0139485 -0.040957
+359 -0.100375 -0.0142476 0.0607591
+360 -0.0127385 -0.0447691 0.0204786
+361 -0.00720208 0.012704 0.101364
+362 0.0933342 0.0210504 0.103063
+363 0.0914453 -0.0212247 -0.00537845
+364 0.0222687 -0.0733793 0.0519698
+365 0.00887453 0.105965 0.0476493
+366 0.0393766 -0.0381711 0.0627169
+367 0.00992684 0.0120678 0.0319012
+368 -0.00524682 0.0858477 0.0545543
+369 -0.0276856 0.030261 0.0137738
+370 0.027146 0.0506496 -0.0606836
+371 -0.0409651 -0.0656822 0.0750463
+372 0.0261079 0.110611 0.0537327
+373 0.0683191 0.00103924 0.101136
+374 0.0223146 0.0638174 0.0372899
+375 0.0538864 0.026447 -0.0256291
+376 -0.0199266 0.0578314 -0.0205107
+377 -0.0287525 0.00897231 0.0789033
+378 0.011206 -0.0477837 -0.0527743
+379 0.0471543 -0.0419562 0.0626134
+380 0.0566571 0.0389111 0.10356
+381 0.0175098 0.0792653 0.0697493
+382 0.0516203 -0.00647098 -0.0733728
+383 0.0899533 0.0374349 0.0162332
+384 0.0490273 0.00456911 0.00870165
+385 -0.0153788 0.0137572 0.0249342
+386 0.109505 0.0779426 -0.0960305
+387 0.0230987 0.0716719 -0.034583
+388 -0.0308869 0.0992023 -0.076132
+389 0.049703 -0.00463838 0.0507225
+390 -0.0160384 -0.0116619 0.0794113
+391 -0.0251558 0.0270421 0.0103171
+392 0.0273061 -0.00456061 -0.0610323
+393 -0.0278667 -0.00932626 -0.0554114
+394 -0.0954355 -0.0612679 0.038761
+395 0.0116837 0.0508276 0.00879948
+396 -0.0921252 -0.00449076 -0.100855
+397 0.0595651 0.0473238 0.0656456
+398 0.00559781 0.0358737 0.0698283
+399 0.0325561 0.0287903 -0.103249
+400 -0.0611306 0.0483602 -0.0651726
+401 0.0530863 -0.0870683 -0.0114436
+402 0.0706962 0.000487238 -0.0722344
+403 0.0812003 -0.0450292 0.0609868
+404 -0.0902842 0.0756444 -0.0795868
+405 0.0342166 -0.0107851 0.0474598
+406 -0.0755312 -0.0418849 0.06597
+407 0.0782342 -0.0275304 -0.00841178
+408 -0.0404713 0.00561785 0.0787162
+409 -0.0985844 -0.0632749 -0.0258086
+410 -0.102143 0.0257031 0.0809771
+411 0.0299029 -0.00559649 0.0390066
+412 0.034459 -0.00404783 0.014188
+413 -0.016108 -0.0565063 0.0656708
+414 0.0809532 -0.0208452 -0.0651575
+415 -0.0251259 -0.0314543 -0.0551357
+416 -0.0949532 0.0830507 0.016536
+417 -0.0878092 -0.0828968 0.0055337
+418 -0.0826239 -0.101344 -0.0400788
+419 -0.0111641 0.0395108 0.016706
+420 0.028367 0.0597103 -0.0745472
+421 0.0141354 -0.0712234 0.0260366
+422 0.00158414 0.0215662 -0.0662277
+423 0.0182286 -0.032185 0.0981183
+424 0.0403989 0.0722646 0.0815234
+425 0.0763858 -0.0237108 0.0734619
+426 0.0749794 0.0654159 -0.0269555
+427 -0.01714 0.0617229 0.028065
+428 0.0490571 -0.0055667 -0.0504239
+429 -0.0592585 0.00800895 -0.0364137
+430 0.0356458 -0.0462567 -0.0565739
+431 0.0304146 0.0883306 -0.0221918
+432 -0.032884 -0.0858759 -0.0727408
+433 -0.0157107 0.103217 -0.0525016
+434 0.0840815 -0.0678038 0.0487336
+435 -0.0136451 -0.0254523 -0.0494127
+436 0.0481152 0.0318921 -0.0711827
+437 0.0669082 -0.00405252 0.1008
+438 -0.0756365 0.107987 0.0485059
+439 0.0971897 -0.0468521 0.0878878
+440 -0.0395712 0.0705408 -0.0558674
+441 -0.0188154 -0.00529399 0.0839984
+442 0.0746482 -0.00178176 0.0844743
+443 -0.0253263 -0.0826901 -0.0344131
+444 0.0200462 -0.0762975 0.045179
+445 -0.0194727 0.0442604 0.066079
+446 -0.0425051 0.00700625 0.0682874
+447 0.00871708 -0.0705593 0.0118328
+448 -0.0118458 0.000796106 -0.027898
+449 0.0226526 -0.0742575 -0.041394
+450 0.0307982 -0.0477487 -0.0859615
+451 0.00750597 -0.00622766 -0.076102
+452 0.0841357 -0.0354635 0.0520188
+453 0.0884507 0.0470198 0.0603375
+454 0.0726154 -0.0256462 -0.0204797
+455 0.0588101 0.00135376 -0.0994888
+456 -0.0512545 -0.102458 0.0550721
+457 0.0207424 -0.0420637 -0.0171892
+458 -0.0167934 0.0343817 0.0216211
+459 0.0853327 0.0416083 -0.104239
+460 0.0685533 0.00330597 0.0908588
+461 0.0831542 0.0777739 -0.0795082
+462 -0.0525808 -0.0390724 0.057681
+463 -0.0777708 -0.0555692 -0.0935927
+464 0.0156546 0.055027 0.00757796
+465 0.0352357 0.0601726 -0.0158123
+466 0.0892271 0.0551928 0.0615953
+467 -0.00601811 -0.034404 0.051511
+468 -0.0875655 -0.00102833 0.0364426
+469 0.0343225 -0.0193016 -0.0429046
+470 0.0237604 -0.105861 -0.0114598
+471 0.0624156 -0.102361 0.0263063
+472 -0.032 0.0271664 -0.0176814
+473 -0.0547783 -0.0769611 -0.0828618
+474 -0.00660219 -0.0272973 -0.0851916
+475 -0.00607989 -0.0831763 0.00508346
+476 -0.00919653 -0.0785865 0.0022782
+477 -0.0873774 -0.00788886 -0.0605173
+478 0.0831451 -0.0517538 -0.029326
+479 -0.0775978 -0.0502973 -0.0660945
+480 0.022881 0.0856377 0.0377766
+481 0.0346714 -0.00127431 0.0261189
+482 0.0132186 0.0532034 -0.0723848
+483 0.0200223 -0.0577082 0.0559004
+484 -0.00117771 -0.0906531 0.0213202
+485 0.085207 0.0652701 0.0662271
+486 0.0669462 -0.0557815 -0.0583366
+487 0.0196271 -0.0298252 -0.0782588
+488 -0.0372764 0.00892936 -0.0904771
+489 0.041935 -0.00854382 -0.0927152
+490 -0.0598391 -0.0137204 -0.0609897
+491 0.034607 0.0648553 -0.0128075
+492 -0.0934921 -0.0226216 -0.00705076
+493 0.0728948 0.0116726 -0.00765632
+494 0.101406 0.0161229 -0.0828996
+495 0.00169226 0.0232688 0.0290798
+496 0.072528 -0.0770499 -0.0124139
+497 0.0578824 0.0609395 0.00790179
+498 -0.0153936 0.0875941 0.104917
+499 -0.0776594 0.0832574 0.0209262
+500 -0.0864071 0.0137418 -0.0414727
diff --git a/src/gromacs/correlationfunctions/tests/testEXP.xvg b/src/gromacs/correlationfunctions/tests/testEXP.xvg
new file mode 100644 (file)
index 0000000..a192c51
--- /dev/null
@@ -0,0 +1,501 @@
+0 0
+1 0.933793
+2 1.64413
+3 2.26881
+4 2.69732
+5 3.18609
+6 3.5633
+7 3.77591
+8 4.083
+9 4.27165
+10 4.50143
+11 4.68664
+12 4.84612
+13 4.93256
+14 5.0487
+15 5.21257
+16 5.29916
+17 5.32257
+18 5.43037
+19 5.50601
+20 5.60239
+21 5.62398
+22 5.72622
+23 5.77308
+24 5.7562
+25 5.84888
+26 5.81699
+27 5.86178
+28 5.94235
+29 5.95981
+30 5.98369
+31 5.95674
+32 6.06792
+33 6.07991
+34 6.11024
+35 6.12377
+36 6.06567
+37 6.16848
+38 6.15328
+39 6.16295
+40 6.16469
+41 6.22697
+42 6.1776
+43 6.27148
+44 6.23865
+45 6.2744
+46 6.27211
+47 6.29498
+48 6.31175
+49 6.28439
+50 6.34758
+51 6.26659
+52 6.29551
+53 6.31016
+54 6.31924
+55 6.32594
+56 6.39353
+57 6.37555
+58 6.4125
+59 6.34882
+60 6.34253
+61 6.37401
+62 6.42251
+63 6.44891
+64 6.41029
+65 6.36925
+66 6.45488
+67 6.47461
+68 6.39323
+69 6.41703
+70 6.47664
+71 6.47864
+72 6.40653
+73 6.4444
+74 6.4901
+75 6.49016
+76 6.43924
+77 6.50607
+78 6.48499
+79 6.4465
+80 6.51673
+81 6.44586
+82 6.53225
+83 6.51432
+84 6.52803
+85 6.49069
+86 6.51123
+87 6.54134
+88 6.50065
+89 6.49403
+90 6.54445
+91 6.56578
+92 6.54692
+93 6.58151
+94 6.5848
+95 6.5796
+96 6.53327
+97 6.57402
+98 6.51995
+99 6.59609
+100 6.59545
+101 6.51956
+102 6.54083
+103 6.53558
+104 6.51182
+105 6.5347
+106 6.55378
+107 6.58284
+108 6.56471
+109 6.57831
+110 6.59092
+111 6.62654
+112 6.54307
+113 6.57412
+114 6.60729
+115 6.59664
+116 6.63216
+117 6.59422
+118 6.61469
+119 6.62636
+120 6.57808
+121 6.57356
+122 6.63797
+123 6.58006
+124 6.62347
+125 6.56521
+126 6.63422
+127 6.57666
+128 6.56846
+129 6.57003
+130 6.56552
+131 6.56682
+132 6.58905
+133 6.59197
+134 6.58329
+135 6.57486
+136 6.6287
+137 6.62418
+138 6.57194
+139 6.62585
+140 6.59216
+141 6.66186
+142 6.61182
+143 6.64493
+144 6.60235
+145 6.64946
+146 6.58789
+147 6.636
+148 6.60824
+149 6.59174
+150 6.67204
+151 6.63844
+152 6.64634
+153 6.61669
+154 6.60086
+155 6.68471
+156 6.6902
+157 6.65257
+158 6.61755
+159 6.67101
+160 6.6674
+161 6.63823
+162 6.63133
+163 6.6367
+164 6.66352
+165 6.696
+166 6.60881
+167 6.67253
+168 6.66735
+169 6.66583
+170 6.66259
+171 6.63691
+172 6.6766
+173 6.6913
+174 6.65969
+175 6.61821
+176 6.6796
+177 6.70715
+178 6.67694
+179 6.69653
+180 6.64676
+181 6.65935
+182 6.6781
+183 6.71181
+184 6.70878
+185 6.67739
+186 6.64651
+187 6.66021
+188 6.71047
+189 6.65987
+190 6.6511
+191 6.71258
+192 6.71689
+193 6.65441
+194 6.65054
+195 6.66806
+196 6.70738
+197 6.64787
+198 6.69967
+199 6.6331
+200 6.63513
+201 6.69851
+202 6.64237
+203 6.70702
+204 6.70229
+205 6.66568
+206 6.6818
+207 6.68629
+208 6.71863
+209 6.73129
+210 6.66952
+211 6.69274
+212 6.67642
+213 6.6782
+214 6.65372
+215 6.7269
+216 6.70297
+217 6.64193
+218 6.65786
+219 6.73524
+220 6.70002
+221 6.6906
+222 6.70867
+223 6.7153
+224 6.66604
+225 6.70376
+226 6.70701
+227 6.71955
+228 6.73206
+229 6.71019
+230 6.70016
+231 6.72956
+232 6.64624
+233 6.73931
+234 6.70839
+235 6.67605
+236 6.67944
+237 6.7271
+238 6.72234
+239 6.66538
+240 6.71936
+241 6.66755
+242 6.68937
+243 6.724
+244 6.68827
+245 6.69197
+246 6.66415
+247 6.69317
+248 6.69017
+249 6.70377
+250 6.70761
+251 6.74691
+252 6.7327
+253 6.66325
+254 6.67565
+255 6.68625
+256 6.71185
+257 6.65938
+258 6.66814
+259 6.69835
+260 6.71306
+261 6.68137
+262 6.68514
+263 6.69503
+264 6.70687
+265 6.70667
+266 6.71226
+267 6.74293
+268 6.6743
+269 6.70273
+270 6.68393
+271 6.71818
+272 6.72623
+273 6.73187
+274 6.73242
+275 6.70873
+276 6.70823
+277 6.69239
+278 6.75188
+279 6.71371
+280 6.7502
+281 6.69877
+282 6.6998
+283 6.66478
+284 6.70866
+285 6.73126
+286 6.73144
+287 6.70046
+288 6.70388
+289 6.6847
+290 6.75264
+291 6.73971
+292 6.70705
+293 6.7407
+294 6.67035
+295 6.72357
+296 6.73306
+297 6.73084
+298 6.68237
+299 6.76651
+300 6.72838
+301 6.76579
+302 6.744
+303 6.6963
+304 6.76216
+305 6.66966
+306 6.67184
+307 6.67226
+308 6.67163
+309 6.68679
+310 6.73726
+311 6.68492
+312 6.73491
+313 6.75372
+314 6.68562
+315 6.73127
+316 6.73742
+317 6.74772
+318 6.71254
+319 6.67357
+320 6.72034
+321 6.71205
+322 6.68542
+323 6.76568
+324 6.69664
+325 6.7009
+326 6.71605
+327 6.73142
+328 6.7524
+329 6.70307
+330 6.7459
+331 6.70831
+332 6.71814
+333 6.76659
+334 6.67721
+335 6.70581
+336 6.75936
+337 6.71626
+338 6.77537
+339 6.73916
+340 6.75086
+341 6.69825
+342 6.73784
+343 6.68206
+344 6.73098
+345 6.69878
+346 6.70428
+347 6.76935
+348 6.68665
+349 6.72539
+350 6.70694
+351 6.683
+352 6.76606
+353 6.74774
+354 6.69002
+355 6.77377
+356 6.71343
+357 6.71858
+358 6.77459
+359 6.72939
+360 6.74046
+361 6.71403
+362 6.70104
+363 6.7676
+364 6.70533
+365 6.68404
+366 6.73426
+367 6.74651
+368 6.73703
+369 6.7093
+370 6.68535
+371 6.78054
+372 6.68628
+373 6.74885
+374 6.75663
+375 6.78102
+376 6.78231
+377 6.69437
+378 6.69903
+379 6.70758
+380 6.74678
+381 6.7422
+382 6.72993
+383 6.68776
+384 6.74261
+385 6.75407
+386 6.76879
+387 6.70534
+388 6.6894
+389 6.71274
+390 6.73197
+391 6.75648
+392 6.74171
+393 6.73153
+394 6.68943
+395 6.75898
+396 6.72838
+397 6.74778
+398 6.72736
+399 6.77489
+400 6.77639
+401 6.70282
+402 6.71161
+403 6.76628
+404 6.77065
+405 6.77603
+406 6.68948
+407 6.76621
+408 6.72207
+409 6.72234
+410 6.75854
+411 6.77273
+412 6.76151
+413 6.74252
+414 6.73153
+415 6.69708
+416 6.74061
+417 6.75818
+418 6.72091
+419 6.74424
+420 6.78673
+421 6.74145
+422 6.69344
+423 6.72471
+424 6.72518
+425 6.76767
+426 6.71893
+427 6.78251
+428 6.78466
+429 6.78094
+430 6.77212
+431 6.74085
+432 6.74283
+433 6.73333
+434 6.78714
+435 6.77238
+436 6.73692
+437 6.73205
+438 6.70148
+439 6.77486
+440 6.76451
+441 6.79155
+442 6.73363
+443 6.69988
+444 6.77442
+445 6.78397
+446 6.7856
+447 6.73778
+448 6.70429
+449 6.7378
+450 6.74829
+451 6.69527
+452 6.75622
+453 6.7867
+454 6.76332
+455 6.72525
+456 6.72494
+457 6.78544
+458 6.7868
+459 6.73629
+460 6.75375
+461 6.71361
+462 6.73621
+463 6.74825
+464 6.70532
+465 6.78782
+466 6.73666
+467 6.79325
+468 6.69962
+469 6.71673
+470 6.72258
+471 6.72758
+472 6.70651
+473 6.70794
+474 6.77938
+475 6.71007
+476 6.7414
+477 6.77997
+478 6.71039
+479 6.77047
+480 6.71826
+481 6.73399
+482 6.69929
+483 6.7929
+484 6.77405
+485 6.79742
+486 6.76882
+487 6.74596
+488 6.71524
+489 6.7947
+490 6.75326
+491 6.72172
+492 6.71176
+493 6.71697
+494 6.74455
+495 6.78932
+496 6.70312
+497 6.72368
+498 6.70806
+499 6.70917
+500 6.79967
diff --git a/src/gromacs/correlationfunctions/tests/testINVEXP.xvg b/src/gromacs/correlationfunctions/tests/testINVEXP.xvg
new file mode 100755 (executable)
index 0000000..a36eac5
--- /dev/null
@@ -0,0 +1,501 @@
+0  1.0681\r
+1  0.943394\r
+2  0.940582\r
+3  0.876908\r
+4  0.772058\r
+5  0.717467\r
+6  0.62021\r
+7  0.637288\r
+8  0.612462\r
+9  0.660404\r
+10  0.587782\r
+11  0.604724\r
+12  0.414682\r
+13  0.485151\r
+14  0.437477\r
+15  0.400413\r
+16  0.492272\r
+17  0.485068\r
+18  0.524471\r
+19  0.331468\r
+20  0.466912\r
+21  0.478988\r
+22  0.409751\r
+23  0.290041\r
+24  0.278663\r
+25  0.327049\r
+26  0.342437\r
+27  0.303842\r
+28  0.439109\r
+29  0.296164\r
+30  0.343069\r
+31  0.248582\r
+32  0.307399\r
+33  0.2247\r
+34  0.210569\r
+35  0.36623\r
+36  0.311727\r
+37  0.281739\r
+38  0.297556\r
+39  0.322846\r
+40  0.323614\r
+41  0.238788\r
+42  0.208327\r
+43  0.34916\r
+44  0.303368\r
+45  0.258602\r
+46  0.304515\r
+47  0.190447\r
+48  0.308091\r
+49  0.160807\r
+50  0.181371\r
+51  0.192209\r
+52  0.181283\r
+53  0.201928\r
+54  0.105623\r
+55  0.246128\r
+56  0.128467\r
+57  0.186709\r
+58  0.195287\r
+59  0.131209\r
+60  0.123502\r
+61  0.21343\r
+62  0.265214\r
+63  0.198079\r
+64  0.0875281\r
+65  0.148709\r
+66  0.162407\r
+67  0.165434\r
+68  0.235861\r
+69  0.225641\r
+70  0.0716764\r
+71  0.224192\r
+72  0.0976416\r
+73  0.164153\r
+74  0.0848313\r
+75  0.0779902\r
+76  0.0789197\r
+77  0.123511\r
+78  0.095581\r
+79  0.187898\r
+80  0.0618937\r
+81  0.214364\r
+82  0.207497\r
+83  0.134731\r
+84  0.211358\r
+85  0.0212662\r
+86  0.123847\r
+87  0.0641108\r
+88  0.09398\r
+89  0.0165856\r
+90  0.0257984\r
+91  0.0374152\r
+92  0.00685148\r
+93  0.0827592\r
+94  0.0394362\r
+95  0.176037\r
+96  0.0588189\r
+97  0.00230256\r
+98  0.14224\r
+99  0.15686\r
+100  0.0514332\r
+101  0.123575\r
+102  0.0661031\r
+103  0.0936242\r
+104  0.165916\r
+105  0.065199\r
+106  0.0166701\r
+107  0.121875\r
+108  0.0783671\r
+109  0.0831681\r
+110  0.0477346\r
+111  0.0944206\r
+112  -0.00249231\r
+113  -0.00795285\r
+114  0.104603\r
+115  0.0897528\r
+116  0.0475694\r
+117  0.105319\r
+118  0.0818006\r
+119  0.137639\r
+120  0.00351689\r
+121  0.139798\r
+122  0.128182\r
+123  0.0740928\r
+124  0.0266052\r
+125  0.01518\r
+126  0.0764528\r
+127  -0.0478048\r
+128  0.145348\r
+129  -0.0278405\r
+130  0.0743014\r
+131  -0.0442497\r
+132  -0.019708\r
+133  0.0312048\r
+134  0.0508013\r
+135  0.0895047\r
+136  0.0205578\r
+137  0.11894\r
+138  -0.0355846\r
+139  0.0526809\r
+140  0.0259417\r
+141  0.000229281\r
+142  0.0478984\r
+143  0.0418232\r
+144  0.0504251\r
+145  0.0714415\r
+146  0.0905807\r
+147  -0.0255317\r
+148  -0.0387278\r
+149  0.0939955\r
+150  -0.020037\r
+151  -0.0230931\r
+152  -0.0375384\r
+153  0.0771837\r
+154  0.0622474\r
+155  -0.0626867\r
+156  0.122018\r
+157  -0.0446062\r
+158  -0.0246245\r
+159  0.0897752\r
+160  0.0498833\r
+161  0.0472345\r
+162  0.0583388\r
+163  -0.0347339\r
+164  0.0762762\r
+165  -0.0672939\r
+166  0.046974\r
+167  0.0223582\r
+168  -0.0599178\r
+169  -0.0605643\r
+170  -0.0708522\r
+171  0.0534838\r
+172  0.112608\r
+173  0.0901323\r
+174  -0.0488154\r
+175  0.0518089\r
+176  0.0541252\r
+177  -0.0691998\r
+178  0.0425829\r
+179  0.0192925\r
+180  -0.0710574\r
+181  -0.0671212\r
+182  -0.0424854\r
+183  -0.00173892\r
+184  -0.0106879\r
+185  -0.0576365\r
+186  0.0192927\r
+187  0.016837\r
+188  -0.0206993\r
+189  0.0350927\r
+190  0.0979423\r
+191  0.0528159\r
+192  0.106826\r
+193  -0.0702302\r
+194  -0.0487975\r
+195  -0.0589017\r
+196  -0.0146245\r
+197  0.0089213\r
+198  -0.0842674\r
+199  -0.0234645\r
+200  0.0565023\r
+201  0.00287557\r
+202  -0.0520075\r
+203  -0.00293986\r
+204  -0.0299982\r
+205  0.102979\r
+206  -0.0167894\r
+207  -0.0287721\r
+208  0.0207559\r
+209  0.0876499\r
+210  0.106049\r
+211  -0.0401939\r
+212  0.0195434\r
+213  -0.0314981\r
+214  0.108024\r
+215  -0.0271984\r
+216  -0.090313\r
+217  0.0936537\r
+218  0.0444229\r
+219  0.101328\r
+220  0.0322305\r
+221  -0.018528\r
+222  -0.00257325\r
+223  -0.0320265\r
+224  -0.0105935\r
+225  0.000379694\r
+226  0.00231763\r
+227  0.00982889\r
+228  -0.040522\r
+229  -0.0410073\r
+230  0.000112217\r
+231  -0.0148902\r
+232  0.0756062\r
+233  -0.0742674\r
+234  -0.0573473\r
+235  -0.0227042\r
+236  0.0972166\r
+237  -0.0418052\r
+238  -0.00486911\r
+239  0.0599813\r
+240  0.074408\r
+241  0.0899329\r
+242  -0.0437813\r
+243  0.0811337\r
+244  0.0342668\r
+245  0.0959573\r
+246  -0.0525791\r
+247  -0.0727846\r
+248  0.102521\r
+249  0.0381233\r
+250  -0.089035\r
+251  -0.0643688\r
+252  -0.0852113\r
+253  -0.0222789\r
+254  0.099484\r
+255  0.0382242\r
+256  0.0687417\r
+257  -0.0650391\r
+258  -0.0590526\r
+259  -0.0609537\r
+260  -0.0781632\r
+261  -0.0263208\r
+262  0.0187378\r
+263  -0.0436076\r
+264  0.048821\r
+265  -0.00552439\r
+266  0.0194677\r
+267  0.0920907\r
+268  -0.0609475\r
+269  0.0306231\r
+270  -0.0299242\r
+271  0.0303031\r
+272  0.0357398\r
+273  -0.041525\r
+274  -0.0890632\r
+275  -0.086406\r
+276  -0.00247411\r
+277  -0.0422722\r
+278  -0.0668341\r
+279  0.0957862\r
+280  0.0974149\r
+281  -0.0132207\r
+282  0.0459918\r
+283  0.0291298\r
+284  -0.0351444\r
+285  -0.0254443\r
+286  0.0340195\r
+287  0.00756723\r
+288  0.0238715\r
+289  -0.0274353\r
+290  -0.0856008\r
+291  0.0583847\r
+292  -0.0165585\r
+293  -0.0404389\r
+294  0.0103612\r
+295  0.0513012\r
+296  -0.00408748\r
+297  -0.0539004\r
+298  0.0202747\r
+299  0.0770502\r
+300  0.0150383\r
+301  0.0873767\r
+302  -0.0196684\r
+303  -0.0632305\r
+304  0.0573153\r
+305  0.0801514\r
+306  0.0941519\r
+307  -0.0209786\r
+308  0.0986031\r
+309  -0.00683724\r
+310  0.0340542\r
+311  -0.0769762\r
+312  0.0225878\r
+313  0.0603486\r
+314  -0.093571\r
+315  -0.0853193\r
+316  -0.0215317\r
+317  0.0523009\r
+318  0.0175962\r
+319  0.0762564\r
+320  -0.0976852\r
+321  0.0337763\r
+322  0.0767278\r
+323  0.0310502\r
+324  0.00986905\r
+325  0.0137131\r
+326  -0.0711432\r
+327  -0.0888209\r
+328  -0.0218738\r
+329  -0.000910774\r
+330  -0.0763064\r
+331  -0.0104076\r
+332  0.0988596\r
+333  0.0750879\r
+334  -0.00508757\r
+335  -0.0833086\r
+336  -0.0906822\r
+337  -0.0485789\r
+338  0.0497686\r
+339  -0.0125583\r
+340  0.0836466\r
+341  -0.0617063\r
+342  -0.0496492\r
+343  -0.08338\r
+344  -0.0968441\r
+345  -0.054627\r
+346  0.00546937\r
+347  0.0578465\r
+348  0.0143735\r
+349  0.0332627\r
+350  0.0861252\r
+351  0.0663102\r
+352  0.0308983\r
+353  0.0893619\r
+354  0.0277007\r
+355  0.075605\r
+356  0.0383847\r
+357  -0.0513761\r
+358  0.0884597\r
+359  -0.0641501\r
+360  0.0215607\r
+361  -0.0653902\r
+362  0.0966357\r
+363  -0.0567258\r
+364  0.0480028\r
+365  -0.0426312\r
+366  -0.0626624\r
+367  -0.0192904\r
+368  -0.0845387\r
+369  -0.0279446\r
+370  0.00569403\r
+371  0.0839343\r
+372  0.0978487\r
+373  -0.02417\r
+374  -0.0158972\r
+375  -0.0494234\r
+376  0.00957538\r
+377  0.000469922\r
+378  -0.0108498\r
+379  0.0162894\r
+380  0.0487372\r
+381  -0.0557467\r
+382  -0.0222935\r
+383  0.0371676\r
+384  -0.0232714\r
+385  -0.0209432\r
+386  -0.0980981\r
+387  0.0378866\r
+388  -0.0548227\r
+389  0.0672464\r
+390  0.0591308\r
+391  0.0117988\r
+392  0.0906635\r
+393  0.0278184\r
+394  -0.00406985\r
+395  0.0922327\r
+396  0.0835114\r
+397  0.00238354\r
+398  -0.00648136\r
+399  0.0534958\r
+400  -0.0609925\r
+401  0.0889696\r
+402  -0.0120165\r
+403  -0.0544075\r
+404  -0.0222787\r
+405  -0.0647516\r
+406  -0.0404564\r
+407  0.0184243\r
+408  0.056176\r
+409  0.0126803\r
+410  -0.0369847\r
+411  0.0492475\r
+412  0.0799349\r
+413  -0.0708037\r
+414  0.0655493\r
+415  -0.048577\r
+416  -0.0417596\r
+417  0.0804274\r
+418  -0.0920922\r
+419  -0.0870022\r
+420  -0.0373363\r
+421  -0.0118833\r
+422  0.0119897\r
+423  0.0904194\r
+424  -0.0882078\r
+425  0.0292385\r
+426  -0.0799874\r
+427  0.0656876\r
+428  -0.0801976\r
+429  -0.0795223\r
+430  -0.0302974\r
+431  0.0645107\r
+432  0.0188364\r
+433  0.0901072\r
+434  -0.014961\r
+435  -0.0714636\r
+436  -0.00657822\r
+437  -0.0570667\r
+438  -0.00645351\r
+439  0.03649\r
+440  0.0497419\r
+441  0.00386253\r
+442  0.0688225\r
+443  -0.022944\r
+444  0.0833869\r
+445  0.011775\r
+446  -0.0590674\r
+447  -0.00939986\r
+448  -0.0937156\r
+449  0.0277734\r
+450  -0.0824969\r
+451  0.0173356\r
+452  0.0468303\r
+453  -0.0794911\r
+454  -0.085217\r
+455  0.0162948\r
+456  0.046809\r
+457  -0.00383156\r
+458  0.0106462\r
+459  0.0524757\r
+460  -0.0554865\r
+461  0.0518396\r
+462  -0.0995535\r
+463  0.0887906\r
+464  0.0555471\r
+465  -0.0516458\r
+466  -0.0381637\r
+467  0.0649521\r
+468  0.0411061\r
+469  -0.077658\r
+470  -0.0838968\r
+471  0.0971887\r
+472  -0.0118835\r
+473  0.087111\r
+474  -0.088725\r
+475  0.0906914\r
+476  0.016415\r
+477  -0.091898\r
+478  0.0461889\r
+479  -0.079051\r
+480  -0.0247629\r
+481  0.0810491\r
+482  -0.095085\r
+483  0.0106392\r
+484  0.0945944\r
+485  -0.0103912\r
+486  -0.0226289\r
+487  0.00549821\r
+488  0.0166932\r
+489  -0.0258937\r
+490  -0.0953396\r
+491  -0.0643975\r
+492  0.0483682\r
+493  0.0041773\r
+494  -0.0933927\r
+495  -0.062249\r
+496  -0.0524264\r
+497  0.0154673\r
+498  -0.0758339\r
+499  -0.0898537\r
+500  0.0852957\r
diff --git a/src/gromacs/correlationfunctions/tests/testPRES.xvg b/src/gromacs/correlationfunctions/tests/testPRES.xvg
new file mode 100644 (file)
index 0000000..1a7c439
--- /dev/null
@@ -0,0 +1,501 @@
+0 1\r
+1 -0.36916866\r
+2 0.014760643\r
+3 0.13679177\r
+4 -0.30409385\r
+5 0.29211639\r
+6 -0.091300702\r
+7 -0.039725083\r
+8 0.11034297\r
+9 -0.14710173\r
+10 0.10112144\r
+11 -0.010410828\r
+12 -0.032484227\r
+13 0.061104037\r
+14 -0.062734083\r
+15 0.025088122\r
+16 0.0090911273\r
+17 -0.017547903\r
+18 0.028334545\r
+19 -0.019187307\r
+20 0.0034395636\r
+21 0.0048080537\r
+22 -0.011152624\r
+23 0.01468337\r
+24 -0.0030113453\r
+25 -0.001243929\r
+26 0.0026129168\r
+27 -0.0026818807\r
+28 0.00064227781\r
+29 0.0074954932\r
+30 -0.0080780674\r
+31 0.00097865747\r
+32 -0.005031499\r
+33 -0.0052062969\r
+34 0.015055237\r
+35 -0.0095560328\r
+36 -0.0012146344\r
+37 0.010541719\r
+38 -0.012150134\r
+39 0.010456563\r
+40 0.0036188245\r
+41 -0.010936702\r
+42 0.010207533\r
+43 -0.012300312\r
+44 0.0095503834\r
+45 0.006544511\r
+46 -0.0066008741\r
+47 0.010029187\r
+48 -0.0071012281\r
+49 0.0031570678\r
+50 0.0012269821\r
+51 -0.0035287761\r
+52 0.0092208671\r
+53 -0.0050034278\r
+54 -0.0028083487\r
+55 0.0099907991\r
+56 -0.011213547\r
+57 0.0090618645\r
+58 0.00031212197\r
+59 -0.0078672003\r
+60 0.010691127\r
+61 -0.0142263\r
+62 0.0058443876\r
+63 0.009818197\r
+64 -0.015058958\r
+65 0.010990055\r
+66 -0.0046160689\r
+67 -0.00587247\r
+68 0.0080246324\r
+69 -0.013475108\r
+70 0.009457794\r
+71 0.0047824004\r
+72 -0.007228957\r
+73 0.0056784217\r
+74 -0.0053565642\r
+75 -0.0023129048\r
+76 0.0029403305\r
+77 0.0033938085\r
+78 -0.0027952122\r
+79 0.0049366451\r
+80 -0.0028004289\r
+81 -0.0050486784\r
+82 0.010090499\r
+83 -0.0066157412\r
+84 0.002647089\r
+85 0.004144073\r
+86 -0.0087895271\r
+87 0.0071204964\r
+88 -0.00012740103\r
+89 -0.0050871728\r
+90 0.0071564119\r
+91 -0.0033754525\r
+92 1.2455157e-05\r
+93 0.0030776314\r
+94 0.0017022748\r
+95 -0.001404079\r
+96 -0.00045972626\r
+97 0.002904963\r
+98 -0.00059061365\r
+99 0.0034982589\r
+100 -0.0040645105\r
+101 0.001922386\r
+102 -0.0048760292\r
+103 0.0036464155\r
+104 -0.0036342766\r
+105 -0.0017862264\r
+106 0.0059070168\r
+107 -0.0091214493\r
+108 0.0045011193\r
+109 -0.0060048408\r
+110 0.0060602812\r
+111 -0.0060052815\r
+112 -0.00020469623\r
+113 0.0065917101\r
+114 -0.0099221852\r
+115 0.014778086\r
+116 -0.0070540206\r
+117 -0.00076770342\r
+118 0.0079772927\r
+119 -0.0085905236\r
+120 -0.00062513836\r
+121 0.0039284039\r
+122 -0.0039490427\r
+123 0.0094788591\r
+124 -0.0089938099\r
+125 -0.00032447391\r
+126 0.012605208\r
+127 -0.012399453\r
+128 0.013065264\r
+129 -0.0065310037\r
+130 -0.0039457333\r
+131 0.0067739115\r
+132 -0.0068084074\r
+133 0.0013759999\r
+134 -0.00063317348\r
+135 -0.0021762489\r
+136 0.0030220418\r
+137 0.0015570751\r
+138 -0.0025386858\r
+139 -0.0014269051\r
+140 0.002304196\r
+141 0.0017299628\r
+142 0.0027960096\r
+143 0.0076820985\r
+144 -0.0079212418\r
+145 -0.0017760952\r
+146 0.00056810081\r
+147 -0.002893933\r
+148 0.0090171461\r
+149 -0.0048042782\r
+150 0.00058932377\r
+151 0.00017170853\r
+152 -0.0035441974\r
+153 0.0043755975\r
+154 0.0084104895\r
+155 -0.005701828\r
+156 0.0018862645\r
+157 -0.0037968043\r
+158 -0.0049495224\r
+159 0.010596751\r
+160 -0.0089947785\r
+161 0.0012556332\r
+162 0.0055142779\r
+163 -0.0062561089\r
+164 0.0038259902\r
+165 -0.0011985974\r
+166 -0.0049824898\r
+167 0.011615239\r
+168 -0.0088481353\r
+169 0.0067664258\r
+170 -0.0021850029\r
+171 -0.0020955691\r
+172 0.0065267348\r
+173 -0.0093968866\r
+174 0.010932961\r
+175 -0.0053299546\r
+176 0.00051623668\r
+177 0.010631414\r
+178 -0.0061742852\r
+179 0.0047321249\r
+180 -0.0041945108\r
+181 0.00041651391\r
+182 0.0059446844\r
+183 -0.0073002656\r
+184 0.0056609192\r
+185 -0.0031166474\r
+186 0.0030953688\r
+187 0.001780965\r
+188 -0.0028736768\r
+189 0.0018569937\r
+190 -0.013309515\r
+191 0.0091007007\r
+192 -0.0032373501\r
+193 -0.0039707857\r
+194 0.011440142\r
+195 -0.0057663289\r
+196 0.004801657\r
+197 -0.0013462481\r
+198 -0.010549285\r
+199 0.010122314\r
+200 -0.0035914536\r
+201 -0.00088911725\r
+202 0.0033173624\r
+203 -0.0043540954\r
+204 0.0030779559\r
+205 -0.0025979372\r
+206 0.0016403824\r
+207 -0.0024759414\r
+208 0.0032173406\r
+209 -0.0030610313\r
+210 -0.0016666896\r
+211 0.0015944701\r
+212 -0.0023360152\r
+213 0.0048610048\r
+214 -0.0032376247\r
+215 -4.3995002e-05\r
+216 6.6794023e-05\r
+217 0.0027313477\r
+218 0.0012655508\r
+219 -0.0017807253\r
+220 -0.0016059832\r
+221 -0.0032230254\r
+222 0.0025585309\r
+223 -0.0011469088\r
+224 -0.0003959904\r
+225 0.0053054824\r
+226 -0.0083941959\r
+227 0.0015681321\r
+228 0.0041374876\r
+229 -0.0057795873\r
+230 0.012391208\r
+231 -0.0089103375\r
+232 -0.0057140203\r
+233 0.010399712\r
+234 -0.0084861502\r
+235 0.0069274989\r
+236 -0.0035049527\r
+237 -0.0032573957\r
+238 0.006458053\r
+239 -0.0073720368\r
+240 0.004089722\r
+241 -0.0039903411\r
+242 0.0042265311\r
+243 0.0033469261\r
+244 -0.0019453617\r
+245 -0.002372851\r
+246 -0.0048265504\r
+247 0.0021513391\r
+248 0.0093348207\r
+249 -0.0069923934\r
+250 -0.0025467685\r
+251 0.0029155541\r
+252 -0.0025788452\r
+253 0.001574745\r
+254 0.0045629202\r
+255 -0.0040519536\r
+256 0.0076833817\r
+257 -0.0074180399\r
+258 -0.00063383685\r
+259 0.0068584823\r
+260 -0.0096914403\r
+261 0.0059967688\r
+262 0.00045410173\r
+263 -0.001403505\r
+264 0.0081904238\r
+265 -0.0071767739\r
+266 0.0059756132\r
+267 0.0017534261\r
+268 -0.004887574\r
+269 0.0048234918\r
+270 -0.0068738558\r
+271 0.0038855002\r
+272 0.0022543436\r
+273 -6.9437609e-05\r
+274 -0.0022807576\r
+275 0.0013418244\r
+276 0.0011818884\r
+277 0.00076014954\r
+278 0.0049090373\r
+279 -0.0070762441\r
+280 -0.0035987494\r
+281 -0.00042682359\r
+282 0.0075464111\r
+283 -0.0014126097\r
+284 -0.00064224669\r
+285 0.0043936991\r
+286 -0.0010854328\r
+287 0.0026627405\r
+288 -0.0056961166\r
+289 -0.0022827355\r
+290 0.00798009\r
+291 -0.0076570431\r
+292 0.0063197703\r
+293 -0.0046694987\r
+294 -0.0024289403\r
+295 0.014527988\r
+296 -0.004486569\r
+297 -0.0080975585\r
+298 0.0095232942\r
+299 -0.010183442\r
+300 0.01195895\r
+301 -0.004018328\r
+302 -0.011547823\r
+303 0.010954626\r
+304 -0.0091701818\r
+305 0.0042623717\r
+306 0.0034892822\r
+307 -0.010150087\r
+308 0.0037818881\r
+309 0.0026481578\r
+310 -0.0088027283\r
+311 0.0074229712\r
+312 -0.002371628\r
+313 -0.0019573871\r
+314 0.0067617097\r
+315 -0.0072601173\r
+316 0.001730287\r
+317 0.0016428277\r
+318 -0.0014072933\r
+319 0.0055637106\r
+320 -0.0082579367\r
+321 -0.00076510199\r
+322 0.0030415574\r
+323 -0.0036437184\r
+324 0.004035587\r
+325 0.00082805112\r
+326 -0.0026851012\r
+327 0.0072246657\r
+328 -0.005339296\r
+329 -0.0043448825\r
+330 0.010643155\r
+331 -0.0081609374\r
+332 0.0066917325\r
+333 0.0012791562\r
+334 -0.01113791\r
+335 0.0090475954\r
+336 -0.010853231\r
+337 0.0032409009\r
+338 0.0040980312\r
+339 -0.0049287883\r
+340 0.0016793288\r
+341 -0.00061239968\r
+342 -0.0017427787\r
+343 0.0036588193\r
+344 -0.0067342253\r
+345 0.0067958251\r
+346 0.00043325857\r
+347 -0.0062904337\r
+348 0.0073918666\r
+349 -0.0066576978\r
+350 0.0026485433\r
+351 -0.0023968324\r
+352 -0.00020262248\r
+353 0.0055669462\r
+354 0.0031921639\r
+355 0.0029113674\r
+356 -0.0020937975\r
+357 -0.0015773086\r
+358 -0.0011931629\r
+359 0.0019845672\r
+360 0.0010049488\r
+361 -0.0043402076\r
+362 0.0069653274\r
+363 -0.0066296993\r
+364 0.0040835956\r
+365 -0.0022719748\r
+366 0.0031787892\r
+367 0.0018863936\r
+368 -0.0043240145\r
+369 0.0031209756\r
+370 0.0032751251\r
+371 -0.0043714253\r
+372 0.0010235949\r
+373 0.005830025\r
+374 -0.0087525349\r
+375 0.011878699\r
+376 -0.0092464787\r
+377 0.0051095452\r
+378 0.00049215492\r
+379 -0.0097728624\r
+380 0.0087838903\r
+381 -0.0098013112\r
+382 0.0068713438\r
+383 0.0049554926\r
+384 -0.0043905163\r
+385 -0.0015883465\r
+386 0.0021411048\r
+387 -0.00053965888\r
+388 0.0036745358\r
+389 0.0014808036\r
+390 -0.004536402\r
+391 0.0015192218\r
+392 0.0027196502\r
+393 -0.0025810566\r
+394 0.0031082096\r
+395 -4.7723387e-06\r
+396 0.0020796938\r
+397 -0.0022570854\r
+398 -0.003936731\r
+399 0.0084666388\r
+400 -0.0057506351\r
+401 0.0016458976\r
+402 0.0094691866\r
+403 -0.008839108\r
+404 0.0050982854\r
+405 -0.0010481337\r
+406 -0.0069512806\r
+407 0.010890251\r
+408 -0.0057060768\r
+409 0.0014311795\r
+410 0.011839364\r
+411 -0.009251874\r
+412 0.0021195342\r
+413 -0.0023409846\r
+414 -0.0063670687\r
+415 0.015033781\r
+416 -0.0088340168\r
+417 0.0079325639\r
+418 -0.0024966017\r
+419 -0.0032571545\r
+420 0.0071797801\r
+421 -0.0057685757\r
+422 0.0065634168\r
+423 -0.0010758619\r
+424 0.0016557167\r
+425 -0.0047244662\r
+426 0.0030926208\r
+427 0.0010412274\r
+428 -0.0091296123\r
+429 0.0059321171\r
+430 -0.004148807\r
+431 -0.00095115911\r
+432 0.0094210884\r
+433 -0.0078277968\r
+434 -0.0012672641\r
+435 0.0050365588\r
+436 -0.0071693578\r
+437 0.0058395732\r
+438 -0.0051660217\r
+439 -0.0013598015\r
+440 0.011156443\r
+441 -0.014047785\r
+442 0.015500496\r
+443 -0.00036496224\r
+444 -0.0050689753\r
+445 0.0055969248\r
+446 -0.0040965089\r
+447 0.00058886366\r
+448 0.0076116355\r
+449 -0.01027737\r
+450 0.00046901907\r
+451 0.001038831\r
+452 -0.0013155834\r
+453 0.0050353034\r
+454 -5.9224741e-05\r
+455 -0.0065878485\r
+456 0.0062157693\r
+457 -0.0041094506\r
+458 -0.0028793431\r
+459 0.0037869066\r
+460 -0.0023136901\r
+461 0.001233849\r
+462 0.00063285754\r
+463 -0.001011581\r
+464 0.004749887\r
+465 -0.01004642\r
+466 0.0079936783\r
+467 0.00078925829\r
+468 -0.005341806\r
+469 0.0060564244\r
+470 -0.0098092403\r
+471 -0.0029105401\r
+472 0.0059783383\r
+473 -0.0072104572\r
+474 0.0051409769\r
+475 0.0018890171\r
+476 -0.0014278876\r
+477 0.0010991714\r
+478 -0.0031653206\r
+479 0.0064217826\r
+480 0.0050600168\r
+481 -0.0037536295\r
+482 0.0016811847\r
+483 -0.00051376806\r
+484 0.00042566853\r
+485 0.0034279566\r
+486 0.0048093524\r
+487 -0.0063048747\r
+488 0.0075198538\r
+489 -0.00304979\r
+490 0.0021628828\r
+491 0.0049535774\r
+492 -0.0073786608\r
+493 0.0066929183\r
+494 -0.010125056\r
+495 0.0034794835\r
+496 0.00019589747\r
+497 -0.0036975265\r
+498 0.0083901558\r
+499 -0.0051172093\r
+500 -0.00025500495\r
index fc65cf8d02b6dda047a9c1944512f82718df7fcb..a9cb9b8f3240a1790e61a7a67fcf427887397d5b 100644 (file)
@@ -501,24 +501,25 @@ static char *fgets3(FILE *fp, char **ptr, int *len, int maxlen)
 
 static int wordcount(char *ptr)
 {
-    int i, n, is[2];
+    int i, n = 0, is[2];
     int cur = 0;
 #define prev (1-cur)
 
-    if (strlen(ptr) == 0)
+    if (NULL != ptr)
     {
-        return 0;
-    }
-    /* fprintf(stderr,"ptr='%s'\n",ptr); */
-    n = 1;
-    for (i = 0; (ptr[i] != '\0'); i++)
-    {
-        is[cur] = isspace(ptr[i]);
-        if ((i > 0)  && (is[cur] && !is[prev]))
+        for (i = 0; (ptr[i] != '\0'); i++)
         {
-            n++;
+            is[cur] = isspace(ptr[i]);
+            if ((0 == i) && !is[cur])
+            {
+                n++;
+            }
+            else if ((i > 0)  && (!is[cur] && is[prev]))
+            {
+                n++;
+            }
+            cur = prev;
         }
-        cur = prev;
     }
     return n;
 }
@@ -690,6 +691,8 @@ int read_xvg_legend(const char *fn, double ***y, int *ny,
 
     *y = yy;
     sfree(tmpbuf);
+    sfree(base);
+    sfree(fmt);
 
     if (legend_nalloc > 0)
     {
diff --git a/src/gromacs/gmxana/correl.c b/src/gromacs/gmxana/correl.c
deleted file mode 100644 (file)
index a8c8c43..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2008, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
- * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
- * and including many others, as listed in the AUTHORS file in the
- * top-level source directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-
-#include "gmxpre.h"
-
-#include "correl.h"
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "gromacs/fft/fft.h"
-#include "gromacs/utility/smalloc.h"
-
-#define SWAP(a, b) tempr = (a); (a) = (b); (b) = tempr
-
-void four1(real data[], int nn, int isign)
-{
-    int    n, mmax, m, j, istep, i;
-    double wtemp, wr, wpr, wpi, wi, theta;
-    real   tempr, tempi;
-
-    n = nn << 1;
-    j = 1;
-    for (i = 1; i < n; i += 2)
-    {
-        if (j > i)
-        {
-            SWAP(data[j], data[i]);
-            SWAP(data[j+1], data[i+1]);
-        }
-        m = n >> 1;
-        while (m >= 2 && j > m)
-        {
-            j  -= m;
-            m >>= 1;
-        }
-        j += m;
-    }
-    mmax = 2;
-    while (n > mmax)
-    {
-        istep = 2*mmax;
-        theta = 6.28318530717959/(isign*mmax);
-        wtemp = sin(0.5*theta);
-        wpr   = -2.0*wtemp*wtemp;
-        wpi   = sin(theta);
-        wr    = 1.0;
-        wi    = 0.0;
-        for (m = 1; m < mmax; m += 2)
-        {
-            for (i = m; i <= n; i += istep)
-            {
-                j          = i+mmax;
-                tempr      = wr*data[j]-wi*data[j+1];
-                tempi      = wr*data[j+1]+wi*data[j];
-                data[j]    = data[i]-tempr;
-                data[j+1]  = data[i+1]-tempi;
-                data[i]   += tempr;
-                data[i+1] += tempi;
-            }
-            wr = (wtemp = wr)*wpr-wi*wpi+wr;
-            wi = wi*wpr+wtemp*wpi+wi;
-        }
-        mmax = istep;
-    }
-}
-
-#undef SWAP
-
-static void realft(real data[], int n, int isign)
-{
-    int    i, i1, i2, i3, i4, n2p3;
-    real   c1 = 0.5, c2, h1r, h1i, h2r, h2i;
-    double wr, wi, wpr, wpi, wtemp, theta;
-
-    theta = 3.141592653589793/(double) n;
-    if (isign == 1)
-    {
-        c2 = -0.5;
-        four1(data, n, 1);
-    }
-    else
-    {
-        c2    = 0.5;
-        theta = -theta;
-    }
-    wtemp = sin(0.5*theta);
-    wpr   = -2.0*wtemp*wtemp;
-    wpi   = sin(theta);
-    wr    = 1.0+wpr;
-    wi    = wpi;
-    n2p3  = 2*n+3;
-    for (i = 2; i <= n/2; i++)
-    {
-        i4       = 1+(i3 = n2p3-(i2 = 1+(i1 = i+i-1)));
-        h1r      = c1*(data[i1]+data[i3]);
-        h1i      = c1*(data[i2]-data[i4]);
-        h2r      = -c2*(data[i2]+data[i4]);
-        h2i      = c2*(data[i1]-data[i3]);
-        data[i1] = h1r+wr*h2r-wi*h2i;
-        data[i2] = h1i+wr*h2i+wi*h2r;
-        data[i3] = h1r-wr*h2r+wi*h2i;
-        data[i4] = -h1i+wr*h2i+wi*h2r;
-        wr       = (wtemp = wr)*wpr-wi*wpi+wr;
-        wi       = wi*wpr+wtemp*wpi+wi;
-    }
-    if (isign == 1)
-    {
-        data[1] = (h1r = data[1])+data[2];
-        data[2] = h1r-data[2];
-    }
-    else
-    {
-        data[1] = c1*((h1r = data[1])+data[2]);
-        data[2] = c1*(h1r-data[2]);
-        four1(data, n, -1);
-    }
-}
-
-static void twofft(real data1[], real data2[], real fft1[], real fft2[], int n)
-{
-    int  nn3, nn2, jj, j;
-    real rep, rem, aip, aim;
-
-    nn3 = 1+(nn2 = 2+n+n);
-    for (j = 1, jj = 2; j <= n; j++, jj += 2)
-    {
-        fft1[jj-1] = data1[j];
-        fft1[jj]   = data2[j];
-    }
-    four1(fft1, n, 1);
-    fft2[1] = fft1[2];
-    fft1[2] = fft2[2] = 0.0;
-    for (j = 3; j <= n+1; j += 2)
-    {
-        rep         = 0.5*(fft1[j]+fft1[nn2-j]);
-        rem         = 0.5*(fft1[j]-fft1[nn2-j]);
-        aip         = 0.5*(fft1[j+1]+fft1[nn3-j]);
-        aim         = 0.5*(fft1[j+1]-fft1[nn3-j]);
-        fft1[j]     = rep;
-        fft1[j+1]   = aim;
-        fft1[nn2-j] = rep;
-        fft1[nn3-j] = -aim;
-        fft2[j]     = aip;
-        fft2[j+1]   = -rem;
-        fft2[nn2-j] = aip;
-        fft2[nn3-j] = rem;
-    }
-}
-
-void correl(real data1[], real data2[], int n, real ans[])
-{
-    int     no2, i;
-    real    dum, *fft;
-
-    snew(fft, 2*n+1);
-    twofft(data1, data2, fft, ans, n);
-    no2 = n/2;
-    for (i = 2; i <= n+2; i += 2)
-    {
-        dum      = ans[i-1];
-        ans[i-1] = (fft[i-1]*dum+fft[i]*ans[i])/no2;
-        ans[i]   = (fft[i]*dum-fft[i-1]*ans[i])/no2;
-    }
-    ans[2] = ans[n+1];
-    realft(ans, no2, -1);
-    sfree(fft);
-}
diff --git a/src/gromacs/gmxana/expfit.c b/src/gromacs/gmxana/expfit.c
deleted file mode 100644 (file)
index 61f9f76..0000000
+++ /dev/null
@@ -1,722 +0,0 @@
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
- * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
- * and including many others, as listed in the AUTHORS file in the
- * top-level source directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-#include "gmxpre.h"
-
-#include <math.h>
-#include <string.h>
-
-#include "gromacs/fileio/xvgr.h"
-#include "gromacs/gmxana/gstat.h"
-#include "gromacs/legacyheaders/typedefs.h"
-#include "gromacs/math/vec.h"
-#include "gromacs/utility/fatalerror.h"
-#include "gromacs/utility/futil.h"
-#include "gromacs/utility/smalloc.h"
-
-const int   nfp_ffn[effnNR] = { 0, 1, 2, 3, 2, 5, 7, 9, 4, 3};
-
-const char *s_ffn[effnNR+2] = {
-    NULL, "none", "exp", "aexp", "exp_exp", "vac",
-    "exp5", "exp7", "exp9", "erffit", NULL, NULL
-};
-/* We don't allow errest as a choice on the command line */
-
-const char *longs_ffn[effnNR] = {
-    "no fit",
-    "y = exp(-x/a1)",
-    "y = a2 exp(-x/a1)",
-    "y = a2 exp(-x/a1) + (1-a2) exp(-x/a3)",
-    "y = exp(-v) (cosh(wv) + 1/w sinh(wv)), v = x/(2 a1), w = sqrt(1 - a2)",
-    "y = a1 exp(-x/a2) +  a3 exp(-x/a4) + a5",
-    "y = a1 exp(-x/a2) +  a3 exp(-x/a4) + a5 exp(-x/a6) + a7",
-    "y = a1 exp(-x/a2) +  a3 exp(-x/a4) + a5 exp(-x/a6) + a7 exp(-x/a8) + a9",
-    "y = 1/2*(a1+a2) - 1/2*(a1-a2)*erf( (x-a3) /a4^2)",
-    "y = a2*ee(a1,x) + (1-a2)*ee(a2,x)"
-};
-
-extern gmx_bool mrqmin_new(real x[], real y[], real sig[], int ndata, real a[],
-                           int ia[], int ma, real **covar, real **alpha, real *chisq,
-                           void (*funcs)(real, real [], real *, real []),
-                           real *alamda);
-
-static real myexp(real x, real A, real tau)
-{
-    if ((A == 0) || (tau == 0))
-    {
-        return 0;
-    }
-    return A*exp(-x/tau);
-}
-
-void erffit (real x, real a[], real *y, real dyda[])
-{
-/* Fuction
- *     y=(a1+a2)/2-(a1-a2)/2*erf((x-a3)/a4^2)
- */
-
-    real erfarg;
-    real erfval;
-    real erfarg2;
-    real derf;
-
-    erfarg  = (x-a[3])/(a[4]*a[4]);
-    erfarg2 = erfarg*erfarg;
-    erfval  = gmx_erf(erfarg)/2;
-    derf    = M_2_SQRTPI*(a[1]-a[2])/2*exp(-erfarg2)/(a[4]*a[4]);
-    *y      = (a[1]+a[2])/2-(a[1]-a[2])*erfval;
-    dyda[1] = 1/2-erfval;
-    dyda[2] = 1/2+erfval;
-    dyda[3] = derf;
-    dyda[4] = 2*derf*erfarg;
-}
-
-
-
-static void exp_one_parm(real x, real a[], real *y, real dyda[])
-{
-    /* Fit to function
-     *
-     * y = exp(-x/a1)
-     *
-     */
-
-    real e1;
-
-    e1      = exp(-x/a[1]);
-    *y      = e1;
-    dyda[1] = x*e1/sqr(a[1]);
-}
-
-static void exp_two_parm(real x, real a[], real *y, real dyda[])
-{
-    /* Fit to function
-     *
-     * y = a2 exp(-x/a1)
-     *
-     */
-
-    real e1;
-
-    e1      = exp(-x/a[1]);
-    *y      = a[2]*e1;
-    dyda[1] = x*a[2]*e1/sqr(a[1]);
-    dyda[2] = e1;
-}
-
-static void exp_3_parm(real x, real a[], real *y, real dyda[])
-{
-    /* Fit to function
-     *
-     * y = a2 exp(-x/a1) + (1-a2) exp(-x/a3)
-     *
-     */
-
-    real e1, e2;
-
-    e1      = exp(-x/a[1]);
-    e2      = exp(-x/a[3]);
-    *y      = a[2]*e1 + (1-a[2])*e2;
-    dyda[1] = x*a[2]*e1/sqr(a[1]);
-    dyda[2] = e1-e2;
-    dyda[3] = x*(1-a[2])*e2/sqr(a[3]);
-}
-
-static void exp_5_parm(real x, real a[], real *y, real dyda[])
-{
-    /* Fit to function
-     *
-     * y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5
-     *
-     */
-
-    real e1, e2;
-
-    e1      = exp(-x/a[2]);
-    e2      = exp(-x/a[4]);
-    *y      = a[1]*e1 + a[3]*e2 + a[5];
-
-    if (debug)
-    {
-        fprintf(debug, "exp_5_parm called: x = %10.3f  y = %10.3f\n"
-                "a = ( %8.3f  %8.3f  %8.3f  %8.3f  %8.3f)\n",
-                x, *y, a[1], a[2], a[3], a[4], a[5]);
-    }
-    dyda[1] = e1;
-    dyda[2] = x*e1/sqr(a[2]);
-    dyda[3] = e2;
-    dyda[4] = x*e2/sqr(a[4]);
-    dyda[5] = 0;
-}
-
-static void exp_7_parm(real x, real a[], real *y, real dyda[])
-{
-    /* Fit to function
-     *
-     * y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7
-     *
-     */
-
-    real e1, e2, e3;
-
-    e1      = exp(-x/a[2]);
-    e2      = exp(-x/a[4]);
-    e3      = exp(-x/a[6]);
-    *y      = a[1]*e1 + a[3]*e2 + a[5]*e3 + a[7];
-
-    dyda[1] = e1;
-    dyda[2] = x*e1/sqr(a[2]);
-    dyda[3] = e2;
-    dyda[4] = x*e2/sqr(a[4]);
-    dyda[5] = e3;
-    dyda[6] = x*e3/sqr(a[6]);
-    dyda[7] = 0;
-}
-
-static void exp_9_parm(real x, real a[], real *y, real dyda[])
-{
-    /* Fit to function
-     *
-     * y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7
-     *
-     */
-
-    real e1, e2, e3, e4;
-
-    e1      = exp(-x/a[2]);
-    e2      = exp(-x/a[4]);
-    e3      = exp(-x/a[6]);
-    e4      = exp(-x/a[8]);
-    *y      = a[1]*e1 + a[3]*e2 + a[5]*e3 + a[7]*e4 + a[9];
-
-    dyda[1] = e1;
-    dyda[2] = x*e1/sqr(a[2]);
-    dyda[3] = e2;
-    dyda[4] = x*e2/sqr(a[4]);
-    dyda[5] = e3;
-    dyda[6] = x*e3/sqr(a[6]);
-    dyda[7] = e4;
-    dyda[8] = x*e4/sqr(a[8]);
-    dyda[9] = 0;
-}
-
-static void vac_2_parm(real x, real a[], real *y, real dyda[])
-{
-    /* Fit to function
-     *
-     * y = 1/2 (1 - 1/w) exp(-(1+w)v) + 1/2 (1 + 1/w) exp(-(1-w)v)
-     *
-     *   = exp(-v) (cosh(wv) + 1/w sinh(wv))
-     *
-     *    v = x/(2 a1)
-     *    w = sqrt(1 - a2)
-     *
-     *    For tranverse current autocorrelation functions:
-     *       a1 = tau
-     *       a2 = 4 tau (eta/rho) k^2
-     *
-     */
-
-    double v, det, omega, omega2, em, ec, es;
-
-    v   = x/(2*a[1]);
-    det = 1 - a[2];
-    em  = exp(-v);
-    if (det != 0)
-    {
-        omega2  = fabs(det);
-        omega   = sqrt(omega2);
-        if (det > 0)
-        {
-            ec = em*0.5*(exp(omega*v)+exp(-omega*v));
-            es = em*0.5*(exp(omega*v)-exp(-omega*v))/omega;
-        }
-        else
-        {
-            ec = em*cos(omega*v);
-            es = em*sin(omega*v)/omega;
-        }
-        *y      = ec + es;
-        dyda[2] = (v/det*ec+(v-1/det)*es)/(-2.0);
-        dyda[1] = (1-det)*v/a[1]*es;
-    }
-    else
-    {
-        *y      = (1+v)*em;
-        dyda[2] = -v*v*em*(0.5+v/6);
-        dyda[1] = v*v/a[1]*em;
-    }
-}
-
-static void errest_3_parm(real x, real a[], real *y, real dyda[])
-{
-    real e1, e2, v1, v2;
-
-    if (a[1])
-    {
-        e1 = exp(-x/a[1]) - 1;
-    }
-    else
-    {
-        e1 = 0;
-    }
-    if (a[3])
-    {
-        e2 = exp(-x/a[3]) - 1;
-    }
-    else
-    {
-        e2 = 0;
-    }
-
-    if (x > 0)
-    {
-        v1      = 2*a[1]*(e1*a[1]/x + 1);
-        v2      = 2*a[3]*(e2*a[3]/x + 1);
-        *y      = a[2]*v1 + (1-a[2])*v2;
-        dyda[1] = 2*     a[2] *(v1/a[1] + e1);
-        dyda[3] = 2*(1 - a[2])*(v2/a[3] + e2);
-        dyda[2] = (v1 - v2);
-    }
-    else
-    {
-        *y      = 0;
-        dyda[1] = 0;
-        dyda[3] = 0;
-        dyda[2] = 0;
-    }
-}
-
-typedef void (*myfitfn)(real x, real a[], real *y, real dyda[]);
-myfitfn mfitfn[effnNR] = {
-    exp_one_parm, exp_one_parm, exp_two_parm, exp_3_parm, vac_2_parm,
-    exp_5_parm,   exp_7_parm,   exp_9_parm, erffit,  errest_3_parm
-};
-
-real fit_function(int eFitFn, real *parm, real x)
-{
-    static real y, dum[8];
-
-    mfitfn[eFitFn](x, parm-1, &y, dum);
-
-    return y;
-}
-
-/* lmfit_exp supports up to 3 parameter fitting of exponential functions */
-static gmx_bool lmfit_exp(int nfit, real x[], real y[], real dy[], real ftol,
-                          real parm[], real dparm[], gmx_bool bVerbose,
-                          int eFitFn, int fix)
-{
-    real     chisq, ochisq, alamda;
-    real    *a, **covar, **alpha, *dum;
-    gmx_bool bCont;
-    int      i, j, ma, mfit, *lista, *ia;
-
-    if ((eFitFn < 0) || (eFitFn >= effnNR))
-    {
-        gmx_fatal(FARGS, "fitfn = %d, should be in 0..%d (%s,%d)",
-                  effnNR-1, eFitFn, __FILE__, __LINE__);
-    }
-
-    ma = mfit = nfp_ffn[eFitFn];   /* number of parameters to fit */
-    snew(a, ma+1);
-    snew(covar, ma+1);
-    snew(alpha, ma+1);
-    snew(lista, ma+1);
-    snew(ia, ma+1);
-    snew(dum, ma+1);
-    for (i = 1; (i < ma+1); i++)
-    {
-        lista[i] = i;
-        ia[i]    = 1; /* fixed bug B.S.S 19/11  */
-        snew(covar[i], ma+1);
-        snew(alpha[i], ma+1);
-    }
-    if (fix)
-    {
-        if (bVerbose)
-        {
-            fprintf(stderr, "Will keep parameters fixed during fit procedure: %d\n",
-                    fix);
-        }
-        for (i = 0; i < ma; i++)
-        {
-            if (fix & 1<<i)
-            {
-                ia[i+1] = 0;
-            }
-        }
-    }
-    if (debug)
-    {
-        fprintf(debug, "%d parameter fit\n", mfit);
-    }
-
-    /* Initial params */
-    alamda = -1;  /* Starting value   */
-    chisq  = 1e12;
-    for (i = 0; (i < mfit); i++)
-    {
-        a[i+1] = parm[i];
-    }
-
-    j = 0;
-    if (bVerbose)
-    {
-        fprintf(stderr, "%4s  %10s  %10s  %10s  %10s  %10s %10s\n",
-                "Step", "chi^2", "Lambda", "A1", "A2", "A3", "A4");
-    }
-    do
-    {
-        ochisq = chisq;
-        /* mrqmin(x-1,y-1,dy-1,nfit,a,ma,lista,mfit,covar,alpha,
-         *   &chisq,expfn[mfit-1],&alamda)
-         */
-        if (!mrqmin_new(x-1, y-1, dy-1, nfit, a, ia, ma, covar, alpha, &chisq,
-                        mfitfn[eFitFn], &alamda))
-        {
-            return FALSE;
-        }
-
-        if (bVerbose)
-        {
-            fprintf(stderr, "%4d  %10.5e  %10.5e  %10.5e",
-                    j, chisq, alamda, a[1]);
-            if (mfit > 1)
-            {
-                fprintf(stderr, "  %10.5e", a[2]);
-            }
-            if (mfit > 2)
-            {
-                fprintf(stderr, "  %10.5e", a[3]);
-            }
-            if (mfit > 3)
-            {
-                fprintf(stderr, " %10.5e", a[4]);
-            }
-            fprintf(stderr, "\n");
-        }
-        j++;
-        bCont = ((fabs(ochisq - chisq) > fabs(ftol*chisq)) ||
-                 ((ochisq == chisq)));
-    }
-    while (bCont && (alamda != 0.0) && (j < 50));
-    if (bVerbose)
-    {
-        fprintf(stderr, "\n");
-    }
-
-    /* Now get the covariance matrix out */
-    alamda = 0;
-
-    /*  mrqmin(x-1,y-1,dy-1,nfit,a,ma,lista,mfit,covar,alpha,
-     * &chisq,expfn[mfit-1],&alamda)
-     */
-    if (!mrqmin_new(x-1, y-1, dy-1, nfit, a, ia, ma, covar, alpha, &chisq,
-                    mfitfn[eFitFn], &alamda))
-    {
-        return FALSE;
-    }
-
-    for (j = 0; (j < mfit); j++)
-    {
-        parm[j]  = a[j+1];
-        dparm[j] = covar[j+1][j+1];
-    }
-
-    for (i = 0; (i < ma+1); i++)
-    {
-        sfree(covar[i]);
-        sfree(alpha[i]);
-    }
-    sfree(a);
-    sfree(covar);
-    sfree(alpha);
-    sfree(lista);
-    sfree(dum);
-
-    return TRUE;
-}
-
-real do_lmfit(int ndata, real c1[], real sig[], real dt, real x0[],
-              real begintimefit, real endtimefit, const output_env_t oenv,
-              gmx_bool bVerbose, int eFitFn, real fitparms[], int fix)
-{
-    FILE *fp;
-    char  buf[32];
-
-    int   i, j, nparm, nfitpnts;
-    real  integral, ttt;
-    real *parm, *dparm;
-    real *x, *y, *dy;
-    real  ftol = 1e-4;
-
-    nparm = nfp_ffn[eFitFn];
-    if (debug)
-    {
-        fprintf(debug, "There are %d points to fit %d vars!\n", ndata, nparm);
-        fprintf(debug, "Fit to function %d from %g through %g, dt=%g\n",
-                eFitFn, begintimefit, endtimefit, dt);
-    }
-
-    snew(x, ndata);
-    snew(y, ndata);
-    snew(dy, ndata);
-
-    j = 0;
-    for (i = 0; i < ndata; i++)
-    {
-        ttt = x0 ? x0[i] : dt*i;
-        if (ttt >= begintimefit && ttt <= endtimefit)
-        {
-            x[j] = ttt;
-            y[j] = c1[i];
-
-            /* mrqmin does not like sig to be zero */
-            if (sig[i] < 1.0e-7)
-            {
-                dy[j] = 1.0e-7;
-            }
-            else
-            {
-                dy[j] = sig[i];
-            }
-            if (debug)
-            {
-                fprintf(debug, "j= %d, i= %d, x= %g, y= %g, dy= %g\n",
-                        j, i, x[j], y[j], dy[j]);
-            }
-            j++;
-        }
-    }
-    nfitpnts = j;
-    integral = 0;
-    if (nfitpnts < nparm)
-    {
-        fprintf(stderr, "Not enough data points for fitting!\n");
-    }
-    else
-    {
-        snew(parm, nparm);
-        snew(dparm, nparm);
-        if (fitparms)
-        {
-            for (i = 0; (i < nparm); i++)
-            {
-                parm[i] = fitparms[i];
-            }
-        }
-
-        if (!lmfit_exp(nfitpnts, x, y, dy, ftol, parm, dparm, bVerbose, eFitFn, fix))
-        {
-            fprintf(stderr, "Fit failed!\n");
-        }
-        else if (nparm <= 3)
-        {
-            /* Compute the integral from begintimefit */
-            if (nparm == 3)
-            {
-                integral = (parm[0]*myexp(begintimefit, parm[1],  parm[0]) +
-                            parm[2]*myexp(begintimefit, 1-parm[1], parm[2]));
-            }
-            else if (nparm == 2)
-            {
-                integral = parm[0]*myexp(begintimefit, parm[1],  parm[0]);
-            }
-            else if (nparm == 1)
-            {
-                integral = parm[0]*myexp(begintimefit, 1,  parm[0]);
-            }
-            else
-            {
-                gmx_fatal(FARGS, "nparm = %d in file %s, line %d",
-                          nparm, __FILE__, __LINE__);
-            }
-
-            /* Generate THE output */
-            if (bVerbose)
-            {
-                fprintf(stderr, "FIT: # points used in fit is: %d\n", nfitpnts);
-                fprintf(stderr, "FIT: %21s%21s%21s\n",
-                        "parm0     ", "parm1 (ps)   ", "parm2 (ps)    ");
-                fprintf(stderr, "FIT: ------------------------------------------------------------\n");
-                fprintf(stderr, "FIT: %8.3g +/- %8.3g%9.4g +/- %8.3g%8.3g +/- %8.3g\n",
-                        parm[0], dparm[0], parm[1], dparm[1], parm[2], dparm[2]);
-                fprintf(stderr, "FIT: Integral (calc with fitted function) from %g ps to inf. is: %g\n",
-                        begintimefit, integral);
-
-                sprintf(buf, "test%d.xvg", nfitpnts);
-                fp = xvgropen(buf, "C(t) + Fit to C(t)", "Time (ps)", "C(t)", oenv);
-                fprintf(fp, "# parm0 = %g, parm1 = %g, parm2 = %g\n",
-                        parm[0], parm[1], parm[2]);
-                for (j = 0; (j < nfitpnts); j++)
-                {
-                    ttt = x0 ? x0[j] : dt*j;
-                    fprintf(fp, "%10.5e  %10.5e  %10.5e\n",
-                            ttt, c1[j], fit_function(eFitFn, parm, ttt));
-                }
-                xvgrclose(fp);
-            }
-        }
-        if (fitparms)
-        {
-            for (i = 0; (i < nparm); i++)
-            {
-                fitparms[i] = parm[i];
-            }
-        }
-        sfree(parm);
-        sfree(dparm);
-    }
-
-    sfree(x);
-    sfree(y);
-    sfree(dy);
-
-    return integral;
-}
-
-void do_expfit(int ndata, real c1[], real dt, real begintimefit, real endtimefit)
-{
-    int   i, n;
-    real *x, *y, *Dy;
-    real  aa, bb, saa, sbb, A, tau, dA, dtau;
-
-    fprintf(stderr, "Will fit data from %g (ps) to %g (ps).\n",
-            begintimefit, endtimefit);
-
-    snew(x, ndata); /* allocate the maximum necessary space */
-    snew(y, ndata);
-    snew(Dy, ndata);
-    n = 0;
-
-    for (i = 0; (i < ndata); i++)
-    {
-        if ( (dt*i >= begintimefit) && (dt*i <= endtimefit) )
-        {
-            x[n]  = dt*i;
-            y[n]  = c1[i];
-            Dy[n] = 0.5;
-            fprintf(stderr, "n= %d, i= %d, x= %g, y= %g\n", n, i, x[n], y[n]);
-            n++;
-        }
-    }
-    fprintf(stderr, "# of data points used in the fit is : %d\n\n", n);
-    expfit(n, x, y, Dy, &aa, &saa, &bb, &sbb);
-
-    A    = exp(aa);
-    dA   = exp(aa)*saa;
-    tau  = -1.0/bb;
-    dtau = sbb/sqr(bb);
-    fprintf(stderr, "Fitted to y=exp(a+bx):\n");
-    fprintf(stderr, "a = %10.5f\t b = %10.5f", aa, bb);
-    fprintf(stderr, "\n");
-    fprintf(stderr, "Fitted to y=Aexp(-x/tau):\n");
-    fprintf(stderr, "A  = %10.5f\t tau  = %10.5f\n", A, tau);
-    fprintf(stderr, "dA = %10.5f\t dtau = %10.5f\n", dA, dtau);
-}
-
-
-void expfit(int n, real *x, real *y, real *Dy, real *a, real *sa,
-            real *b, real *sb)
-{
-    real *w, *ly, A, SA, B, SB;
-    int   i;
-    real  sum, xbar, ybar, Sxx, Sxy, wr2, chi2, gamma, Db;
-
-#define ZERO 0.0
-#define ONE 1.0
-#define ONEP5 1.5
-#define TWO 2.0
-
-#define sqr(x) ((x)*(x))
-
-    /*allocate memory */
-    snew(w, n);
-    snew(ly, n);
-
-    /* Calculate weights and values of ln(y). */
-    for (i = 0; (i < n); i++)
-    {
-        w[i]  = sqr(y[i]/Dy[i]);
-        ly[i] = log(y[i]);
-    }
-
-    /* The weighted averages of x and y: xbar and ybar. */
-    sum  = ZERO;
-    xbar = ZERO;
-    ybar = ZERO;
-    for (i = 0; (i < n); i++)
-    {
-        sum  += w[i];
-        xbar += w[i]*x[i];
-        ybar += w[i]*ly[i];
-    }
-    xbar /= sum;
-    ybar /= sum;
-
-    /* The centered product sums Sxx and Sxy, and hence A and B. */
-    Sxx = ZERO;
-    Sxy = ZERO;
-    for (i = 0; (i < n); i++)
-    {
-        Sxx += w[i]*sqr(x[i]-xbar);
-        Sxy += w[i]*(x[i]-xbar)*(ly[i]-ybar);
-    }
-    B = Sxy/Sxx;
-    A = ybar-B*xbar;
-
-    /* Chi-squared (chi2) and gamma. */
-    chi2  = ZERO;
-    gamma = ZERO;
-    for (i = 0; (i < n); i++)
-    {
-        wr2    = w[i]*sqr(ly[i]-A-B*x[i]);
-        chi2  += wr2;
-        gamma += wr2*(x[i]-xbar);
-    }
-
-    /* Refined values of A and B. Also SA and SB. */
-    Db  = -ONEP5*gamma/Sxx;
-    B  += Db;
-    A  -= ONEP5*chi2/sum-xbar*Db;
-    SB  = sqrt((chi2/(n-2))/Sxx);
-    SA  = SB*sqrt(Sxx/sum+sqr(xbar));
-    *a  = A;
-    *b  = B;
-    *sa = SA;
-    *sb = SB;
-}
index a2f9799621121539723b8758fdf3377a8a05f378..8d1eab6bee08e2ce8bb27576d8717a506d94a437 100644 (file)
@@ -41,6 +41,9 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
+#include "gromacs/correlationfunctions/expfit.h"
+#include "gromacs/correlationfunctions/integrate.h"
 #include "gromacs/fileio/xvgr.h"
 #include "gromacs/gmxana/geminate.h"
 #include "gromacs/gmxana/gmx_ana.h"
@@ -391,7 +394,7 @@ static void average(const char *avfile, int avbar_opt,
     }
 }
 
-static real anal_ee_inf(real *parm, real T)
+static real anal_ee_inf(double *parm, real T)
 {
     return sqrt(parm[1]*2*parm[0]/T+parm[3]*2*parm[2]/T);
 }
@@ -408,7 +411,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
     double   blav, var;
     char   **leg;
     real    *tbs, *ybs, rtmp, dens, *fitsig, twooe, tau1_est, tau_sig;
-    real     fitparm[4];
+    double   fitparm[4];
     real     ee, a, tau1, tau2;
 
     if (n < 4)
@@ -628,8 +631,9 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
 
         if (bFitAc)
         {
-            int   fitlen;
-            real *ac, acint, ac_fit[4];
+            int    fitlen;
+            real  *ac, acint;
+            double ac_fit[4];
 
             snew(ac, n);
             for (i = 0; i < n; i++)
@@ -787,14 +791,15 @@ static void do_fit(FILE *out, int n, gmx_bool bYdy,
                    int ny, real *x0, real **val,
                    int npargs, t_pargs *ppa, const output_env_t oenv)
 {
-    real *c1 = NULL, *sig = NULL, *fitparm;
-    real  tendfit, tbeginfit;
-    int   i, efitfn, nparm;
+    real   *c1 = NULL, *sig = NULL;
+    double *fitparm;
+    real    tendfit, tbeginfit;
+    int     i, efitfn, nparm;
 
     efitfn = get_acffitfn();
-    nparm  = nfp_ffn[efitfn];
+    nparm  = effnNparams(efitfn);
     fprintf(out, "Will fit to the following function:\n");
-    fprintf(out, "%s\n", longs_ffn[efitfn]);
+    fprintf(out, "%s\n", effnDescription(efitfn));
     c1 = val[n];
     if (bYdy)
     {
index 2a093478e48932698edd6c70f55137a963b5a9d7..544842106f8522995744fbf9ce77b621fb2fd1bf 100644 (file)
@@ -40,6 +40,7 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
 #include "gromacs/fileio/trnio.h"
 #include "gromacs/fileio/xvgr.h"
 #include "gromacs/gmxana/gmx_ana.h"
@@ -55,7 +56,6 @@
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
 
-
 static void dump_dih_trn(int nframes, int nangles, real **dih, const char *fn,
                          real *time)
 {
index 8c377df06afe31642c6b944f64a07c1051f94332..3717abb12b7aa429718327d7319bde4e3291c0f7 100644 (file)
@@ -41,6 +41,7 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/matio.h"
 #include "gromacs/fileio/pdbio.h"
@@ -59,6 +60,7 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
+#include "gmx_ana.h"
 
 static gmx_bool bAllowed(real phi, real psi)
 {
index 99f68079920b4084ee6dfc0173034af85a1b4511..bf4f6c68eae8d774fb74cf7813803fa13d7e72f1 100644 (file)
@@ -39,6 +39,8 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
+#include "gromacs/correlationfunctions/expfit.h"
 #include "gromacs/fileio/matio.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
@@ -353,21 +355,21 @@ static void interfaces_txy (real ****Densmap, int xslices, int yslices, int zsli
                             t_interf ****intf2, const output_env_t oenv)
 {
     /*Returns two pointers to 3D arrays of t_interf structs containing (position,thickness) of the interface(s)*/
-    FILE       *xvg;
-    real       *zDensavg; /* zDensavg[z]*/
-    int         i, j, k, n;
-    int         xysize;
-    int         ndx1, ndx2, *zperm;
-    real        densmid;
-    real        splitpoint, startpoint, endpoint;
-    real       *sigma1, *sigma2;
-    real        beginfit1[4];
-    real        beginfit2[4];
-    real       *fit1 = NULL, *fit2 = NULL;
-    const real *avgfit1;
-    const real *avgfit2;
-    const real  onehalf = 1.00/2.00;
-    t_interf ***int1    = NULL, ***int2 = NULL; /*Interface matrices [t][x,y] - last index in row-major order*/
+    FILE         *xvg;
+    real         *zDensavg; /* zDensavg[z]*/
+    int           i, j, k, n;
+    int           xysize;
+    int           ndx1, ndx2, *zperm;
+    real          densmid;
+    real          splitpoint, startpoint, endpoint;
+    real         *sigma1, *sigma2;
+    double        beginfit1[4];
+    double        beginfit2[4];
+    double       *fit1 = NULL, *fit2 = NULL;
+    const double *avgfit1;
+    const double *avgfit2;
+    const real    onehalf = 1.00/2.00;
+    t_interf   ***int1    = NULL, ***int2 = NULL; /*Interface matrices [t][x,y] - last index in row-major order*/
     /*Create int1(t,xy) and int2(t,xy) arrays with correct number of interf_t elements*/
     xysize = xslices*yslices;
     snew(int1, tblocks);
index 5f4ce8844609862a753050b9da8b6464a1154dbc..18d1d4a38bd2fe161a7e5f071789b1713fe21f3c 100644 (file)
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
+#include "gromacs/correlationfunctions/expfit.h"
+#include "gromacs/correlationfunctions/integrate.h"
+#include "gromacs/fft/fft.h"
 #include "gromacs/fileio/xvgr.h"
-#include "gromacs/gmxana/correl.h"
 #include "gromacs/gmxana/gmx_ana.h"
 #include "gromacs/gmxana/gstat.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/math/gmxcomplex.h"
+#include "gromacs/math/utilities.h"
+#include "gmx_ana.h"
 
 /* Determines at which point in the array the fit should start */
 int calc_nbegin(int nx, real x[], real tbegin)
@@ -155,6 +162,8 @@ void do_four(const char *fn, const char *cn, int nx, real x[], real dy[],
     t_complex *tmp, gw, hw, kw;
     int        i, nnx, nxsav;
     real       fac, nu, dt, *ptr, maxeps, numax;
+    gmx_fft_t  fft;
+    int        fftcode;
 
     nxsav = nx;
     /*while ((dy[nx-1] == 0.0) && (nx > 0))
@@ -169,15 +178,24 @@ void do_four(const char *fn, const char *cn, int nx, real x[], real dy[],
     {
         nnx *= 2;
     }
+
     snew(tmp, 2*nnx);
     printf("Doing FFT of %d points\n", nnx);
     for (i = 0; (i < nx); i++)
     {
         tmp[i].re = dy[i];
     }
-    ptr = &tmp[0].re;
-    four1(ptr-1, nnx, -1);
-
+    if ((fftcode = gmx_fft_init_1d_real(&fft, nnx,
+                                        GMX_FFT_FLAG_NONE)) != 0)
+    {
+        gmx_fatal(FARGS, "gmx_fft_init_1d_real returned %d", fftcode);
+    }
+    if ((fftcode = gmx_fft_1d_real(fft, GMX_FFT_COMPLEX_TO_REAL,
+                                   (void *)tmp, (void *)tmp)) != 0)
+    {
+        gmx_fatal(FARGS, "gmx_fft_1d_real returned %d", fftcode);
+    }
+    gmx_fft_destroy(fft);
     dt = x[1]-x[0];
     if (epsRF == 0)
     {
@@ -259,17 +277,16 @@ int gmx_dielectric(int argc, char *argv[])
 #define NFILE asize(fnm)
     output_env_t oenv;
     int          i, j, nx, ny, nxtail, eFitFn, nfitparm;
-    real         dt, integral, fitintegral, *fitparms, fac, rffac;
+    real         dt, integral, fitintegral, fac, rffac;
+    double      *fitparms;
     double     **yd;
     real       **y;
     const char  *legend[] = { "Correlation", "Std. Dev.", "Fit", "Combined", "Derivative" };
-    static int   fix      = 0, bFour = 0, bX = 1, nsmooth = 3;
+    static int   fix      = 0, bX = 1, nsmooth = 3;
     static real  tendInt  = 5.0, tbegin = 5.0, tend = 500.0;
     static real  A        = 0.5, tau1 = 10.0, tau2 = 1.0, eps0 = 80, epsRF = 78.5, tail = 500.0;
     real         lambda;
     t_pargs      pa[] = {
-        { "-fft", FALSE, etBOOL, {&bFour},
-          "use fast fourier transform for correlation function" },
         { "-x1",  FALSE, etBOOL, {&bX},
           "use first column as [IT]x[it]-axis rather than first data set" },
         { "-eint", FALSE, etREAL, {&tendInt},
@@ -358,7 +375,7 @@ int gmx_dielectric(int argc, char *argv[])
     }
 
     eFitFn   = sffn2effn(s_ffn);
-    nfitparm = nfp_ffn[eFitFn];
+    nfitparm = effnNparams(eFitFn);
     snew(fitparms, 4);
     fitparms[0] = tau1;
     if (nfitparm > 1)
index b0f4c12451402e6cb237c5a409ac6c983336fb87..f13e0da1116725fa664b8a687be5f0826e334fc0 100644 (file)
 #include <algorithm>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
 #include "gromacs/fileio/enxio.h"
 #include "gromacs/fileio/matio.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/fileio/xvgr.h"
 #include "gromacs/gmxana/gmx_ana.h"
-#include "gromacs/gmxana/gstat.h"
 #include "gromacs/legacyheaders/calcmu.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/macros.h"
index 65b6eaad3d211c7bd560d8843c1b33406c39f47f..560ab280f550d58b14275e0c2a87c726f7b7fe2e 100644 (file)
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
+#include "gromacs/correlationfunctions/integrate.h"
 #include "gromacs/fft/fft.h"
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/fileio/xvgr.h"
-#include "gromacs/gmxana/correl.h"
 #include "gromacs/gmxana/gmx_ana.h"
-#include "gromacs/gmxana/gstat.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/txtdump.h"
@@ -58,6 +58,7 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
+#include "gmx_ana.h"
 
 enum {
     VACF, MVACF, DOS, DOS_SOLID, DOS_DIFF, DOS_CP, DOS_S, DOS_A, DOS_E, DOS_NR
index 3319c96e81e0a98a7c0dcc89e7ef2c5d6a58d5eb..eca1ca6166df976f507a728af3b8aeafe21c2783 100644 (file)
@@ -41,6 +41,7 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
 #include "gromacs/fileio/enxio.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
index a1f3622fdcc50286a41cf0bc0998f35d857f524d..ebf112f28632756566046d7f7320f11e85547ce7 100644 (file)
@@ -40,6 +40,7 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/fileio/xvgr.h"
@@ -56,6 +57,7 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
+#include "gmx_ana.h"
 
 real calc_gyro(rvec x[], int gnx, atom_id index[], t_atom atom[], real tm,
                rvec gvec, rvec d, gmx_bool bQ, gmx_bool bRot, gmx_bool bMOI, matrix trans)
index 5d960071a7e80b64503180e44fe66f79180081b9..3e9acb11c9acb90bc6720027a71e355ac34d623d 100644 (file)
 #include <math.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
+#include "gromacs/correlationfunctions/crosscorr.h"
+#include "gromacs/correlationfunctions/expfit.h"
+#include "gromacs/correlationfunctions/integrate.h"
 #include "gromacs/fileio/matio.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/fileio/xvgr.h"
-#include "gromacs/gmxana/correl.h"
 #include "gromacs/gmxana/geminate.h"
 #include "gromacs/gmxana/gmx_ana.h"
-#include "gromacs/gmxana/gstat.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/txtdump.h"
@@ -63,6 +65,8 @@
 #include "gromacs/utility/gmxomp.h"
 #include "gromacs/utility/smalloc.h"
 
+#include "geminate.h"
+
 /*#define HAVE_NN_LOOPS*/
 
 typedef short int t_E;
@@ -2374,9 +2378,10 @@ static real compute_weighted_rates(int n, real t[], real ct[], real nt[],
 static void smooth_tail(int n, real t[], real c[], real sigma_c[], real start,
                         const output_env_t oenv)
 {
-    FILE *fp;
-    real  e_1, fitparm[4];
-    int   i;
+    FILE  *fp;
+    real   e_1;
+    double fitparm[4];
+    int    i;
 
     e_1 = exp(-1);
     for (i = 0; (i < n); i++)
@@ -2395,7 +2400,8 @@ static void smooth_tail(int n, real t[], real c[], real sigma_c[], real start,
         fitparm[0] = 10;
     }
     fitparm[1] = 0.95;
-    do_lmfit(n, c, sigma_c, 0, t, start, t[n-1], oenv, bDebugMode(), effnEXP2, fitparm, 0);
+    do_lmfit(n, c, sigma_c, 0, t, start, t[n-1], oenv, bDebugMode(),
+             effnEXP2, fitparm, 0);
 }
 
 void analyse_corr(int n, real t[], real ct[], real nt[], real kt[],
index 47c4bc0c6fdb45e6165e0ec4884ac8738768c99e..4dda9da2ff3e07afa08b545938b9db4e928664ef 100644 (file)
@@ -40,6 +40,7 @@
 #include <math.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/integrate.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/fileio/xvgr.h"
index 4eb9a6ec18f871da561d2c3b1b38d9da4fe9e424..e48fc483f262fa549f38bf5da9608fdefa17dc33 100644 (file)
@@ -40,9 +40,9 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/gmxana/gmx_ana.h"
-#include "gromacs/gmxana/gstat.h"
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/legacyheaders/viewit.h"
index b676ffc6a2deba541021747d1c64ff300852cb59..668073ef659691f694696b28299fc81a6fdf5e8d 100644 (file)
@@ -41,6 +41,8 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
+#include "gromacs/correlationfunctions/expfit.h"
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/trxio.h"
 #include "gromacs/fileio/xvgr.h"
@@ -59,7 +61,6 @@
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
 
-
 #define NK  24
 #define NPK 4
 
@@ -79,10 +80,10 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac,
 {
     FILE  *fp, *fp_vk, *fp_cub = NULL;
     int    nk, ntc;
-    real **tcaf, **tcafc = NULL, eta;
+    real **tcaf, **tcafc = NULL, eta, *sig;
     int    i, j, k, kc;
     int    ncorr;
-    real   fitparms[3], *sig;
+    double fitparms[3];
 
     nk  = kset_c[nkc];
     ntc = nk*NPK;
index 34c378d3a406dfa324a2f232797803146a9aa20e..c66255db2368fec7a28e1b26a481ad83da6b7462 100644 (file)
@@ -41,6 +41,7 @@
 #include <string.h>
 
 #include "gromacs/commandline/pargs.h"
+#include "gromacs/correlationfunctions/autocorr.h"
 #include "gromacs/fft/fft.h"
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/trxio.h"
@@ -58,6 +59,7 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
+#include "gmx_ana.h"
 
 static void index_atom2mol(int *n, atom_id *index, t_block *mols)
 {
index a07b3ed51307e063669b58aa15f280744273312f..ac08579eb501cb5640387cc00a67a3b0fba0a0f3 100644 (file)
@@ -48,30 +48,6 @@ extern "C" {
 
 struct gmx_residuetype_t;
 
-/***********************************************
- *
- *     A U T O C O R R E L A T I O N
- *
- ***********************************************/
-
-real LegendreP(real x, unsigned long m);
-
-#define eacNormal (1<<0)
-#define eacCos    (1<<1)
-#define eacVector (1<<2)
-#define eacRcross (1<<3  | eacVector)
-#define eacP0     (1<<4  | eacVector)
-#define eacP1     (1<<5  | eacVector)
-#define eacP2     (1<<6  | eacVector)
-#define eacP3     (1<<7  | eacVector)
-#define eacP4     (1<<8  | eacVector)
-#define eacIden   (1<<9)
-
-enum {
-    effnNONE, effnEXP1, effnEXP2, effnEXP3,   effnVAC,
-    effnEXP5, effnEXP7, effnEXP9, effnERF, effnERREST, effnNR
-};
-
 /* must correspond with 'leg' g_chi.c:727 */
 enum {
     edPhi = 0, edPsi, edOmega, edChi1, edChi2, edChi3, edChi4, edChi5, edChi6, edMax
@@ -103,95 +79,6 @@ typedef struct {
 
 } t_dlist;
 
-extern const int   nfp_ffn[effnNR];
-
-extern const char *s_ffn[effnNR+2];
-
-extern const char *longs_ffn[effnNR];
-
-int sffn2effn(const char **sffn);
-/* Returns the ffn enum corresponding to the selected enum option in sffn */
-
-t_pargs *add_acf_pargs(int *npargs, t_pargs *pa);
-/* Add options for autocorr to the current set of options.
- * *npargs must be initialised to the number of elements in pa,
- * it will be incremented appropriately.
- */
-
-void cross_corr(int n, real f[], real g[], real corr[]);
-/* Simple minded cross correlation algorithm */
-
-real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose,
-             real tbeginfit, real tendfit, real dt, real c1[], real *fit);
-/* Fit an ACF to a given function */
-
-void do_autocorr(const char *fn, const output_env_t oenv,
-                 const char *title,
-                 int nframes, int nitem, real **c1,
-                 real dt, unsigned long mode, gmx_bool bAver);
-/* Calls low_do_autocorr (see below). After calling add_acf_pargs */
-
-void low_do_autocorr(const char *fn, const output_env_t oenv,
-                     const char *title, int  nframes, int nitem,
-                     int nout, real **c1, real dt, unsigned long mode,
-                     int nrestart, gmx_bool bAver, gmx_bool bNormalize,
-                     gmx_bool bVerbose, real tbeginfit, real tendfit,
-                     int nfitparm);
-/*
- * do_autocorr calculates autocorrelation functions for many things.
- * It takes a 2 d array containing nitem arrays of length nframes
- * for each item the ACF is calculated.
- *
- * A number of "modes" exist for computation of the ACF
- *
- * if (mode == eacNormal) {
- *   C(t) = < X (tau) * X (tau+t) >
- * }
- * else if (mode == eacCos) {
- *   C(t) = < cos (X(tau) - X(tau+t)) >
- * }
- * else if (mode == eacIden) { **not fully supported yet**
- *   C(t) = < (X(tau) == X(tau+t)) >
- * }
- * else if (mode == eacVector) {
- *   C(t) = < X(tau) * X(tau+t)
- * }
- * else if (mode == eacP1) {
- *   C(t) = < cos (X(tau) * X(tau+t) >
- * }
- * else if (mode == eacP2) {
- *   C(t) = 1/2 * < 3 cos (X(tau) * X(tau+t) - 1 >
- * }
- * else if (mode == eacRcross) {
- *   C(t) = < ( X(tau) * X(tau+t) )^2 >
- * }
- *
- * For modes eacVector, eacP1, eacP2 and eacRcross the input should be
- * 3 x nframes long, where each triplet is taken as a 3D vector
- *
- * For mode eacCos inputdata must be in radians, not degrees!
- *
- * Other parameters are:
- *
- * fn is output filename (.xvg) where the correlation function(s) are printed
- * title is the title in the output file
- * nframes is the number of frames in the time series
- * nitem is the number of items
- * c1       is an array of dimension [ 0 .. nitem-1 ] [ 0 .. nframes-1 ]
- *          on output, this array is filled with the correlation function
- *          to reduce storage
- * nrestart     is the number of steps between restarts for direct ACFs
- *              (i.e. without FFT) When set to 1 all points are used as
- *              time origin for averaging
- * dt       is the time between frames
- * bAver    If set, all ndih C(t) functions are averaged into a single
- *          C(t)
- * (bFour       If set, will use fast fourier transform (FFT) for evaluating
- *              the ACF: removed option, now on the command line only)
- * bNormalize   If set, all ACFs will be normalized to start at 0
- * nskip        Determines whether steps a re skipped in the output
- */
-
 typedef struct {
     const char *name;    /* Description of the J coupling constant */
     real        A, B, C; /* Karplus coefficients */
@@ -226,25 +113,6 @@ void calc_distribution_props(int nh, int histo[],
  *
  */
 
-
-/***********************************************
- *
- *     F I T   R O U T I N E S
- *
- ***********************************************/
-void do_expfit(int ndata, real c1[], real dt,
-               real begintimefit, real endtimefit);
-
-void expfit(int n, real x[], real y[], real Dy[],
-            real *a, real *sa,
-            real *b, real *sb);
-/* This procedure fits y=exp(a+bx) for n (x,y) pairs to determine a and b.
- * The uncertainties in the y values must be in the vector Dy.
- * The standard deviations of a and b, sa and sb, are also calculated.
- *
- * Routine from Computers in physics, 7(3) (1993), p. 280-285.
- */
-
 void ana_dih_trans(const char *fn_trans, const char *fn_histo,
                    real **dih, int nframes, int nangles,
                    const char *grpname, real *time, gmx_bool bRb,
@@ -347,47 +215,6 @@ void normalize_histo(int npoints, int histo[], real dx, real normhisto[]);
  * normhisto  normalized output histogram
  */
 
-real fit_function(int eFitFn, real *parm, real x);
-/* Returns the value of fit function eFitFn at x */
-
-/* Use Levenberg-Marquardt method to fit to a nfitparm parameter exponential */
-/* or to a transverse current autocorrelation function */
-/* Or: "There is no KILL like OVERKILL", Dr. Ir. D. van der Spoel */
-real do_lmfit(int ndata, real c1[], real sig[], real dt, real *x,
-              real begintimefit, real endtimefit, const output_env_t oenv,
-              gmx_bool bVerbose, int eFitFn, real fitparms[], int fix);
-/* Returns integral.
- * If x == NULL, the timestep dt will be used to create a time axis.
- * fix fixes fit parameter i at it's starting value, when the i'th bit
- * of fix is set.
- */
-
-real evaluate_integral(int n, real x[], real y[], real dy[],
-                       real aver_start, real *stddev);
-/* Integrate data in y, and, if given, use dy as weighting
- * aver_start should be set to a value where the function has
- * converged to 0.
- */
-
-real print_and_integrate(FILE *fp, int n, real dt,
-                         real c[], real *fit, int nskip);
-/* Integrate the data in c[] from 0 to n using trapezium rule.
- * If fp != NULL output is written to it
- * nskip determines whether all elements are written to the output file
- * (written when i % nskip == 0)
- * If fit != NULL the fit is also written.
- */
-
-int get_acfnout(void);
-/* Return the output length for the correlation function
- * Works only AFTER do_auto_corr has been called!
- */
-
-int get_acffitfn(void);
-/* Return the fit function type.
- * Works only AFTER do_auto_corr has been called!
- */
-
 /* Routines from pp2shift (anadih.c etc.) */
 
 void do_pp2shifts(FILE *fp, int nframes,
diff --git a/src/gromacs/gmxana/levenmar.c b/src/gromacs/gmxana/levenmar.c
deleted file mode 100644 (file)
index c84f103..0000000
+++ /dev/null
@@ -1,768 +0,0 @@
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
- * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
- * and including many others, as listed in the AUTHORS file in the
- * top-level source directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-#include "gmxpre.h"
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "gromacs/utility/basedefinitions.h"
-#include "gromacs/utility/real.h"
-
-static void nrerror(const char error_text[], gmx_bool bExit)
-{
-    fprintf(stderr, "Numerical Recipes run-time error...\n");
-    fprintf(stderr, "%s\n", error_text);
-    if (bExit)
-    {
-        fprintf(stderr, "...now exiting to system...\n");
-        exit(1);
-    }
-}
-
-/* dont use the keyword vector - it will clash with the
- * altivec extensions used for powerpc processors.
- */
-
-static real *rvector(int nl, int nh)
-{
-    real *v;
-
-    v = (real *)malloc((unsigned) (nh-nl+1)*sizeof(real));
-    if (!v)
-    {
-        nrerror("allocation failure in rvector()", TRUE);
-    }
-    /* cppcheck-suppress memleak
-     * free_vector does the same vector arithmetic */
-    return v-nl;
-}
-
-static int *ivector(int nl, int nh)
-{
-    int *v;
-
-    v = (int *)malloc((unsigned) (nh-nl+1)*sizeof(int));
-    if (!v)
-    {
-        nrerror("allocation failure in ivector()", TRUE);
-    }
-    /* cppcheck-suppress memleak
-     * free_vector does the same vector arithmetic */
-    return v-nl;
-}
-
-
-static real **matrix1(int nrl, int nrh, int ncl, int nch)
-{
-    int    i;
-    real **m;
-
-    m = (real **) malloc((unsigned) (nrh-nrl+1)*sizeof(real*));
-    if (!m)
-    {
-        nrerror("allocation failure 1 in matrix1()", TRUE);
-    }
-    m -= nrl;
-
-    for (i = nrl; i <= nrh; i++)
-    {
-        m[i] = (real *) malloc((unsigned) (nch-ncl+1)*sizeof(real));
-        if (!m[i])
-        {
-            nrerror("allocation failure 2 in matrix1()", TRUE);
-        }
-        m[i] -= ncl;
-    }
-    return m;
-}
-
-static double **dmatrix(int nrl, int nrh, int ncl, int nch)
-{
-    int      i;
-    double **m;
-
-    m = (double **) malloc((unsigned) (nrh-nrl+1)*sizeof(double*));
-    if (!m)
-    {
-        nrerror("allocation failure 1 in dmatrix()", TRUE);
-    }
-    m -= nrl;
-
-    for (i = nrl; i <= nrh; i++)
-    {
-        m[i] = (double *) malloc((unsigned) (nch-ncl+1)*sizeof(double));
-        if (!m[i])
-        {
-            nrerror("allocation failure 2 in dmatrix()", TRUE);
-        }
-        m[i] -= ncl;
-    }
-    return m;
-}
-
-static int **imatrix1(int nrl, int nrh, int ncl, int nch)
-{
-    int i, **m;
-
-    m = (int **)malloc((unsigned) (nrh-nrl+1)*sizeof(int*));
-    if (!m)
-    {
-        nrerror("allocation failure 1 in imatrix1()", TRUE);
-    }
-    m -= nrl;
-
-    for (i = nrl; i <= nrh; i++)
-    {
-        m[i] = (int *)malloc((unsigned) (nch-ncl+1)*sizeof(int));
-        if (!m[i])
-        {
-            nrerror("allocation failure 2 in imatrix1()", TRUE);
-        }
-        m[i] -= ncl;
-    }
-    return m;
-}
-
-
-
-static real **submatrix(real **a, int oldrl, int oldrh, int oldcl,
-                        int newrl, int newcl)
-{
-    int    i, j;
-    real **m;
-
-    m = (real **) malloc((unsigned) (oldrh-oldrl+1)*sizeof(real*));
-    if (!m)
-    {
-        nrerror("allocation failure in submatrix()", TRUE);
-    }
-    m -= newrl;
-
-    for (i = oldrl, j = newrl; i <= oldrh; i++, j++)
-    {
-        m[j] = a[i]+oldcl-newcl;
-    }
-
-    return m;
-}
-
-
-
-static void free_vector(real *v, int nl)
-{
-    free((char*) (v+nl));
-}
-
-static void free_ivector(int *v, int nl)
-{
-    free((char*) (v+nl));
-}
-
-static void free_dvector(int *v, int nl)
-{
-    free((char*) (v+nl));
-}
-
-
-
-static void free_matrix(real **m, int nrl, int nrh, int ncl)
-{
-    int i;
-
-    for (i = nrh; i >= nrl; i--)
-    {
-        free((char*) (m[i]+ncl));
-    }
-    free((char*) (m+nrl));
-}
-
-static real **convert_matrix(real *a, int nrl, int nrh, int ncl, int nch)
-{
-    int    i, j, nrow, ncol;
-    real **m;
-
-    nrow = nrh-nrl+1;
-    ncol = nch-ncl+1;
-    m    = (real **) malloc((unsigned) (nrow)*sizeof(real*));
-    if (!m)
-    {
-        nrerror("allocation failure in convert_matrix()", TRUE);
-    }
-    m -= nrl;
-    for (i = 0, j = nrl; i <= nrow-1; i++, j++)
-    {
-        m[j] = a+ncol*i-ncl;
-    }
-    return m;
-}
-
-
-
-static void free_convert_matrix(real **b, int nrl)
-{
-    free((char*) (b+nrl));
-}
-
-#define SWAP(a, b) {real temp = (a); (a) = (b); (b) = temp; }
-
-static void dump_mat(int n, real **a)
-{
-    int i, j;
-
-    for (i = 1; (i <= n); i++)
-    {
-        for (j = 1; (j <= n); j++)
-        {
-            fprintf(stderr, "  %10.3f", a[i][j]);
-        }
-        fprintf(stderr, "\n");
-    }
-}
-
-gmx_bool gaussj(real **a, int n, real **b, int m)
-{
-    int *indxc, *indxr, *ipiv;
-    int  i, icol = 0, irow = 0, j, k, l, ll;
-    real big, dum, pivinv;
-
-    indxc = ivector(1, n);
-    indxr = ivector(1, n);
-    ipiv  = ivector(1, n);
-    for (j = 1; j <= n; j++)
-    {
-        ipiv[j] = 0;
-    }
-    for (i = 1; i <= n; i++)
-    {
-        big = 0.0;
-        for (j = 1; j <= n; j++)
-        {
-            if (ipiv[j] != 1)
-            {
-                for (k = 1; k <= n; k++)
-                {
-                    if (ipiv[k] == 0)
-                    {
-                        if (fabs(a[j][k]) >= big)
-                        {
-                            big  = fabs(a[j][k]);
-                            irow = j;
-                            icol = k;
-                        }
-                    }
-                    else if (ipiv[k] > 1)
-                    {
-                        nrerror("GAUSSJ: Singular Matrix-1", FALSE);
-                        return FALSE;
-                    }
-                }
-            }
-        }
-        ++(ipiv[icol]);
-        if (irow != icol)
-        {
-            for (l = 1; l <= n; l++)
-            {
-                SWAP(a[irow][l], a[icol][l]);
-            }
-            for (l = 1; l <= m; l++)
-            {
-                SWAP(b[irow][l], b[icol][l]);
-            }
-        }
-        indxr[i] = irow;
-        indxc[i] = icol;
-        if (a[icol][icol] == 0.0)
-        {
-            fprintf(stderr, "irow = %d, icol = %d\n", irow, icol);
-            dump_mat(n, a);
-            nrerror("GAUSSJ: Singular Matrix-2", FALSE);
-            return FALSE;
-        }
-        pivinv        = 1.0/a[icol][icol];
-        a[icol][icol] = 1.0;
-        for (l = 1; l <= n; l++)
-        {
-            a[icol][l] *= pivinv;
-        }
-        for (l = 1; l <= m; l++)
-        {
-            b[icol][l] *= pivinv;
-        }
-        for (ll = 1; ll <= n; ll++)
-        {
-            if (ll != icol)
-            {
-                dum         = a[ll][icol];
-                a[ll][icol] = 0.0;
-                for (l = 1; l <= n; l++)
-                {
-                    a[ll][l] -= a[icol][l]*dum;
-                }
-                for (l = 1; l <= m; l++)
-                {
-                    b[ll][l] -= b[icol][l]*dum;
-                }
-            }
-        }
-    }
-    for (l = n; l >= 1; l--)
-    {
-        if (indxr[l] != indxc[l])
-        {
-            for (k = 1; k <= n; k++)
-            {
-                SWAP(a[k][indxr[l]], a[k][indxc[l]]);
-            }
-        }
-    }
-    free_ivector(ipiv, 1);
-    free_ivector(indxr, 1);
-    free_ivector(indxc, 1);
-
-    return TRUE;
-}
-
-#undef SWAP
-
-
-static void covsrt(real **covar, int ma, int lista[], int mfit)
-{
-    int  i, j;
-    real swap;
-
-    for (j = 1; j < ma; j++)
-    {
-        for (i = j+1; i <= ma; i++)
-        {
-            covar[i][j] = 0.0;
-        }
-    }
-    for (i = 1; i < mfit; i++)
-    {
-        for (j = i+1; j <= mfit; j++)
-        {
-            if (lista[j] > lista[i])
-            {
-                covar[lista[j]][lista[i]] = covar[i][j];
-            }
-            else
-            {
-                covar[lista[i]][lista[j]] = covar[i][j];
-            }
-        }
-    }
-    swap = covar[1][1];
-    for (j = 1; j <= ma; j++)
-    {
-        covar[1][j] = covar[j][j];
-        covar[j][j] = 0.0;
-    }
-    covar[lista[1]][lista[1]] = swap;
-    for (j = 2; j <= mfit; j++)
-    {
-        covar[lista[j]][lista[j]] = covar[1][j];
-    }
-    for (j = 2; j <= ma; j++)
-    {
-        for (i = 1; i <= j-1; i++)
-        {
-            covar[i][j] = covar[j][i];
-        }
-    }
-}
-
-#define SWAP(a, b) {swap = (a); (a) = (b); (b) = swap; }
-
-static void covsrt_new(real **covar, int ma, int ia[], int mfit)
-/* Expand in storage the covariance matrix covar, so as to take
- * into account parameters that are being held fixed. (For the
- * latter, return zero covariances.)
- */
-{
-    int  i, j, k;
-    real swap;
-    for (i = mfit+1; i <= ma; i++)
-    {
-        for (j = 1; j <= i; j++)
-        {
-            covar[i][j] = covar[j][i] = 0.0;
-        }
-    }
-    k = mfit;
-    for (j = ma; j >= 1; j--)
-    {
-        if (ia[j])
-        {
-            for (i = 1; i <= ma; i++)
-            {
-                SWAP(covar[i][k], covar[i][j]);
-            }
-            for (i = 1; i <= ma; i++)
-            {
-                SWAP(covar[k][i], covar[j][i]);
-            }
-            k--;
-        }
-    }
-}
-#undef SWAP
-
-static void mrqcof(real x[], real y[], real sig[], int ndata, real a[],
-                   int ma, int lista[], int mfit,
-                   real **alpha, real beta[], real *chisq,
-                   void (*funcs)(real, real *, real *, real *))
-{
-    int  k, j, i;
-    real ymod, wt, sig2i, dy, *dyda;
-
-    dyda = rvector(1, ma);
-    for (j = 1; j <= mfit; j++)
-    {
-        for (k = 1; k <= j; k++)
-        {
-            alpha[j][k] = 0.0;
-        }
-        beta[j] = 0.0;
-    }
-    *chisq = 0.0;
-    for (i = 1; i <= ndata; i++)
-    {
-        (*funcs)(x[i], a, &ymod, dyda);
-        sig2i = 1.0/(sig[i]*sig[i]);
-        dy    = y[i]-ymod;
-        for (j = 1; j <= mfit; j++)
-        {
-            wt = dyda[lista[j]]*sig2i;
-            for (k = 1; k <= j; k++)
-            {
-                alpha[j][k] += wt*dyda[lista[k]];
-            }
-            beta[j] += dy*wt;
-        }
-        (*chisq) += dy*dy*sig2i;
-    }
-    for (j = 2; j <= mfit; j++)
-    {
-        for (k = 1; k <= j-1; k++)
-        {
-            alpha[k][j] = alpha[j][k];
-        }
-    }
-    free_vector(dyda, 1);
-}
-
-
-gmx_bool mrqmin(real x[], real y[], real sig[], int ndata, real a[],
-                int ma, int lista[], int mfit,
-                real **covar, real **alpha, real *chisq,
-                void (*funcs)(real, real *, real *, real *),
-                real *alamda)
-{
-    int          k, kk, j, ihit;
-    static real *da, *atry, **oneda, *beta, ochisq;
-
-    if (*alamda < 0.0)
-    {
-        oneda = matrix1(1, mfit, 1, 1);
-        atry  = rvector(1, ma);
-        da    = rvector(1, ma);
-        beta  = rvector(1, ma);
-        kk    = mfit+1;
-        for (j = 1; j <= ma; j++)
-        {
-            ihit = 0;
-            for (k = 1; k <= mfit; k++)
-            {
-                if (lista[k] == j)
-                {
-                    ihit++;
-                }
-            }
-            if (ihit == 0)
-            {
-                lista[kk++] = j;
-            }
-            else if (ihit > 1)
-            {
-                nrerror("Bad LISTA permutation in MRQMIN-1", FALSE);
-                return FALSE;
-            }
-        }
-        if (kk != ma+1)
-        {
-            nrerror("Bad LISTA permutation in MRQMIN-2", FALSE);
-            return FALSE;
-        }
-        *alamda = 0.001;
-        mrqcof(x, y, sig, ndata, a, ma, lista, mfit, alpha, beta, chisq, funcs);
-        ochisq = (*chisq);
-    }
-    for (j = 1; j <= mfit; j++)
-    {
-        for (k = 1; k <= mfit; k++)
-        {
-            covar[j][k] = alpha[j][k];
-        }
-        covar[j][j] = alpha[j][j]*(1.0+(*alamda));
-        oneda[j][1] = beta[j];
-    }
-    if (!gaussj(covar, mfit, oneda, 1))
-    {
-        return FALSE;
-    }
-    for (j = 1; j <= mfit; j++)
-    {
-        da[j] = oneda[j][1];
-    }
-    if (*alamda == 0.0)
-    {
-        covsrt(covar, ma, lista, mfit);
-        free_vector(beta, 1);
-        free_vector(da, 1);
-        free_vector(atry, 1);
-        free_matrix(oneda, 1, mfit, 1);
-        return TRUE;
-    }
-    for (j = 1; j <= ma; j++)
-    {
-        atry[j] = a[j];
-    }
-    for (j = 1; j <= mfit; j++)
-    {
-        atry[lista[j]] = a[lista[j]]+da[j];
-    }
-    mrqcof(x, y, sig, ndata, atry, ma, lista, mfit, covar, da, chisq, funcs);
-    if (*chisq < ochisq)
-    {
-        *alamda *= 0.1;
-        ochisq   = (*chisq);
-        for (j = 1; j <= mfit; j++)
-        {
-            for (k = 1; k <= mfit; k++)
-            {
-                alpha[j][k] = covar[j][k];
-            }
-            beta[j]     = da[j];
-            a[lista[j]] = atry[lista[j]];
-        }
-    }
-    else
-    {
-        *alamda *= 10.0;
-        *chisq   = ochisq;
-    }
-    return TRUE;
-}
-
-
-gmx_bool mrqmin_new(real x[], real y[], real sig[], int ndata, real a[],
-                    int ia[], int ma, real **covar, real **alpha, real *chisq,
-                    void (*funcs)(real, real [], real *, real []),
-                    real *alamda)
-/* Levenberg-Marquardt method, attempting to reduce the value Chi^2
- * of a fit between a set of data points x[1..ndata], y[1..ndata]
- * with individual standard deviations sig[1..ndata], and a nonlinear
- * function dependent on ma coefficients a[1..ma]. The input array
- * ia[1..ma] indicates by nonzero entries those components of a that
- * should be fitted for, and by zero entries those components that
- * should be held fixed at their input values. The program returns
- * current best-fit values for the parameters a[1..ma], and
- * Chi^2 = chisq. The arrays covar[1..ma][1..ma], alpha[1..ma][1..ma]
- * are used as working space during most iterations. Supply a routine
- * funcs(x,a,yfit,dyda,ma) that evaluates the fitting function yfit,
- * and its derivatives dyda[1..ma] with respect to the fitting
- * parameters a at x. On the first call provide an initial guess for
- * the parameters a, and set alamda < 0 for initialization (which then
- * sets alamda=.001). If a step succeeds chisq becomes smaller and
- * alamda de-creases by a factor of 10. If a step fails alamda grows by
- * a factor of 10. You must call this routine repeatedly until
- * convergence is achieved. Then, make one final call with alamda=0,
- * so that covar[1..ma][1..ma] returns the covariance matrix, and alpha
- * the curvature matrix.
- * (Parameters held fixed will return zero covariances.)
- */
-{
-    void covsrt(real **covar, int ma, int ia[], int mfit);
-    gmx_bool gaussj(real **a, int n, real **b, int m);
-    void mrqcof_new(real x[], real y[], real sig[], int ndata, real a[],
-                    int ia[], int ma, real **alpha, real beta[], real *chisq,
-                    void (*funcs)(real, real [], real *, real []));
-    int         j, k, l;
-    static int  mfit;
-    static real ochisq, *atry, *beta, *da, **oneda;
-
-    if (*alamda < 0.0)                    /* Initialization. */
-    {
-        atry = rvector(1, ma);
-        beta = rvector(1, ma);
-        da   = rvector(1, ma);
-        for (mfit = 0, j = 1; j <= ma; j++)
-        {
-            if (ia[j])
-            {
-                mfit++;
-            }
-        }
-        oneda   = matrix1(1, mfit, 1, 1);
-        *alamda = 0.001;
-        mrqcof_new(x, y, sig, ndata, a, ia, ma, alpha, beta, chisq, funcs);
-        ochisq = (*chisq);
-        for (j = 1; j <= ma; j++)
-        {
-            atry[j] = a[j];
-        }
-    }
-    for (j = 1; j <= mfit; j++) /* Alter linearized fitting matrix, by augmenting. */
-    {
-        for (k = 1; k <= mfit; k++)
-        {
-            covar[j][k] = alpha[j][k]; /* diagonal elements. */
-        }
-        covar[j][j] = alpha[j][j]*(1.0+(*alamda));
-        oneda[j][1] = beta[j];
-    }
-    if (!gaussj(covar, mfit, oneda, 1)) /* Matrix solution. */
-    {
-        return FALSE;
-    }
-    for (j = 1; j <= mfit; j++)
-    {
-        da[j] = oneda[j][1];
-    }
-    if (*alamda == 0.0) /* Once converged, evaluate covariance matrix. */
-    {
-        covsrt_new(covar, ma, ia, mfit);
-        free_matrix(oneda, 1, mfit, 1);
-        free_vector(da, 1);
-        free_vector(beta, 1);
-        free_vector(atry, 1);
-        return TRUE;
-    }
-    for (j = 0, l = 1; l <= ma; l++) /* Did the trial succeed? */
-    {
-        if (ia[l])
-        {
-            atry[l] = a[l]+da[++j];
-        }
-    }
-    mrqcof_new(x, y, sig, ndata, atry, ia, ma, covar, da, chisq, funcs);
-    if (*chisq < ochisq)
-    {
-        /* Success, accept the new solution. */
-        *alamda *= 0.1;
-        ochisq   = (*chisq);
-        for (j = 1; j <= mfit; j++)
-        {
-            for (k = 1; k <= mfit; k++)
-            {
-                alpha[j][k] = covar[j][k];
-            }
-            beta[j] = da[j];
-        }
-        for (l = 1; l <= ma; l++)
-        {
-            a[l] = atry[l];
-        }
-    }
-    else                 /* Failure, increase alamda and return. */
-    {
-        *alamda *= 10.0;
-        *chisq   = ochisq;
-    }
-    return TRUE;
-}
-
-void mrqcof_new(real x[], real y[], real sig[], int ndata, real a[],
-                int ia[], int ma, real **alpha, real beta[], real *chisq,
-                void (*funcs)(real, real [], real *, real[]))
-/* Used by mrqmin to evaluate the linearized fitting matrix alpha, and
- * vector beta as in (15.5.8), and calculate Chi^2.
- */
-{
-    int  i, j, k, l, m, mfit = 0;
-    real ymod, wt, sig2i, dy, *dyda;
-
-    dyda = rvector(1, ma);
-    for (j = 1; j <= ma; j++)
-    {
-        if (ia[j])
-        {
-            mfit++;
-        }
-    }
-    for (j = 1; j <= mfit; j++) /* Initialize (symmetric) alpha), beta. */
-    {
-        for (k = 1; k <= j; k++)
-        {
-            alpha[j][k] = 0.0;
-        }
-        beta[j] = 0.0;
-    }
-    *chisq = 0.0;
-    for (i = 1; i <= ndata; i++) /* Summation loop over all data. */
-    {
-        (*funcs)(x[i], a, &ymod, dyda);
-        sig2i = 1.0/(sig[i]*sig[i]);
-        dy    = y[i]-ymod;
-        for (j = 0, l = 1; l <= ma; l++)
-        {
-            if (ia[l])
-            {
-                wt = dyda[l]*sig2i;
-                for (j++, k = 0, m = 1; m <= l; m++)
-                {
-                    if (ia[m])
-                    {
-                        alpha[j][++k] += wt*dyda[m];
-                    }
-                }
-                beta[j] += dy*wt;
-            }
-        }
-        *chisq += dy*dy*sig2i;  /* And find Chi^2. */
-    }
-    for (j = 2; j <= mfit; j++) /* Fill in the symmetric side. */
-    {
-        for (k = 1; k < j; k++)
-        {
-            alpha[k][j] = alpha[j][k];
-        }
-    }
-    free_vector(dyda, 1);
-}