KickJava   Java API By Example, From Geeks To Geeks.

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


1 package JSci.maths.chaos;
2
3 import JSci.maths.*;
4
5 /**
6 * The GingerbreadManMap class provides an object that encapsulates the gingerbread man map.
7 * x<sub>n+1</sub> = 1 - y<sub>n</sub> + |x<sub>n</sub>|
8 * y<sub>n+1</sub> = x<sub>n</sub>
9 * (Devaney).
10 * @version 1.0
11 * @author Mark Hale
12 */

13 public final class GingerbreadManMap extends Object JavaDoc implements MappingND {
14         /**
15         * Chaotic x value.
16         */

17         public final static double X_CHAOS[]={-0.1,0.0};
18         /**
19         * Constructs a gingerbread man map.
20         */

21         public GingerbreadManMap() {}
22         /**
23         * Performs the mapping.
24         * @param x a 2-D double array
25         * @return a 2-D double array
26         */

27         public double[] map(double x[]) {
28                 double ans[]=new double[2];
29                 ans[0]=1.0-x[1]+Math.abs(x[0]);
30                 ans[1]=x[0];
31                 return ans;
32         }
33         /**
34         * Iterates the map.
35         * @param n the number of iterations
36         * @param x the initial values (2-D)
37         * @return a 2-D double array
38         */

39         public double[] iterate(int n,double x[]) {
40                 double xn[]=map(x);
41                 for(int i=1;i<n;i++)
42                         xn=map(xn);
43                 return xn;
44         }
45 }
46
47
Popular Tags