// On The Frequency of Chaotic Dynamics on Large Economies // Author: Dave Albers // e-mail: djalbers@students.wisc.edu // note to users: this code must be recompiled for each combination of n, d, // and s. it was created this way in order to be able to look at any c // combination of n, d, and s. this code was written on the borland 4.0 c+++ // compiler. to achieve the data format for dr. sprott's display program the // data can be run through the convert program written for the power basic c // compiler. #include #include #include #include #include #include // declarations for the random number generator const long IM1 = 2147483563; const double IM2 = 2147483399; const double AM = (1.0/IM1); const double IMM1 = (IM1-1); const long IA1 = 40014; const long IA2 = 40692; const long IQ1 = 53668; const long IQ2 = 52774; const long IR1 = 12211; const long IR2 = 3791; const long NTAB = 32; const double NDIV = (1+IMM1/NTAB); const double EPS = 1.2e-7; const double RNMX = (1.0-EPS); // delcarations for # of neurons and the dimention of the system const int n=64, d=64; // number of iterations, number disregarded, and number of cases const int thrown = 400; const int iter = 2400; const int cases = 1; // array and variable declarations long double B[n]; long double w[n][d+1]; long double y[d], dy[d]; long double ljmax, ljmin; long double d0 = .00000001, ljsum=0.0, ljexp; long double lypsum=0.0; // function declarations long double return_value(int a); long double dreturn_value(int a); void ljy(int a, long double f, int v); float ran2 (long *idum); ofstream output("testdata.dat"); //ifstream input("benchmrk.dat"); int main () { int i, j, k, l, a, u, v, m, z, x, ii, jj; long double f=0.0, b=0.0, ljexp, lexp; long double g=0.0, t=0.0, mm=0.0, qq=0.0; long double p; int s=8; long *idum; long kj; cout = output; //cin = input; srand(time(0)); kj = rand(); kj = -kj; idum = &kj; for (v=1; v<=cases; v++) { b=0; // assign arrays for (i=0; i= 0) { B[i] = B[i]; } else if (B[i]<0) { B[i] = -B[i]; } b = b + B[i]; for (j=0; j<=d; j++) { // initialize wij to have a normal distribution for (l=1; l<=12; l++) { t = ran2(idum); g = g + t; } g = g - 6; w[i][j] = s*g; g=0.0; } } // assign arrays for test //ii = 0; //for (i=0; i<128; i++) //{ // if (i<64) // { // input >> mm; // B[i] = mm; // //output << i << " " << "next b = " << B[i] << endl; // if (B[i] >= 0) // { // B[i] = B[i]; // } // else if (B[i]<0) // { // B[i] = -B[i]; // } // // b = b + B[i]; // } // jj = 0; // if (i == 64) // { // ii = 0; // } // if (i>=64) // { // for (jj=0; jj<=64; jj++) // { // input >> mm; // w[ii][jj] = s*mm; // //output << ii << " " << " " << jj << "next w = " << // // w[ii][jj] << endl; // } // ii= ii + 1; // } //} // end of test sequence // // to scale too n^2 instead of 1 //b = b/(n*n); for (i=0; i thrown ) { ljexp = ljsum/(a-thrown); if ( a == iter ) { output << ljexp << endl; lypsum = lypsum + ljexp; } } } float ran2 (long *idum) { int j; long k; static long idum2=123456789; static long iy=0; static long iv[NTAB]; float temp; if (*idum <= 0) { if (-(*idum) < 1) *idum=1; else *idum = -(*idum); idum2=(*idum); for (j=NTAB+7; j>=0; j--) { k=(*idum)/IQ1; *idum=IA1*(*idum-k*IQ1)-k*IR1; if (*idum < 0) *idum += IM1; if (j < NTAB) iv[j] = *idum; } iy=iv[0]; } k=(*idum)/IQ1; *idum=IA1*(*idum-k*IQ1)-k*IR1; if (*idum < 0) *idum += IM1; k=idum2/IQ2; idum2=IA2*(idum2-k*IQ2)-k*IR2; if (idum2 < 0) idum2 += IM2; j=iy/NDIV; iy=iv[j]-idum2; iv[j] = *idum; if (iy < 1) iy += IMM1; if ((temp=AM*iy) > RNMX) return RNMX; else return temp; }