From 3726cc68e806d93e39de680204e47303a56c5e38 Mon Sep 17 00:00:00 2001 From: nemu Date: Sat, 24 Jan 2009 11:12:37 +0000 Subject: [PATCH] renaming train --- src/tests/dynKT_LF/dynGaussKT_LF.cpp | 250 +++++++++++++++++++++++++++ src/tests/dynKT_LF/dynGaussKT_LF.pro | 20 +++ src/tests/dynKT_LF/nr/lubksb.cpp | 24 +++ src/tests/dynKT_LF/nr/ludcmp.cpp | 53 ++++++ src/tests/dynKT_LF/nr/voltra.cpp | 36 ++++ src/tests/dynKT_LF/nr/xvoltra.cpp | 44 +++++ 6 files changed, 427 insertions(+) create mode 100644 src/tests/dynKT_LF/dynGaussKT_LF.cpp create mode 100644 src/tests/dynKT_LF/dynGaussKT_LF.pro create mode 100644 src/tests/dynKT_LF/nr/lubksb.cpp create mode 100644 src/tests/dynKT_LF/nr/ludcmp.cpp create mode 100644 src/tests/dynKT_LF/nr/voltra.cpp create mode 100644 src/tests/dynKT_LF/nr/xvoltra.cpp diff --git a/src/tests/dynKT_LF/dynGaussKT_LF.cpp b/src/tests/dynKT_LF/dynGaussKT_LF.cpp new file mode 100644 index 00000000..91fb8075 --- /dev/null +++ b/src/tests/dynKT_LF/dynGaussKT_LF.cpp @@ -0,0 +1,250 @@ +#include +#include + +#include +#include +#include +#include +using namespace std; + +#include + +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(val); + + // nu/Delta criteria + if (param[1] != 0.0) { // Delta != 0 + val = param[2]/param[1]; // nu/Delta + if (val > 5.0) { + useKeren = true; + N = 3000; + } + } + } + + if (argc > 4) { + if (*argv[4] == 'L') { + gaussian = false; + } + } + + const double H = Tmax/N; + + PDoubleVector t(N); + PDoubleVector f(N); + PDoubleVector gi(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=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