KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > chaos > HenonMap


1 package JSci.maths.chaos;
2
3 import JSci.maths.*;
4
5 /**
6 * The HenonMap class provides an object that encapsulates the Henon map.
7 * x<sub>n+1</sub> = 1 - a x<sub>n</sub><sup>2</sup> + y<sub>n</sub>
8 * y<sub>n+1</sub> = b x<sub>n</sub>
9 * @version 1.0
10 * @author Mark Hale
11 */

12 public final class HenonMap extends Object JavaDoc implements MappingND {
13         private final double a;
14         private final double b;
15         /**
16         * Chaotic a parameter value.
17         */

18         public final static double A_CHAOS=1.4;
19         /**
20         * Chaotic b parameter value.
21         */

22         public final static double B_CHAOS=0.3;
23         /**
24         * Constructs a Henon map.
25         * @param aval the value of the a parameter
26         * @param bval the value of the b parameter
27         */

28         public HenonMap(double aval,double bval) {
29                 a=aval;
30                 b=bval;
31         }
32         /**
33         * Performs the mapping.
34         * @param x a 2-D double array
35         * @return a 2-D double array
36         */

37         public double[] map(double x[]) {
38                 double ans[]=new double[2];
39                 ans[0]=1.0-a*x[0]*x[0]+x[1];
40                 ans[1]=b*x[0];
41                 return ans;
42         }
43         public double hausdorffDimension() {
44                 return 1.26;
45         }
46         /**
47         * Iterates the map.
48         * @param n the number of iterations
49         * @param x the initial values (2-D)
50         * @return a 2-D double array
51         */

52         public double[] iterate(int n,double x[]) {
53                 double xn[]=map(x);
54                 for(int i=1;i<n;i++)
55                         xn=map(xn);
56                 return xn;
57         }
58 }
59
60
Popular Tags