diff --git a/src/tests/dynGaussKT_LF/dynGaussKT_LF.cpp b/src/tests/dynGaussKT_LF/dynGaussKT_LF.cpp new file mode 100644 index 00000000..ec4c3e32 --- /dev/null +++ b/src/tests/dynGaussKT_LF/dynGaussKT_LF.cpp @@ -0,0 +1,191 @@ +#include +#include + +#include +#include +#include +#include +using namespace std; + +typedef vector PDoubleVector; + +#define PI 3.14159265359 + +// NR p.797 +void voltra(const double h, PDoubleVector &t, PDoubleVector ¶m, PDoubleVector &f, + double g(const int, const PDoubleVector &, const PDoubleVector &, const PDoubleVector &), PDoubleVector &gi) +{ + int i,j; + double sum; + + int n = f.size(); + double a; + t[0] = 0.0; + f[0]=g(0,t,param,gi); + + for (i=1; i calc N internally"; + cout << endl << " if N is not given, N=1000"; + cout << endl << endl; + return 0; + } + + PDoubleVector param(4); + const double Tmax = 15.0; + + // feed parameter vector + param[0] = atof(argv[1]); // w0 + param[1] = atof(argv[2]); // Delta + param[2] = atof(argv[3]); // nu + if (argc == 5) { + param[3] = atof(argv[4]); // N + if (param[3] == -1.0) { // estimate N by itself + // w0 criteria, i.e. w0 T = 2 pi, ts = T/16, N = Tmax/ts, if N < 300, N == 300 + double val = 8.0/PI*Tmax*param[0]; + if (val < 250) + param[3] = 250; + else + param[3] = val; + + // nu/Delta criteria + if (param[1] != 0.0) { // Delta != 0 + val = param[2]/param[1]; // nu/Delta + if (val > 5.0) { + useKeren = true; + param[3] = 1000; + } + } + } + } else { + param[3] = 1000; + } + + const unsigned int N=static_cast(param[3]); + const double H = Tmax/N; + + PDoubleVector t(N); + PDoubleVector f(N); + PDoubleVector gi(N); + PDoubleVector abragam(N); + PDoubleVector keren(N); + + // get start time + struct timeval tv_start, tv_stop; + double t1, t2; + gettimeofday(&tv_start, 0); + + // feed time vector + for (unsigned int i=0; i= 1.0) { + for (unsigned int i=0; i=0;i--) { + sum=b[i]; + for (j=i+1;j +#include "nr.h" +using namespace std; + +void NR::ludcmp(Mat_IO_DP &a, Vec_O_INT &indx, DP &d) +{ + const DP TINY=1.0e-20; + int i,imax,j,k; + DP big,dum,sum,temp; + + int n=a.nrows(); + Vec_DP vv(n); + d=1.0; + for (i=0;i big) big=temp; + if (big == 0.0) nrerror("Singular matrix in routine ludcmp"); + vv[i]=1.0/big; + } + for (j=0;j= big) { + big=dum; + imax=i; + } + } + if (j != imax) { + for (k=0;k +#include +#include +#include "nr.h" +using namespace std; + +// Driver for routine voltra + +DP g(const int k, const DP t) +{ + return (k == 0 ? cosh(t)+t*sin(t) : + 2.0*sin(t)+t*(SQR(sin(t))+exp(t))); +} + +DP ak(const int k, const int l, const DP t, const DP s) +{ + return ((k == 0) ? + (l == 0 ? -exp(t-s) : -cos(t-s)) : + (l == 0 ? -exp(t+s) : -t*cos(s))); +} + +int main(void) +{ + const int N=10,M=2; + const DP H=0.05; + int nn; + DP t0=0.0; + Vec_DP t(N); + Mat_DP f(M,N); + + NR::voltra(t0,H,t,f,g,ak); + // exact soln is f[1]=exp(-t), f[2]=2sin(t) + cout << " abscissa voltra real"; + cout << " voltra real" << endl; + cout << " answer1 answer1"; + cout << " answer2 answer2" << endl << endl; + cout << fixed << setprecision(6); + for (nn=0;nn