Fixed issues with compilation.
authorlimw <limw>
Thu, 14 Jul 2011 21:28:30 +0000 (21:28 +0000)
committerlimw <limw>
Thu, 14 Jul 2011 21:28:30 +0000 (21:28 +0000)
43 files changed:
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/Fibheaps/FibHeap.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/Fibheaps/TestRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/Fibheaps/Tree.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/GCBench/Node.java [new file with mode: 0644]
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/GCBench/TestRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/AppDemo.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/AppDemoRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/MonteCarloPath.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/MyRandom.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/PathId.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/PriceStock.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/RatePath.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/ReturnPath.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/JGFMonteCarlo/ToResult.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Composer.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Interval.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Isect.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Light.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Primitive.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Ray.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/RayTracer.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Scene.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Sphere.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Surface.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/TestRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/Vec.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/RayTracer/View.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/Body.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/Cell.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/MathVector.class
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/MathVector.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/Node.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/TestRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/Tree.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/lcss/TestRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/tsp/TestRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/tsp/Tree_tsp.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/voronoi/Edge.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/voronoi/EdgePair.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/voronoi/MyDouble.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/voronoi/TestRunner.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/voronoi/Vec2.java
Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/voronoi/Vertex.java

index c96413afc35734497d81da7fceb71e60db06d42e..13bc00234e34b48f5ef58dc78ef57fc2b2e11fe3 100644 (file)
@@ -1,38 +1,40 @@
+package Fibheaps;
+
 public class FibHeap {
 
   public int degree;
   public TaggedTree ttree;
   public Vector forest;
-  
+
   public FibHeap() {
     this.degree = 0;
     this.ttree = null;
     this.forest = null;
   }
-  
+
   public FibHeap(int degree,
-                 TaggedTree ttree,
-                 Vector forest) {
+      TaggedTree ttree,
+      Vector forest) {
     this.degree = degree;
     this.ttree = ttree;
     this.forest = forest;
   }
-  
+
   public boolean isEmpty() {
     return this.degree == 0;
   }
-  
+
   public int minFH() {
     return this.ttree.tree.root;
   }
-  
+
   public FibHeap insertFH(int x) {
     TaggedTree tt = new TaggedTree(0, new Tree(x, null));
     FibHeap fh = new FibHeap(1, tt, null);
-    
+
     return this.meldFH(fh);
   }
-  
+
   public FibHeap meldFH(FibHeap fh) {
     if(this.isEmpty()) {
       return fh;
@@ -59,9 +61,9 @@ public class FibHeap {
       return new FibHeap(fh.degree+this.degree, root, forest);
     }
   }
-  
+
   private void insert(Vector a,
-                      TaggedTree tt) {
+      TaggedTree tt) {
     int index = tt.degree;
     if(a.elementAt(index) == null) {
       a.setElementAt(tt.tree, index);
@@ -74,13 +76,13 @@ public class FibHeap {
       insert(a, itt);
     }
   }
-  
+
   private FibHeap getMin_t(Vector a,
-                           int mini,
-                           Tree mint,
-                           Vector b,
-                           int i,
-                           int d) {
+      int mini,
+      Tree mint,
+      Vector b,
+      int i,
+      int d) {
     if(i >= d) {
       return new FibHeap(this.degree-1, new TaggedTree(mini, mint), b);
     } else {
@@ -98,7 +100,7 @@ public class FibHeap {
       }
     }
   }
-  
+
   private int locallog(int n) {
     if(n == 1) {
       return 0;
@@ -106,7 +108,7 @@ public class FibHeap {
       return 1 + locallog(n/2);  
     }
   }
-  
+
   public FibHeap deleteMinFH() {
     if(this.isEmpty()) {
       // error here
@@ -144,11 +146,11 @@ public class FibHeap {
       return getMin_t(a, d, test, new Vector(), 0, d);
     }
   }
-  
+
   private Vector combine(int index,
-                         Vector ts,
-                         Vector next,
-                         Vector rest) {
+      Vector ts,
+      Vector next,
+      Vector rest) {
     if(ts.size() == 0) {
       return startup(index+1, next, rest);
     } else if (ts.size() == 1) {
@@ -166,10 +168,10 @@ public class FibHeap {
       return combine(index, nts, next, rest);
     }
   }
-  
+
   private Vector startup(int index,
-                         Vector ts,
-                         Vector rest) {
+      Vector ts,
+      Vector rest) {
     if(ts.size() == 0) {
       if(rest.size() == 0) {
         return new Vector();
@@ -194,9 +196,9 @@ public class FibHeap {
       }
     }
   }
-  
+
   private FibHeap chooseMin(FibHeap fh,
-                            TaggedTree tt) {
+      TaggedTree tt) {
     FibHeap rfh = null;
     if(fh.ttree.tree.root <= tt.tree.root) {
       fh.forest.insertElementAt(tt, 0);
@@ -207,7 +209,7 @@ public class FibHeap {
     }
     return rfh;
   }
-  
+
   public FibHeap deleteMinFH_t() {
     if(this.isEmpty()) {
       // error here
@@ -243,7 +245,7 @@ public class FibHeap {
       na.addElement(a.elementAt(i));
     }
     Vector vvec = startup(0, ts, na);
-    
+
     // getMin()
     TaggedTree rtt = (TaggedTree)vvec.elementAt(0);
     FibHeap rfh = new FibHeap(this.degree-1, rtt, new Vector());
index 2b5d94a5562a72d15731b8ecb543c529115c27ab..c61f7b721eb0fac76657d221adc57fb7098d01ce 100644 (file)
@@ -1,5 +1,7 @@
+package Fibheaps;
+
 // the fibheap class
-public class TestRunner {
+public class TestRunner extends Thread {
 
   public TestRunner() {}
 
@@ -60,7 +62,7 @@ public class TestRunner {
     int threadnum = 62;
     for(int i = 0; i < threadnum; ++i) {
       TestRunner tr = new TestRunner();
-      tr.run();
+      tr.start();
     }
   }
 }
index a6e495e048a1595640413c0e8928d9b966368368..4df6d36ed130cedf6fb7025747aa45e15f518493 100644 (file)
@@ -1,15 +1,17 @@
+package Fibheaps;
+
 // the bionomial class
 public class Tree {
   public int root;
   public Vector v_trees;
-  
+
   public Tree() {
     this.root = 0;
     this.v_trees = null;
   }
-  
+
   public Tree(int root,
-              Vector trees) {
+      Vector trees) {
     this.root = root;
     this.v_trees = trees;
   }
@@ -39,18 +41,18 @@ public class Tree {
 public class TaggedTree {
   public int degree;
   public Tree tree;
-  
+
   public TaggedTree() {
     this.degree = 0;
     this.tree = null;
   }
-  
+
   public TaggedTree(int degree,
-                    Tree tree) {
+      Tree tree) {
     this.degree = degree;
     this.tree = tree;
   }
-  
+
   public Vector getChildren() {
     Vector rst = new Vector();
     Vector v = tree.v_trees;
diff --git a/Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/GCBench/Node.java b/Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/GCBench/Node.java
new file mode 100644 (file)
index 0000000..13a97fa
--- /dev/null
@@ -0,0 +1,8 @@
+package GCBench;
+
+public class Node {
+  Node left, right;
+  int i, j;
+  Node(Node l, Node r) { left = l; right = r; }
+  Node() { }
+}
index 2429753542921ab7c242070e1d18633031e15a60..0507ff1fb9949926be0915cb4d32f810593e539e 100644 (file)
@@ -1,3 +1,5 @@
+package GCBench;
+
 //This is adapted from a benchmark written by John Ellis and Pete Kovac
 //of Post Communications.
 //It was modified by Hans Boehm of Silicon Graphics.
@@ -43,7 +45,7 @@
 //- Results are sensitive to locking cost, but we dont
 //check for proper locking
 
-public class TestRunner  extends Thread {
+public class TestRunner extends Thread {
 
   public static final int kStretchTreeDepth = 16; // about 4Mb
   public static final int kLongLivedTreeDepth = 14;  // about 1Mb
@@ -144,19 +146,12 @@ public class TestRunner  extends Thread {
       System.out.println((int)(array[1000]*1000000));
     }
   }
-  
-  class Node {
-    Node left, right;
-    int i, j;
-    Node(Node l, Node r) { left = l; right = r; }
-    Node() { }
-  }
-  
+
   public static void main(String[] args) {
     int threadnum = 62;
     for(int i = 0; i < threadnum; ++i) {
       TestRunner tr = new TestRunner();
-      tr.run();
+      tr.start();
     }
   }
 } // class JavaGC
index 001923da00ee962bfa15f96a4c4c3fa4cd94d7ba..b7a99141739f558e3025f6e0fac10c63900edca2 100644 (file)
@@ -1,3 +1,4 @@
+package JGFMonteCarlo;
 
 /**************************************************************************
  *                                                                         *
@@ -33,7 +34,7 @@
  * </ol>
  *
  * @author H W Yau
- * @version $Revision: 1.1 $ $Date: 2011/07/13 23:49:52 $
+ * @version $Revision: 1.2 $ $Date: 2011/07/14 21:28:29 $
  */
 public class AppDemo {
 
index e03ec1d666c28cbba099269b15edccd603f4ac60..96a13210a44a8f810cae3235ec7556ef52cccadc 100644 (file)
@@ -1,4 +1,6 @@
-class AppDemoRunner {
+package JGFMonteCarlo;
+
+public class AppDemoRunner extends Thread {
 
   public String header;
   public String name;
@@ -61,6 +63,7 @@ class AppDemoRunner {
       results.addElement(ps.getResult());
     }
   }
+
   public static void main(String[] args) {
     int datasize = 10000;  //should be times of 2
     int nruns = 62 * 62;  //16 * 16;
@@ -71,7 +74,7 @@ class AppDemoRunner {
 
     for(int i = 0; i < group; i++) {
       AppDemoRunner adr = new AppDemoRunner(i, nruns, group, ad);
-      adr.run();
+      adr.start();
     }
   }
 }
\ No newline at end of file
index c3756b4bd16693cb0985f06392fb545884bc2cae..5a41432948efc5e2ad9fed0a17ff98ea7c10bdc5 100644 (file)
@@ -1,4 +1,4 @@
-/** Banboo Version  **/
+package JGFMonteCarlo;
 
 /**************************************************************************
  *                                                                         *
  * </ol>
  *
  * @author H W Yau
- * @version $Revision: 1.1 $ $Date: 2011/07/13 23:49:52 $
+ * @version $Revision: 1.2 $ $Date: 2011/07/14 21:28:29 $
  */
 public class MonteCarloPath extends PathId {
 
-    //------------------------------------------------------------------------
-    // Instance variables.
-    //------------------------------------------------------------------------
-    /**
-     * Random fluctuations generated as a series of random numbers with
-     * given distribution.
-     */
-    public float[] fluctuations;
-    /**
-     * The path values from which the random fluctuations are used to update.
-     */
-    public float[] pathValue;
-    /**
-     * Integer flag for determining how the return was calculated, when
-     * used to calculate the mean drift and volatility parameters.
-     */
-    public int returnDefinition;
-    /**
-     * Value for the mean drift, for use in the generation of the random path.
-     */
-    public float expectedReturnRate;
-    /**
-     * Value for the volatility, for use in the generation of the random path.
-     */
-    public float volatility;
-    /**
-     * Number of time steps for which the simulation should act over.
-     */
-    public int nTimeSteps;
-    /**
-     * The starting value for of the security.
-     */
-    public float pathStartValue;
-    //------------------------------------------------------------------------
-    // Constructors.
-    //------------------------------------------------------------------------
-    /**
-     * Default constructor.  Needed by the HPT library to start create
-     * new instances of this class.  The instance variables for this should
-     * then be initialised with the <code>setInitAllTasks()</code> method.
-     */
-    public MonteCarloPath() {
-       super();
-       this.expectedReturnRate = (float)0.0;
-       this.volatility = (float)0.0;
-       this.pathStartValue = (float)0.0;
-       this.returnDefinition=1;
-       this.nTimeSteps=0;
-    }
+  //------------------------------------------------------------------------
+  // Instance variables.
+  //------------------------------------------------------------------------
+  /**
+   * Random fluctuations generated as a series of random numbers with
+   * given distribution.
+   */
+  public float[] fluctuations;
+  /**
+   * The path values from which the random fluctuations are used to update.
+   */
+  public float[] pathValue;
+  /**
+   * Integer flag for determining how the return was calculated, when
+   * used to calculate the mean drift and volatility parameters.
+   */
+  public int returnDefinition;
+  /**
+   * Value for the mean drift, for use in the generation of the random path.
+   */
+  public float expectedReturnRate;
+  /**
+   * Value for the volatility, for use in the generation of the random path.
+   */
+  public float volatility;
+  /**
+   * Number of time steps for which the simulation should act over.
+   */
+  public int nTimeSteps;
+  /**
+   * The starting value for of the security.
+   */
+  public float pathStartValue;
+  //------------------------------------------------------------------------
+  // Constructors.
+  //------------------------------------------------------------------------
+  /**
+   * Default constructor.  Needed by the HPT library to start create
+   * new instances of this class.  The instance variables for this should
+   * then be initialised with the <code>setInitAllTasks()</code> method.
+   */
+  public MonteCarloPath() {
+    super();
+    this.expectedReturnRate = (float)0.0;
+    this.volatility = (float)0.0;
+    this.pathStartValue = (float)0.0;
+    this.returnDefinition=1;
+    this.nTimeSteps=0;
+  }
 
+  /**
+   * Constructor, using the <code>ReturnPath</code> object to initialise
+   * the necessary instance variables.
+   *
+   * @param returnPath Object used to define the instance variables in
+   *                   this object.
+   * @param nTimeSteps The number of time steps for which to generate the
+   *                   random path.
+   * @exception DemoException Thrown if there is a problem initialising the
+   *                          object's instance variables.
+   */
+  public MonteCarloPath(ReturnPath returnPath, 
+      int nTimeSteps) {
     /**
-     * Constructor, using the <code>ReturnPath</code> object to initialise
-     * the necessary instance variables.
-     *
-     * @param returnPath Object used to define the instance variables in
-     *                   this object.
-     * @param nTimeSteps The number of time steps for which to generate the
-     *                   random path.
-     * @exception DemoException Thrown if there is a problem initialising the
-     *                          object's instance variables.
-     */
-    public MonteCarloPath(ReturnPath returnPath, 
-                         int nTimeSteps) {
-       /**
-        * These instance variables are members of PathId class.
-        */
-       this.expectedReturnRate = (float)0.0;
-       this.volatility = (float)0.0;
-       this.pathStartValue = (float)0.0;
-       this.returnDefinition=1;
-       
-       copyInstanceVariables(returnPath);
-       this.nTimeSteps = nTimeSteps;
-       this.pathValue = new float[nTimeSteps];
-       this.fluctuations = new float[nTimeSteps];
-    }
-    /**
-     * Constructor, where the <code>PathId</code> objects is used to ease
-     * the number of instance variables to pass in.
-     *
-     * @param pathId Object used to define the identity of this Path.
-     * @param returnDefinition How the statistic variables were defined,
-     *                         according to the definitions in
-     *                         <code>ReturnPath</code>'s two class variables
-     *                         <code>COMPOUNDED</code> and
-     *                         <code>NONCOMPOUNDED</code>.
-     * @param expectedReturnRate The measured expected return rate for which to generate.
-     * @param volatility The measured volatility for which to generate.
-     * @param nTimeSteps The number of time steps for which to generate.
-     * @exception DemoException Thrown if there is a problem initialising the
-     *                          object's instance variables.
+     * These instance variables are members of PathId class.
      */
-    public MonteCarloPath(PathId pathId, 
-                         int returnDefinition, 
-                         float expectedReturnRate, 
-                         float volatility, 
-                         int nTimeSteps) {
-       /**
-        * These instance variables are members of PathId class.
-        * Invoking with this particular signature should point to the
-        * definition in the PathId class.
-        */
-       this.pathStartValue = (float)0.0;
-           
-       copyInstanceVariables(pathId);
-       this.returnDefinition   = returnDefinition;
-       this.expectedReturnRate = expectedReturnRate;
-       this.volatility         = volatility;
-       this.nTimeSteps         = nTimeSteps;
-       this.pathValue          = new float[nTimeSteps];
-       this.fluctuations       = new float[nTimeSteps];
-    }
+    this.expectedReturnRate = (float)0.0;
+    this.volatility = (float)0.0;
+    this.pathStartValue = (float)0.0;
+    this.returnDefinition=1;
+
+    copyInstanceVariables(returnPath);
+    this.nTimeSteps = nTimeSteps;
+    this.pathValue = new float[nTimeSteps];
+    this.fluctuations = new float[nTimeSteps];
+  }
+  /**
+   * Constructor, where the <code>PathId</code> objects is used to ease
+   * the number of instance variables to pass in.
+   *
+   * @param pathId Object used to define the identity of this Path.
+   * @param returnDefinition How the statistic variables were defined,
+   *                         according to the definitions in
+   *                         <code>ReturnPath</code>'s two class variables
+   *                         <code>COMPOUNDED</code> and
+   *                         <code>NONCOMPOUNDED</code>.
+   * @param expectedReturnRate The measured expected return rate for which to generate.
+   * @param volatility The measured volatility for which to generate.
+   * @param nTimeSteps The number of time steps for which to generate.
+   * @exception DemoException Thrown if there is a problem initialising the
+   *                          object's instance variables.
+   */
+  public MonteCarloPath(PathId pathId, 
+      int returnDefinition, 
+      float expectedReturnRate, 
+      float volatility, 
+      int nTimeSteps) {
     /**
-     * Constructor, for when the user wishes to define each of the instance
-     * variables individually.
-     *
-     * @param name The name of the security which this Monte Carlo path
-     *             should represent.
-     * @param startDate The date when the path starts, in 'YYYYMMDD' format.
-     * @param endDate The date when the path ends, in 'YYYYMMDD' format.
-     * @param dTime The interval in the data between successive data points
-     *              in the generated path.
-     * @param returnDefinition How the statistic variables were defined,
-     *                         according to the definitions in
-     *                         <code>ReturnPath</code>'s two class variables
-     *                         <code>COMPOUNDED</code> and
-     *                         <code>NONCOMPOUNDED</code>.
-     * @param expectedReturnRate The measured mean drift for which to generate.
-     * @param volatility The measured volatility for which to generate.
-     * @param nTimeSteps The number of time steps for which to generate.
+     * These instance variables are members of PathId class.
+     * Invoking with this particular signature should point to the
+     * definition in the PathId class.
      */
-    public MonteCarloPath(String name, 
-                         int startDate, 
-                         int endDate, 
-                         float dTime, 
-                         int returnDefinition, 
-                         float expectedReturnRate, 
-                         float volatility, 
-                         int nTimeSteps) {
-       /**
-        * These instance variables are members of PathId class.
-        */
-       this.name = name;
-       this.startDate = startDate;
-       this.endDate = endDate;
-       this.dTime = dTime;
-       this.returnDefinition   = returnDefinition;
-       this.expectedReturnRate = expectedReturnRate;
-       this.volatility         = volatility;
-       this.nTimeSteps         = nTimeSteps;
-       this.pathValue          = new float[nTimeSteps];
-       this.fluctuations       = new float[nTimeSteps];
-    }
+    this.pathStartValue = (float)0.0;
 
-    //------------------------------------------------------------------------
-    // Methods.
-    //------------------------------------------------------------------------
-    //------------------------------------------------------------------------
-    // Accessor methods for class MonteCarloPath.
-    // Generated by 'makeJavaAccessor.pl' script.  HWY.  20th January 1999.
-    //------------------------------------------------------------------------
+    copyInstanceVariables(pathId);
+    this.returnDefinition   = returnDefinition;
+    this.expectedReturnRate = expectedReturnRate;
+    this.volatility         = volatility;
+    this.nTimeSteps         = nTimeSteps;
+    this.pathValue          = new float[nTimeSteps];
+    this.fluctuations       = new float[nTimeSteps];
+  }
+  /**
+   * Constructor, for when the user wishes to define each of the instance
+   * variables individually.
+   *
+   * @param name The name of the security which this Monte Carlo path
+   *             should represent.
+   * @param startDate The date when the path starts, in 'YYYYMMDD' format.
+   * @param endDate The date when the path ends, in 'YYYYMMDD' format.
+   * @param dTime The interval in the data between successive data points
+   *              in the generated path.
+   * @param returnDefinition How the statistic variables were defined,
+   *                         according to the definitions in
+   *                         <code>ReturnPath</code>'s two class variables
+   *                         <code>COMPOUNDED</code> and
+   *                         <code>NONCOMPOUNDED</code>.
+   * @param expectedReturnRate The measured mean drift for which to generate.
+   * @param volatility The measured volatility for which to generate.
+   * @param nTimeSteps The number of time steps for which to generate.
+   */
+  public MonteCarloPath(String name, 
+      int startDate, 
+      int endDate, 
+      float dTime, 
+      int returnDefinition, 
+      float expectedReturnRate, 
+      float volatility, 
+      int nTimeSteps) {
     /**
-     * Accessor method for private instance variable <code>fluctuations</code>.
-     *
-     * @return Value of instance variable <code>fluctuations</code>.
-     * @exception DemoException thrown if instance variable <code>fluctuations</code> 
-     * is undefined.
+     * These instance variables are members of PathId class.
      */
-    /*public float[] get_fluctuations() {
+    this.name = name;
+    this.startDate = startDate;
+    this.endDate = endDate;
+    this.dTime = dTime;
+    this.returnDefinition   = returnDefinition;
+    this.expectedReturnRate = expectedReturnRate;
+    this.volatility         = volatility;
+    this.nTimeSteps         = nTimeSteps;
+    this.pathValue          = new float[nTimeSteps];
+    this.fluctuations       = new float[nTimeSteps];
+  }
+
+  //------------------------------------------------------------------------
+  // Methods.
+  //------------------------------------------------------------------------
+  //------------------------------------------------------------------------
+  // Accessor methods for class MonteCarloPath.
+  // Generated by 'makeJavaAccessor.pl' script.  HWY.  20th January 1999.
+  //------------------------------------------------------------------------
+  /**
+   * Accessor method for private instance variable <code>fluctuations</code>.
+   *
+   * @return Value of instance variable <code>fluctuations</code>.
+   * @exception DemoException thrown if instance variable <code>fluctuations</code> 
+   * is undefined.
+   */
+  /*public float[] get_fluctuations() {
        return(this.fluctuations);
     }*/
-    /**
-     * Set method for private instance variable <code>fluctuations</code>.
-     *
-     * @param fluctuations the value to set for the instance variable 
-     * <code>fluctuations</code>.
-     */
-    public void set_fluctuations(float[] fluctuations) {
-       this.fluctuations = fluctuations;
-    }
-    /**
-     * Accessor method for private instance variable <code>pathValue</code>.
-     *
-     * @return Value of instance variable <code>pathValue</code>.
-     * @exception DemoException thrown if instance variable <code>pathValue</code> 
-     * is undefined.
-     */
-    /*public float[] get_pathValue() {
+  /**
+   * Set method for private instance variable <code>fluctuations</code>.
+   *
+   * @param fluctuations the value to set for the instance variable 
+   * <code>fluctuations</code>.
+   */
+  public void set_fluctuations(float[] fluctuations) {
+    this.fluctuations = fluctuations;
+  }
+  /**
+   * Accessor method for private instance variable <code>pathValue</code>.
+   *
+   * @return Value of instance variable <code>pathValue</code>.
+   * @exception DemoException thrown if instance variable <code>pathValue</code> 
+   * is undefined.
+   */
+  /*public float[] get_pathValue() {
        return(this.pathValue);
     }*/
-    /**
-     * Set method for private instance variable <code>pathValue</code>.
-     *
-     * @param pathValue the value to set for the instance variable <code>pathValue</code>.
-     */
-    public void set_pathValue(float[] pathValue) {
-       this.pathValue = pathValue;
-    }
-    /**
-     * Accessor method for private instance variable <code>returnDefinition</code>.
-     *
-     * @return Value of instance variable <code>returnDefinition</code>.
-     * @exception DemoException thrown if instance variable <code>returnDefinition</code> 
-     * is undefined.
-     */
-    /*public int get_returnDefinition() {
+  /**
+   * Set method for private instance variable <code>pathValue</code>.
+   *
+   * @param pathValue the value to set for the instance variable <code>pathValue</code>.
+   */
+  public void set_pathValue(float[] pathValue) {
+    this.pathValue = pathValue;
+  }
+  /**
+   * Accessor method for private instance variable <code>returnDefinition</code>.
+   *
+   * @return Value of instance variable <code>returnDefinition</code>.
+   * @exception DemoException thrown if instance variable <code>returnDefinition</code> 
+   * is undefined.
+   */
+  /*public int get_returnDefinition() {
        return(this.returnDefinition);
     }*/
-    /**
-     * Set method for private instance variable <code>returnDefinition</code>.
-     *
-     * @param returnDefinition the value to set for the instance variable 
-     * <code>returnDefinition</code>.
-     */
-    public void set_returnDefinition(int returnDefinition) {
-       this.returnDefinition = returnDefinition;
-    }
-    /**
-     * Accessor method for private instance variable <code>expectedReturnRate</code>.
-     *
-     * @return Value of instance variable <code>expectedReturnRate</code>.
-     * @exception DemoException thrown if instance variable <code>expectedReturnRate</code> 
-     * is undefined.
-     */
-    /*public float get_expectedReturnRate() {
+  /**
+   * Set method for private instance variable <code>returnDefinition</code>.
+   *
+   * @param returnDefinition the value to set for the instance variable 
+   * <code>returnDefinition</code>.
+   */
+  public void set_returnDefinition(int returnDefinition) {
+    this.returnDefinition = returnDefinition;
+  }
+  /**
+   * Accessor method for private instance variable <code>expectedReturnRate</code>.
+   *
+   * @return Value of instance variable <code>expectedReturnRate</code>.
+   * @exception DemoException thrown if instance variable <code>expectedReturnRate</code> 
+   * is undefined.
+   */
+  /*public float get_expectedReturnRate() {
        return(this.expectedReturnRate);
     }*/
-    /**
-     * Set method for private instance variable <code>expectedReturnRate</code>.
-     *
-     * @param expectedReturnRate the value to set for the instance variable 
-     * <code>expectedReturnRate</code>.
-     */
-    public void set_expectedReturnRate(float expectedReturnRate) {
-       this.expectedReturnRate = expectedReturnRate;
-    }
-    /**
-     * Accessor method for private instance variable <code>volatility</code>.
-     *
-     * @return Value of instance variable <code>volatility</code>.
-     * @exception DemoException thrown if instance variable <code>volatility</code> 
-     * is undefined.
-     */
-    /*public float get_volatility() {
+  /**
+   * Set method for private instance variable <code>expectedReturnRate</code>.
+   *
+   * @param expectedReturnRate the value to set for the instance variable 
+   * <code>expectedReturnRate</code>.
+   */
+  public void set_expectedReturnRate(float expectedReturnRate) {
+    this.expectedReturnRate = expectedReturnRate;
+  }
+  /**
+   * Accessor method for private instance variable <code>volatility</code>.
+   *
+   * @return Value of instance variable <code>volatility</code>.
+   * @exception DemoException thrown if instance variable <code>volatility</code> 
+   * is undefined.
+   */
+  /*public float get_volatility() {
        return(this.volatility);
     }*/
-    /**
-     * Set method for private instance variable <code>volatility</code>.
-     *
-     * @param volatility the value to set for the instance variable 
-     * <code>volatility</code>.
-     */
-    public void set_volatility(float volatility) {
-       this.volatility = volatility;
-    }
-    /**
-     * Accessor method for private instance variable <code>nTimeSteps</code>.
-     *
-     * @return Value of instance variable <code>nTimeSteps</code>.
-     * @exception DemoException thrown if instance variable <code>nTimeSteps</code> 
-     * is undefined.
-     */
-    /*public int get_nTimeSteps() {
+  /**
+   * Set method for private instance variable <code>volatility</code>.
+   *
+   * @param volatility the value to set for the instance variable 
+   * <code>volatility</code>.
+   */
+  public void set_volatility(float volatility) {
+    this.volatility = volatility;
+  }
+  /**
+   * Accessor method for private instance variable <code>nTimeSteps</code>.
+   *
+   * @return Value of instance variable <code>nTimeSteps</code>.
+   * @exception DemoException thrown if instance variable <code>nTimeSteps</code> 
+   * is undefined.
+   */
+  /*public int get_nTimeSteps() {
        return(this.nTimeSteps);
     }*/
-    /**
-     * Set method for private instance variable <code>nTimeSteps</code>.
-     *
-     * @param nTimeSteps the value to set for the instance variable 
-     * <code>nTimeSteps</code>.
-     */
-    public void set_nTimeSteps(int nTimeSteps) {
-       this.nTimeSteps = nTimeSteps;
-    }
-    /**
-     * Accessor method for private instance variable <code>pathStartValue</code>.
-     *
-     * @return Value of instance variable <code>pathStartValue</code>.
-     * @exception DemoException thrown if instance variable <code>pathStartValue</code> 
-     * is undefined.
-     */
-    /*public float get_pathStartValue() {
+  /**
+   * Set method for private instance variable <code>nTimeSteps</code>.
+   *
+   * @param nTimeSteps the value to set for the instance variable 
+   * <code>nTimeSteps</code>.
+   */
+  public void set_nTimeSteps(int nTimeSteps) {
+    this.nTimeSteps = nTimeSteps;
+  }
+  /**
+   * Accessor method for private instance variable <code>pathStartValue</code>.
+   *
+   * @return Value of instance variable <code>pathStartValue</code>.
+   * @exception DemoException thrown if instance variable <code>pathStartValue</code> 
+   * is undefined.
+   */
+  /*public float get_pathStartValue() {
        return(this.pathStartValue);
     }*/
-    /**
-     * Set method for private instance variable <code>pathStartValue</code>.
-     *
-     * @param pathStartValue the value to set for the instance variable 
-     * <code>pathStartValue</code>.
-     */
-    public void set_pathStartValue(float pathStartValue) {
-       this.pathStartValue = pathStartValue;
-    }
-    //------------------------------------------------------------------------
-    /**
-     * Method for copying the suitable instance variable from a
-     * <code>ReturnPath</code> object.
-     *
-     * @param obj Object used to define the instance variables which
-     *            should be carried over to this object.
-     * @exception DemoException thrown if there is a problem accessing the
-     *                          instance variables from the target objetct.
-     */
-    private void copyInstanceVariables(ReturnPath obj) {
-       //
-       // Instance variables defined in the PathId object.
-       this.name = obj.name;
-       this.startDate = obj.startDate;
-       this.endDate = obj.endDate;
-       this.dTime = obj.dTime;
-       //
-       // Instance variables defined in this object.
-       this.returnDefinition   = obj.returnDefinition;
-       this.expectedReturnRate = obj.expectedReturnRate;
-       this.volatility         = obj.volatility;
-    }
+  /**
+   * Set method for private instance variable <code>pathStartValue</code>.
+   *
+   * @param pathStartValue the value to set for the instance variable 
+   * <code>pathStartValue</code>.
+   */
+  public void set_pathStartValue(float pathStartValue) {
+    this.pathStartValue = pathStartValue;
+  }
+  //------------------------------------------------------------------------
+  /**
+   * Method for copying the suitable instance variable from a
+   * <code>ReturnPath</code> object.
+   *
+   * @param obj Object used to define the instance variables which
+   *            should be carried over to this object.
+   * @exception DemoException thrown if there is a problem accessing the
+   *                          instance variables from the target objetct.
+   */
+  private void copyInstanceVariables(ReturnPath obj) {
+    //
+    // Instance variables defined in the PathId object.
+    this.name = obj.name;
+    this.startDate = obj.startDate;
+    this.endDate = obj.endDate;
+    this.dTime = obj.dTime;
+    //
+    // Instance variables defined in this object.
+    this.returnDefinition   = obj.returnDefinition;
+    this.expectedReturnRate = obj.expectedReturnRate;
+    this.volatility         = obj.volatility;
+  }
 
-    /**
-     * Method for returning a RatePath object from the Monte Carlo data
-     * generated.
-     *
-     * @return a <code>RatePath</code> object representing the generated
-     *         data.
-     * @exception DemoException thrown if there was a problem creating
-     *            the RatePath object.
-     */
-    public RatePath getRatePath() {
-       return(new RatePath(this));
+  /**
+   * Method for returning a RatePath object from the Monte Carlo data
+   * generated.
+   *
+   * @return a <code>RatePath</code> object representing the generated
+   *         data.
+   * @exception DemoException thrown if there was a problem creating
+   *            the RatePath object.
+   */
+  public RatePath getRatePath() {
+    return(new RatePath(this));
+  }
+  /**
+   * Method for calculating the sequence of fluctuations, based around
+   * a Gaussian distribution of given mean and variance, as defined
+   * in this class' instance variables.  Mapping from Gaussian
+   * distribution of (0,1) to (mean-drift,volatility) is done via
+   * Ito's lemma on the log of the stock price.
+   * 
+   * @param randomSeed The psuedo-random number seed value, to start off a
+   *                   given sequence of Gaussian fluctuations.
+   * @exception DemoException thrown if there are any problems with
+   *                          the computation.
+   */
+  public boolean computeFluctuationsGaussian(long randomSeed) {
+    int ntimesteps = this.nTimeSteps;
+    int length = this.fluctuations.length;
+    if( ntimesteps > length ) {
+      return false;
     }
-    /**
-     * Method for calculating the sequence of fluctuations, based around
-     * a Gaussian distribution of given mean and variance, as defined
-     * in this class' instance variables.  Mapping from Gaussian
-     * distribution of (0,1) to (mean-drift,volatility) is done via
-     * Ito's lemma on the log of the stock price.
-     * 
-     * @param randomSeed The psuedo-random number seed value, to start off a
-     *                   given sequence of Gaussian fluctuations.
-     * @exception DemoException thrown if there are any problems with
-     *                          the computation.
-     */
-    public boolean computeFluctuationsGaussian(long randomSeed) {
-       int ntimesteps = this.nTimeSteps;
-       int length = this.fluctuations.length;
-       if( ntimesteps > length ) {
-           return false;
-       }
-       float[] flucts = this.fluctuations;
-       float expectedreturnrate = this.expectedReturnRate;
-       float vol = this.volatility;
-       float dtime = this.dTime;
-       
-       //
-       // First, make use of the passed in seed value.
-       MyRandom rnd;
-       float v1,v2, r;
-       v1 = (float)0.0;
-       v2 = (float)0.0;
-       if( randomSeed == -1 ) {
-           rnd = new MyRandom(0, v1, v2);
-       } else {
-           rnd = new MyRandom((int)randomSeed, v1, v2);
-       }
-       
-       //
-       // Determine the mean and standard-deviation, from the mean-drift and volatility.
-       float mean = (expectedreturnrate-(float)0.5*vol*vol)*dtime;
-       float sd   = vol*Math.sqrtf(dtime);
-       float gauss, meanGauss=(float)0.0, variance=(float)0.0;
-       for( int i=0; i < ntimesteps; i += 2 ) {
-           r  = rnd.seed();
-           gauss = r*rnd.v1;
-           meanGauss+= gauss;
-           variance+= gauss*gauss;
-           //
-           // Now map this onto a general Gaussian of given mean and variance.
-           flucts[i] = mean + sd*gauss;
-           //      dbgPrintln("gauss="+gauss+" fluctuations="+fluctuations[i]);
-           
-           gauss  = r*rnd.v2;
-           meanGauss+= gauss;
-           variance+= gauss*gauss;
-           //
-           // Now map this onto a general Gaussian of given mean and variance.
-           flucts[i+1] = mean + sd*gauss;
-       }
-       meanGauss/=(float)ntimesteps;
-       variance /=(float)ntimesteps;
-       //    dbgPrintln("meanGauss="+meanGauss+" variance="+variance);
+    float[] flucts = this.fluctuations;
+    float expectedreturnrate = this.expectedReturnRate;
+    float vol = this.volatility;
+    float dtime = this.dTime;
+
+    //
+    // First, make use of the passed in seed value.
+    MyRandom rnd;
+    float v1,v2, r;
+    v1 = (float)0.0;
+    v2 = (float)0.0;
+    if( randomSeed == -1 ) {
+      rnd = new MyRandom(0, v1, v2);
+    } else {
+      rnd = new MyRandom((int)randomSeed, v1, v2);
     }
-    /**
-     * Method for calculating the sequence of fluctuations, based around
-     * a Gaussian distribution of given mean and variance, as defined
-     * in this class' instance variables.  Mapping from Gaussian
-     * distribution of (0,1) to (mean-drift,volatility) is done via
-     * Ito's lemma on the log of the stock price.  This overloaded method
-     * is for when the random seed should be decided by the system.
-     * 
-     * @exception DemoException thrown if there are any problems with
-     *                          the computation.
-     */
-    public void computeFluctuationsGaussian() {
-       computeFluctuationsGaussian((long)-1);
+
+    //
+    // Determine the mean and standard-deviation, from the mean-drift and volatility.
+    float mean = (expectedreturnrate-(float)0.5*vol*vol)*dtime;
+    float sd   = vol*Math.sqrtf(dtime);
+    float gauss, meanGauss=(float)0.0, variance=(float)0.0;
+    for( int i=0; i < ntimesteps; i += 2 ) {
+      r  = rnd.seed();
+      gauss = r*rnd.v1;
+      meanGauss+= gauss;
+      variance+= gauss*gauss;
+      //
+      // Now map this onto a general Gaussian of given mean and variance.
+      flucts[i] = mean + sd*gauss;
+      //      dbgPrintln("gauss="+gauss+" fluctuations="+fluctuations[i]);
+
+      gauss  = r*rnd.v2;
+      meanGauss+= gauss;
+      variance+= gauss*gauss;
+      //
+      // Now map this onto a general Gaussian of given mean and variance.
+      flucts[i+1] = mean + sd*gauss;
     }
-    /**
-     * Method for calculating the corresponding rate path, given the
-     * fluctuations and starting rate value.
-     * 
-     * @param startValue the starting value of the rate path, to be
-     *                   updated with the precomputed fluctuations.
-     * @exception DemoException thrown if there are any problems with
-     *                          the computation.
-     */
-    public void computePathValue(float startValue) {
-       float[] pathvalue = this.pathValue;
-       float[] flucts = this.fluctuations;
-       int length = this.nTimeSteps;
-       pathvalue[0] = startValue;
-       if( returnDefinition == 1 | 
-               returnDefinition == 2) {
-           for(int i=1; i < length; i++ ) {
-               //System.printI((int)(flucts[i] * 10000));
-               pathvalue[i] = pathvalue[i-1] * Math.expf(flucts[i]);
-           }
-       }
+    meanGauss/=(float)ntimesteps;
+    variance /=(float)ntimesteps;
+    //    dbgPrintln("meanGauss="+meanGauss+" variance="+variance);
+  }
+  /**
+   * Method for calculating the sequence of fluctuations, based around
+   * a Gaussian distribution of given mean and variance, as defined
+   * in this class' instance variables.  Mapping from Gaussian
+   * distribution of (0,1) to (mean-drift,volatility) is done via
+   * Ito's lemma on the log of the stock price.  This overloaded method
+   * is for when the random seed should be decided by the system.
+   * 
+   * @exception DemoException thrown if there are any problems with
+   *                          the computation.
+   */
+  public void computeFluctuationsGaussian() {
+    computeFluctuationsGaussian((long)-1);
+  }
+  /**
+   * Method for calculating the corresponding rate path, given the
+   * fluctuations and starting rate value.
+   * 
+   * @param startValue the starting value of the rate path, to be
+   *                   updated with the precomputed fluctuations.
+   * @exception DemoException thrown if there are any problems with
+   *                          the computation.
+   */
+  public void computePathValue(float startValue) {
+    float[] pathvalue = this.pathValue;
+    float[] flucts = this.fluctuations;
+    int length = this.nTimeSteps;
+    pathvalue[0] = startValue;
+    if( returnDefinition == 1 | 
+        returnDefinition == 2) {
+      for(int i=1; i < length; i++ ) {
+        //System.printI((int)(flucts[i] * 10000));
+        pathvalue[i] = pathvalue[i-1] * Math.expf(flucts[i]);
+      }
     }
+  }
 }
index 2a8f985d244b0549d5aa396620326c6b2c7cea94..ec6ef14cad525638cead349561716c59398896db 100644 (file)
@@ -1,58 +1,60 @@
+package JGFMonteCarlo;
+
 public class MyRandom {
 
-    public int iseed;
-    public float v1,v2;
+  public int iseed;
+  public float v1,v2;
 
-    public MyRandom(int iseed, float v1, float v2) {
-       this.iseed = iseed;
-       this.v1 = v1;
-       this.v2 = v2;
-    }
+  public MyRandom(int iseed, float v1, float v2) {
+    this.iseed = iseed;
+    this.v1 = v1;
+    this.v2 = v2;
+  }
 
-    public float update() {
-       float rand;
-       float scale= (float)4.656612875e-10;
+  public float update() {
+    float rand;
+    float scale= (float)4.656612875e-10;
 
-       int is1,is2,iss2;
-       int imult= 16807;
-       int imod = 2147483647;
-       int seed = this.iseed;
+    int is1,is2,iss2;
+    int imult= 16807;
+    int imod = 2147483647;
+    int seed = this.iseed;
 
-       if (seed<=0) { 
-           iseed = seed = 1; 
-       }
+    if (seed<=0) { 
+      iseed = seed = 1; 
+    }
 
-       is2 = seed % 32768;
-       is1 = seed / 32768;
-       iss2 = is2 * imult;
-       is2 = iss2 % 32768;
-       is1 = (is1 * imult + iss2 / 32768) % (65536);
+    is2 = seed % 32768;
+    is1 = seed / 32768;
+    iss2 = is2 * imult;
+    is2 = iss2 % 32768;
+    is1 = (is1 * imult + iss2 / 32768) % (65536);
 
-       iseed = seed = (is1 * 32768 + is2) % imod;
+    iseed = seed = (is1 * 32768 + is2) % imod;
 
-       rand = scale * seed;
+    rand = scale * seed;
 
-       return rand;
+    return rand;
 
-    }
+  }
 
-    public float seed() {
+  public float seed() {
 
-       float s,u1,u2,r;
-       s = (float)1.0;
-       //do {
-           u1 = update();
-           u2 = update();
+    float s,u1,u2,r;
+    s = (float)1.0;
+    //do {
+    u1 = update();
+    u2 = update();
 
-           v1 = (float)2.0 * u1 - (float)1.0;
-           v2 = (float)2.0 * u2 - (float)1.0;
-           s = v1*v1 + v2*v2;
-       //} while (s >= (float)1.0);
-        s = s - (int)s;
-       //System.printI(0xb4);
-       r = Math.sqrtf((float)(-2.0*Math.logf(s))/(float)s);
-       //System.printI(0xb5);
-       return r;
+    v1 = (float)2.0 * u1 - (float)1.0;
+    v2 = (float)2.0 * u2 - (float)1.0;
+    s = v1*v1 + v2*v2;
+    //} while (s >= (float)1.0);
+    s = s - (int)s;
+    //System.printI(0xb4);
+    r = Math.sqrtf((float)(-2.0*Math.logf(s))/(float)s);
+    //System.printI(0xb5);
+    return r;
 
-    }
+  }
 }
index 2320a693f15b8b91c0df15f7ffeaad53802cfdfb..fba9615a04674ba607db15bf233ad807dd9f95f9 100644 (file)
@@ -1,63 +1,63 @@
-/** Banboo Version  **/
+package JGFMonteCarlo;
 
 /**************************************************************************
-*                                                                         *
-*         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
-*                                                                         *
-*                            produced by                                  *
-*                                                                         *
-*                  Java Grande Benchmarking Project                       *
-*                                                                         *
-*                                at                                       *
-*                                                                         *
-*                Edinburgh Parallel Computing Centre                      *
-*                                                                         *
-*                email: epcc-javagrande@epcc.ed.ac.uk                     *
-*                                                                         *
-*      Original version of this code by Hon Yau (hwyau@epcc.ed.ac.uk)     *
-*                                                                         *
-*      This version copyright (c) The University of Edinburgh, 2001.      *
-*                         All rights reserved.                            *
-*                                                                         *
-**************************************************************************/
+ *                                                                         *
+ *         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
+ *                                                                         *
+ *                            produced by                                  *
+ *                                                                         *
+ *                  Java Grande Benchmarking Project                       *
+ *                                                                         *
+ *                                at                                       *
+ *                                                                         *
+ *                Edinburgh Parallel Computing Centre                      *
+ *                                                                         *
+ *                email: epcc-javagrande@epcc.ed.ac.uk                     *
+ *                                                                         *
+ *      Original version of this code by Hon Yau (hwyau@epcc.ed.ac.uk)     *
+ *                                                                         *
+ *      This version copyright (c) The University of Edinburgh, 2001.      *
+ *                         All rights reserved.                            *
+ *                                                                         *
+ **************************************************************************/
 
 /**
 * Base class for all the security objects, namely in terms of
 * providing a consistent means of identifying each such object.
 * Also provides some methods for writing out debug messages.
 *
 * @author H W Yau
 * @version $Revision: 1.1 $ $Date: 2011/07/13 23:49:52 $
 */
+ * Base class for all the security objects, namely in terms of
+ * providing a consistent means of identifying each such object.
+ * Also provides some methods for writing out debug messages.
+ *
+ * @author H W Yau
* @version $Revision: 1.2 $ $Date: 2011/07/14 21:28:29 $
+ */
 public class PathId {
 
   //------------------------------------------------------------------------
   // Instance variables.
   //------------------------------------------------------------------------
   /**
-    * Simple string name.
-    */
+   * Simple string name.
+   */
   public String name;
 
   /**
-    * The start date for the path, in YYYYMMDD format.
-    */
+   * The start date for the path, in YYYYMMDD format.
+   */
   public int startDate;
   /**
-    * The end date for the path, in YYYYMMDD format.
-    */
+   * The end date for the path, in YYYYMMDD format.
+   */
   public int endDate;
   /**
-    * The change in time between two successive data values.
-    */
+   * The change in time between two successive data values.
+   */
   public float dTime;
 
   //------------------------------------------------------------------------
   // Constructors.
   //------------------------------------------------------------------------
   /**
-    * Default constructor.
-    */
+   * Default constructor.
+   */
   public PathId() {
     this.startDate=0;
     this.endDate=0;
@@ -65,10 +65,10 @@ public class PathId {
   }
 
   /**
-    * Another constructor.
-    *
-    * @param name The name for the security to record.
-    */
+   * Another constructor.
+   *
+   * @param name The name for the security to record.
+   */
   public PathId(String name) {
     this.name = name;
     this.startDate=0;
@@ -84,82 +84,82 @@ public class PathId {
   // Generated by 'makeJavaAccessor.pl' script.  HWY.  20th January 1999.
   //------------------------------------------------------------------------
   /**
-    * Accessor method for private instance variable <code>name</code>.
-    *
-    * @return Value of instance variable <code>name</code>.
-    * @exception DemoException thrown if instance variable <code>name</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>name</code>.
+   *
+   * @return Value of instance variable <code>name</code>.
+   * @exception DemoException thrown if instance variable <code>name</code> is undefined.
+   */
   /*public String get_name() {
     return(this.name);
   }*/
   /**
-    * Set method for private instance variable <code>name</code>.
-    *
-    * @param name the value to set for the instance variable <code>name</code>.
-    */
+   * Set method for private instance variable <code>name</code>.
+   *
+   * @param name the value to set for the instance variable <code>name</code>.
+   */
   public void set_name(String name) {
     this.name = name;
   }
   /**
-    * Accessor method for private instance variable <code>startDate</code>.
-    *
-    * @return Value of instance variable <code>startDate</code>.
-    * @exception DemoException thrown if instance variable <code>startDate</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>startDate</code>.
+   *
+   * @return Value of instance variable <code>startDate</code>.
+   * @exception DemoException thrown if instance variable <code>startDate</code> is undefined.
+   */
   /*public int get_startDate() {
     return(this.startDate);
   }*/
   /**
-    * Set method for private instance variable <code>startDate</code>.
-    *
-    * @param startDate the value to set for the instance variable <code>startDate</code>.
-    */
+   * Set method for private instance variable <code>startDate</code>.
+   *
+   * @param startDate the value to set for the instance variable <code>startDate</code>.
+   */
   public void set_startDate(int startDate) {
     this.startDate = startDate;
   }
   /**
-    * Accessor method for private instance variable <code>endDate</code>.
-    *
-    * @return Value of instance variable <code>endDate</code>.
-    * @exception DemoException thrown if instance variable <code>endDate</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>endDate</code>.
+   *
+   * @return Value of instance variable <code>endDate</code>.
+   * @exception DemoException thrown if instance variable <code>endDate</code> is undefined.
+   */
   /*public int get_endDate() {
     return(this.endDate);
   }*/
   /**
-    * Set method for private instance variable <code>endDate</code>.
-    *
-    * @param endDate the value to set for the instance variable <code>endDate</code>.
-    */
+   * Set method for private instance variable <code>endDate</code>.
+   *
+   * @param endDate the value to set for the instance variable <code>endDate</code>.
+   */
   public void set_endDate(int endDate) {
     this.endDate = endDate;
   }
   /**
-    * Accessor method for private instance variable <code>dTime</code>.
-    *
-    * @return Value of instance variable <code>dTime</code>.
-    * @exception DemoException thrown if instance variable <code>dTime</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>dTime</code>.
+   *
+   * @return Value of instance variable <code>dTime</code>.
+   * @exception DemoException thrown if instance variable <code>dTime</code> is undefined.
+   */
   /*public float get_dTime() {
     return(this.dTime);
   }*/
   /**
-    * Set method for private instance variable <code>dTime</code>.
-    *
-    * @param dTime the value to set for the instance variable <code>dTime</code>.
-    */
+   * Set method for private instance variable <code>dTime</code>.
+   *
+   * @param dTime the value to set for the instance variable <code>dTime</code>.
+   */
   public void set_dTime(float dTime) {
     this.dTime = dTime;
   }
   //------------------------------------------------------------------------
   /**
-    * Clone the instance variables in this class, from another instance
-    * of this class.
-    *
-    * @param obj the PathId object from which to copy.
-    * @exception DemoException thrown if the values to be copied contain
-    *                          any undefined objects.
-    */
+   * Clone the instance variables in this class, from another instance
+   * of this class.
+   *
+   * @param obj the PathId object from which to copy.
+   * @exception DemoException thrown if the values to be copied contain
+   *                          any undefined objects.
+   */
   public void copyInstanceVariables(PathId obj) {
     this.name      = obj.name;
     this.startDate = obj.startDate;
@@ -167,13 +167,13 @@ public class PathId {
     this.dTime     = obj.dTime;
   }
   /**
-    * Dumps the contents of the fields, to standard-out, for debugging.
-    */
+   * Dumps the contents of the fields, to standard-out, for debugging.
+   */
   public void dbgDumpFields() {
-//    dbgPrintln("name="     +this.name);
-//    dbgPrintln("startDate="+this.startDate);
-//    dbgPrintln("endDate="  +this.endDate);
-//    dbgPrintln("dTime="    +this.dTime);
+    //    dbgPrintln("name="     +this.name);
+    //    dbgPrintln("startDate="+this.startDate);
+    //    dbgPrintln("endDate="  +this.endDate);
+    //    dbgPrintln("dTime="    +this.dTime);
   }
 }
 
index 7daed65ca7d5134a82f8dacab5b15c33ee3e33f2..78d76efba1523d571c2da430032cf56f8024753d 100644 (file)
@@ -1,4 +1,4 @@
-/** Banboo Version  **/
+package JGFMonteCarlo;
 
 /**************************************************************************
  *                                                                         *
  * value.
  *
  * @author H W Yau
- * @version $Revision: 1.1 $ $Date: 2011/07/13 23:49:52 $
+ * @version $Revision: 1.2 $ $Date: 2011/07/14 21:28:29 $
  */
 public class PriceStock{
 
-    //------------------------------------------------------------------------
-    // Instance variables.
-    //------------------------------------------------------------------------
-    /**
-     * The Monte Carlo path to be generated.
-     */
-    public MonteCarloPath mcPath;
-    /**
-     * String identifier for a given task.
-     */
-    //private String taskHeader;
-    /**
-     * Random seed from which the Monte Carlo sequence is started.
-     */
-    public long randomSeed;
-    /**
-     * Initial stock price value.
-     */
-    public float pathStartValue;
-    /**
-     * Object which represents the results from a given computation task.
-     */
-    public ToResult result;
-    public float expectedReturnRate;
-    public float volatility;
-    public float volatility2;
-    public float finalStockPrice;
-    public float[] pathValue;
+  //------------------------------------------------------------------------
+  // Instance variables.
+  //------------------------------------------------------------------------
+  /**
+   * The Monte Carlo path to be generated.
+   */
+  public MonteCarloPath mcPath;
+  /**
+   * String identifier for a given task.
+   */
+  //private String taskHeader;
+  /**
+   * Random seed from which the Monte Carlo sequence is started.
+   */
+  public long randomSeed;
+  /**
+   * Initial stock price value.
+   */
+  public float pathStartValue;
+  /**
+   * Object which represents the results from a given computation task.
+   */
+  public ToResult result;
+  public float expectedReturnRate;
+  public float volatility;
+  public float volatility2;
+  public float finalStockPrice;
+  public float[] pathValue;
 
-    //------------------------------------------------------------------------
-    // Constructors.
-    //------------------------------------------------------------------------
-    /**
-     * Default constructor.
-     */
-    public PriceStock() {
-       //this.taskHeader = "";
-       this.randomSeed=-1;
-       this.pathStartValue=(float)0.0;
-       this.expectedReturnRate=(float)0.0;
-       this.volatility=(float)0.0;
-       this.volatility2=(float)0.0;
-       this.finalStockPrice=(float)0.0;
+  //------------------------------------------------------------------------
+  // Constructors.
+  //------------------------------------------------------------------------
+  /**
+   * Default constructor.
+   */
+  public PriceStock() {
+    //this.taskHeader = "";
+    this.randomSeed=-1;
+    this.pathStartValue=(float)0.0;
+    this.expectedReturnRate=(float)0.0;
+    this.volatility=(float)0.0;
+    this.volatility2=(float)0.0;
+    this.finalStockPrice=(float)0.0;
 
-       mcPath = new MonteCarloPath();
-    }
-    //------------------------------------------------------------------------
-    // Methods.
-    //------------------------------------------------------------------------
-    //------------------------------------------------------------------------
-    // Methods which implement the Slaveable interface.
-    //------------------------------------------------------------------------
-    /**
-     * Method which is passed in the initialisation data common to all tasks,
-     * and then unpacks them for use by this object.
-     *
-     * @param obj Object representing data which are common to all tasks.
-     */
-    public void setInitAllTasks(AppDemoRunner obj) {
-       mcPath.name = obj.name;
-       mcPath.startDate = obj.startDate;
-       mcPath.endDate = obj.endDate;
-       mcPath.dTime = obj.dTime;
-       mcPath.returnDefinition = obj.returnDefinition;
-       mcPath.expectedReturnRate = obj.expectedReturnRate;
-       mcPath.volatility = obj.volatility;
-       int nTimeSteps = obj.nTimeSteps;
-       mcPath.nTimeSteps = nTimeSteps;
-       this.pathStartValue = obj.pathStartValue;
-       mcPath.pathStartValue = pathStartValue;
-       mcPath.pathValue = new float[nTimeSteps];
-       mcPath.fluctuations = new float[nTimeSteps];
-    }
-    /**
-     * Method which is passed in the data representing each task, which then
-     * unpacks it for use by this object.
-     *
-     * @param obj Object representing the data which defines a given task.
-     */
-    public void setTask(/*String header, */long randomSeed) {
-       //this.taskHeader     = header;
-       this.randomSeed     = randomSeed;
-    }
-    /**
-     * The business end.  Invokes the necessary computation routine, for a
-     * a given task.
-     */
-    public void run() {
-       mcPath.computeFluctuationsGaussian(randomSeed);
-       mcPath.computePathValue(pathStartValue);
-       RatePath rateP = new RatePath(mcPath);
-       ReturnPath returnP = rateP.getReturnCompounded();
-       returnP.estimatePath();
-       expectedReturnRate = returnP.expectedReturnRate;
-       volatility = returnP.volatility;
-       volatility2 = returnP.volatility2;
-       finalStockPrice = rateP.getEndPathValue();//pathValue[rateP.pathValue.length-1];
-       pathValue = mcPath.pathValue;
-    }
-    /*
-     * Method which returns the results of a computation back to the caller.
-     *
-     * @return An object representing the computed results.
-     */
-    public ToResult getResult() {
-       //String resultHeader = "Result of task with Header="+taskHeader+": randomSeed="+randomSeed+": pathStartValue="+(int)pathStartValue;
-       ToResult res = new ToResult(/*resultHeader,*/
-                                   expectedReturnRate,
-                                   volatility,
-                                   volatility2,
-                                   finalStockPrice,
-                                   pathValue);
-       return res;
-    }
+    mcPath = new MonteCarloPath();
+  }
+  //------------------------------------------------------------------------
+  // Methods.
+  //------------------------------------------------------------------------
+  //------------------------------------------------------------------------
+  // Methods which implement the Slaveable interface.
+  //------------------------------------------------------------------------
+  /**
+   * Method which is passed in the initialisation data common to all tasks,
+   * and then unpacks them for use by this object.
+   *
+   * @param obj Object representing data which are common to all tasks.
+   */
+  public void setInitAllTasks(AppDemoRunner obj) {
+    mcPath.name = obj.name;
+    mcPath.startDate = obj.startDate;
+    mcPath.endDate = obj.endDate;
+    mcPath.dTime = obj.dTime;
+    mcPath.returnDefinition = obj.returnDefinition;
+    mcPath.expectedReturnRate = obj.expectedReturnRate;
+    mcPath.volatility = obj.volatility;
+    int nTimeSteps = obj.nTimeSteps;
+    mcPath.nTimeSteps = nTimeSteps;
+    this.pathStartValue = obj.pathStartValue;
+    mcPath.pathStartValue = pathStartValue;
+    mcPath.pathValue = new float[nTimeSteps];
+    mcPath.fluctuations = new float[nTimeSteps];
+  }
+  /**
+   * Method which is passed in the data representing each task, which then
+   * unpacks it for use by this object.
+   *
+   * @param obj Object representing the data which defines a given task.
+   */
+  public void setTask(/*String header, */long randomSeed) {
+    //this.taskHeader     = header;
+    this.randomSeed     = randomSeed;
+  }
+  /**
+   * The business end.  Invokes the necessary computation routine, for a
+   * a given task.
+   */
+  public void run() {
+    mcPath.computeFluctuationsGaussian(randomSeed);
+    mcPath.computePathValue(pathStartValue);
+    RatePath rateP = new RatePath(mcPath);
+    ReturnPath returnP = rateP.getReturnCompounded();
+    returnP.estimatePath();
+    expectedReturnRate = returnP.expectedReturnRate;
+    volatility = returnP.volatility;
+    volatility2 = returnP.volatility2;
+    finalStockPrice = rateP.getEndPathValue();//pathValue[rateP.pathValue.length-1];
+    pathValue = mcPath.pathValue;
+  }
+  /*
+   * Method which returns the results of a computation back to the caller.
+   *
+   * @return An object representing the computed results.
+   */
+  public ToResult getResult() {
+    //String resultHeader = "Result of task with Header="+taskHeader+": randomSeed="+randomSeed+": pathStartValue="+(int)pathStartValue;
+    ToResult res = new ToResult(/*resultHeader,*/
+        expectedReturnRate,
+        volatility,
+        volatility2,
+        finalStockPrice,
+        pathValue);
+    return res;
+  }
 }
index f7576982feb5ecfab7c4688b5adb8a6990c2edd8..c22a0c3878db375cbbed40e2be9a9e9e0cac8424 100644 (file)
@@ -1,4 +1,4 @@
-/** Banboo Version  **/
+package JGFMonteCarlo;
 
 /**************************************************************************
  *                                                                         *
  * </ol>
  *
  * @author H W Yau
- * @version $Revision: 1.1 $ $Date: 2011/07/13 23:49:52 $
+ * @version $Revision: 1.2 $ $Date: 2011/07/14 21:28:29 $
  */
 public class RatePath extends PathId {
 
-    //------------------------------------------------------------------------
-    // Class variables.
-    //------------------------------------------------------------------------
-    /**
-     * Class variable to represent the minimal date, whence the stock prices
-     * appear. Used to trap any potential problems with the data.
-     */
-    public int MINIMUMDATE;
-    /**
-     * Class variable for defining what is meant by a small number, small enough
-     * to cause an arithmetic overflow when dividing.  According to the
-     * Java Nutshell book, the actual range is +/-4.9406564841246544E-324
-     */
-    public float EPSILON;
+  //------------------------------------------------------------------------
+  // Class variables.
+  //------------------------------------------------------------------------
+  /**
+   * Class variable to represent the minimal date, whence the stock prices
+   * appear. Used to trap any potential problems with the data.
+   */
+  public int MINIMUMDATE;
+  /**
+   * Class variable for defining what is meant by a small number, small enough
+   * to cause an arithmetic overflow when dividing.  According to the
+   * Java Nutshell book, the actual range is +/-4.9406564841246544E-324
+   */
+  public float EPSILON;
 
-    //------------------------------------------------------------------------
-    // Instance variables.
-    //------------------------------------------------------------------------
-    /**
-     * An instance variable, for storing the rate's path values itself.
-     */
-    public float[] pathValue;
-    /**
-     * An instance variable, for storing the corresponding date of the datum,
-     * in 'YYYYMMDD' format.
-     */
-    public int[] pathDate;
-    /**
-     * The number of accepted values in the rate path.
-     */
-    public int nAcceptedPathValue;
+  //------------------------------------------------------------------------
+  // Instance variables.
+  //------------------------------------------------------------------------
+  /**
+   * An instance variable, for storing the rate's path values itself.
+   */
+  public float[] pathValue;
+  /**
+   * An instance variable, for storing the corresponding date of the datum,
+   * in 'YYYYMMDD' format.
+   */
+  public int[] pathDate;
+  /**
+   * The number of accepted values in the rate path.
+   */
+  public int nAcceptedPathValue;
 
-    //------------------------------------------------------------------------
-    // Constructors.
-    //------------------------------------------------------------------------
-    /**
-     * Constructor, where the user specifies the directory and filename in
-     * from which the data should be read.
-     *
-     * @param String dirName
-     * @param String filename
-     * @exception DemoException thrown if there is a problem reading in
-     *                          the data file.
-     */
-    public RatePath() {
-       this.MINIMUMDATE = 19000101;
-       this.EPSILON= (float)10.0 * (float)(4.9E-324);
-       this.nAcceptedPathValue = 0;
-       readRatesFile();
-    }
-    /**
-     * Constructor, for when the user specifies simply an array of values
-     * for the path.  User must also include information for specifying
-     * the other characteristics of the path.
-     *
-     * @param pathValue the array containing the values for the path.
-     * @param name the name to attach to the path.
-     * @param startDate date from which the path is supposed to start, in
-     *        'YYYYMMDD' format.
-     * @param startDate date from which the path is supposed to end, in
-     *        'YYYYMMDD' format.
-     * @param dTime the time interval between successive path values, in
-     *        fractions of a year.
-     */
-    public RatePath(float[] pathValue, 
-                   String name, 
-                   int startDate, 
-                   int endDate, 
-                   float dTime) {
-       this.MINIMUMDATE = 19000101;
-       this.EPSILON= (float)10.0 * (float)(4.9E-324);
-       
-       this.name = name;
-       this.startDate = startDate;
-       this.endDate = endDate;
-       this.dTime = dTime;
-       this.pathValue = pathValue;
-       this.nAcceptedPathValue = pathValue.length;
-    }
-    /**
-     * Constructor, for use by the Monte Carlo generator, when it wishes
-     * to represent its findings as a RatePath object.
-     *
-     * @param mc the Monte Carlo generator object, whose data are to
-     *           be copied over.
-     * @exception DemoException thrown if there is an attempt to access
-     *            an undefined variable.
-     */
-    public RatePath(MonteCarloPath mc) {
-       this.MINIMUMDATE = 19000101;
-       this.EPSILON= (float)10.0 * (float)(4.9E-324);
+  //------------------------------------------------------------------------
+  // Constructors.
+  //------------------------------------------------------------------------
+  /**
+   * Constructor, where the user specifies the directory and filename in
+   * from which the data should be read.
+   *
+   * @param String dirName
+   * @param String filename
+   * @exception DemoException thrown if there is a problem reading in
+   *                          the data file.
+   */
+  public RatePath() {
+    this.MINIMUMDATE = 19000101;
+    this.EPSILON= (float)10.0 * (float)(4.9E-324);
+    this.nAcceptedPathValue = 0;
+    readRatesFile();
+  }
+  /**
+   * Constructor, for when the user specifies simply an array of values
+   * for the path.  User must also include information for specifying
+   * the other characteristics of the path.
+   *
+   * @param pathValue the array containing the values for the path.
+   * @param name the name to attach to the path.
+   * @param startDate date from which the path is supposed to start, in
+   *        'YYYYMMDD' format.
+   * @param startDate date from which the path is supposed to end, in
+   *        'YYYYMMDD' format.
+   * @param dTime the time interval between successive path values, in
+   *        fractions of a year.
+   */
+  public RatePath(float[] pathValue, 
+      String name, 
+      int startDate, 
+      int endDate, 
+      float dTime) {
+    this.MINIMUMDATE = 19000101;
+    this.EPSILON= (float)10.0 * (float)(4.9E-324);
+
+    this.name = name;
+    this.startDate = startDate;
+    this.endDate = endDate;
+    this.dTime = dTime;
+    this.pathValue = pathValue;
+    this.nAcceptedPathValue = pathValue.length;
+  }
+  /**
+   * Constructor, for use by the Monte Carlo generator, when it wishes
+   * to represent its findings as a RatePath object.
+   *
+   * @param mc the Monte Carlo generator object, whose data are to
+   *           be copied over.
+   * @exception DemoException thrown if there is an attempt to access
+   *            an undefined variable.
+   */
+  public RatePath(MonteCarloPath mc) {
+    this.MINIMUMDATE = 19000101;
+    this.EPSILON= (float)10.0 * (float)(4.9E-324);
 
-       //
-       // Fields pertaining to the parent PathId object:
-       this.name = mc.name;
-       this.startDate = mc.startDate;
-       this.endDate = mc.endDate;
-       this.dTime = mc.dTime;
-       //
-       // Fields pertaining to RatePath object itself.
-       pathValue=mc.pathValue;
-       nAcceptedPathValue=mc.nTimeSteps;
-       //
-       // Note that currently the pathDate is neither declared, defined,
-       // nor used in the MonteCarloPath object.
-       pathDate=new int[nAcceptedPathValue];
+    //
+    // Fields pertaining to the parent PathId object:
+    this.name = mc.name;
+    this.startDate = mc.startDate;
+    this.endDate = mc.endDate;
+    this.dTime = mc.dTime;
+    //
+    // Fields pertaining to RatePath object itself.
+    pathValue=mc.pathValue;
+    nAcceptedPathValue=mc.nTimeSteps;
+    //
+    // Note that currently the pathDate is neither declared, defined,
+    // nor used in the MonteCarloPath object.
+    pathDate=new int[nAcceptedPathValue];
+  }
+  /**
+   * Constructor, for when there is no actual pathValue with which to
+   * initialise.
+   *
+   * @param pathValueLegth the length of the array containing the values
+   *        for the path.
+   * @param name the name to attach to the path.
+   * @param startDate date from which the path is supposed to start, in
+   *        'YYYYMMDD' format.
+   * @param startDate date from which the path is supposed to end, in
+   *        'YYYYMMDD' format.
+   * @param dTime the time interval between successive path values, in
+   *        fractions of a year.
+   */
+  public RatePath(int pathValueLength, 
+      String name, 
+      int startDate, 
+      int endDate, 
+      float dTime) {
+    this.MINIMUMDATE = 19000101;
+    this.EPSILON= (float)10.0 * (float)(4.9E-324);
+
+    this.name = name;
+    this.startDate = startDate;
+    this.endDate = endDate;
+    this.dTime = dTime;
+    this.pathValue = new float[pathValueLength];
+    this.nAcceptedPathValue = pathValue.length;
+  }
+  //------------------------------------------------------------------------
+  // Methods.
+  //------------------------------------------------------------------------
+  /**
+   * Routine to update this rate path with the values from another rate
+   * path, via its pathValue array.
+   *
+   * @param operandPath the path value array to use for the update.
+   * @exception DemoException thrown if there is a mismatch between the
+   *            lengths of the operand and target arrays.
+   */
+  public boolean inc_pathValue(float[] operandPath) {
+    int length = this.pathValue.length;
+    if( length != operandPath.length ) {
+      return false;
     }
-    /**
-     * Constructor, for when there is no actual pathValue with which to
-     * initialise.
-     *
-     * @param pathValueLegth the length of the array containing the values
-     *        for the path.
-     * @param name the name to attach to the path.
-     * @param startDate date from which the path is supposed to start, in
-     *        'YYYYMMDD' format.
-     * @param startDate date from which the path is supposed to end, in
-     *        'YYYYMMDD' format.
-     * @param dTime the time interval between successive path values, in
-     *        fractions of a year.
-     */
-    public RatePath(int pathValueLength, 
-                   String name, 
-                   int startDate, 
-                   int endDate, 
-                   float dTime) {
-       this.MINIMUMDATE = 19000101;
-       this.EPSILON= (float)10.0 * (float)(4.9E-324);
-       
-       this.name = name;
-       this.startDate = startDate;
-       this.endDate = endDate;
-       this.dTime = dTime;
-       this.pathValue = new float[pathValueLength];
-       this.nAcceptedPathValue = pathValue.length;
+    float[] pathvalue = this.pathValue;
+    for(int i=0; i<length; i++ ) {
+      pathvalue[i] += operandPath[i];
     }
-    //------------------------------------------------------------------------
-    // Methods.
-    //------------------------------------------------------------------------
-    /**
-     * Routine to update this rate path with the values from another rate
-     * path, via its pathValue array.
-     *
-     * @param operandPath the path value array to use for the update.
-     * @exception DemoException thrown if there is a mismatch between the
-     *            lengths of the operand and target arrays.
-     */
-    public boolean inc_pathValue(float[] operandPath) {
-       int length = this.pathValue.length;
-       if( length != operandPath.length ) {
-           return false;
-       }
-       float[] pathvalue = this.pathValue;
-       for(int i=0; i<length; i++ ) {
-           pathvalue[i] += operandPath[i];
-       }
-       return true;
+    return true;
+  }
+  /**
+   * Routine to scale this rate path by a constant.
+   *
+   * @param scale the constant with which to multiply to all the path
+   *        values.
+   * @exception DemoException thrown if there is a mismatch between the
+   *            lengths of the operand and target arrays.
+   */
+  public boolean inc_pathValue(float scale) {
+    float[] pathvalue = this.pathValue;
+    if( pathvalue==null ) {
+      return false;
     }
-    /**
-     * Routine to scale this rate path by a constant.
-     *
-     * @param scale the constant with which to multiply to all the path
-     *        values.
-     * @exception DemoException thrown if there is a mismatch between the
-     *            lengths of the operand and target arrays.
-     */
-    public boolean inc_pathValue(float scale) {
-       float[] pathvalue = this.pathValue;
-       if( pathvalue==null ) {
-           return false;
-       }
-       int length = this.pathValue.length;
-       for(int i=0; i<length; i++ ) {
-           pathvalue[i] *= scale;
-       }
-       return true;
+    int length = this.pathValue.length;
+    for(int i=0; i<length; i++ ) {
+      pathvalue[i] *= scale;
     }
-    //------------------------------------------------------------------------
-    // Accessor methods for class RatePath.
-    // Generated by 'makeJavaAccessor.pl' script.  HWY.  20th January 1999.
-    //------------------------------------------------------------------------
-    /**
-     * Accessor method for private instance variable <code>pathValue</code>.
-     *
-     * @return Value of instance variable <code>pathValue</code>.
-     * @exception DemoException thrown if instance variable <code>pathValue</code> is undefined.
-     */
-    /*public float[] get_pathValue() {
+    return true;
+  }
+  //------------------------------------------------------------------------
+  // Accessor methods for class RatePath.
+  // Generated by 'makeJavaAccessor.pl' script.  HWY.  20th January 1999.
+  //------------------------------------------------------------------------
+  /**
+   * Accessor method for private instance variable <code>pathValue</code>.
+   *
+   * @return Value of instance variable <code>pathValue</code>.
+   * @exception DemoException thrown if instance variable <code>pathValue</code> is undefined.
+   */
+  /*public float[] get_pathValue() {
        return(this.pathValue);
     }*/
-    /**
-     * Set method for private instance variable <code>pathValue</code>.
-     *
-     * @param pathValue the value to set for the instance variable <code>pathValue</code>.
-     */
-    public void set_pathValue(float[] pathValue) {
-       this.pathValue = pathValue;
-    }
-    /**
-     * Accessor method for private instance variable <code>pathDate</code>.
-     *
-     * @return Value of instance variable <code>pathDate</code>.
-     * @exception DemoException thrown if instance variable <code>pathDate</code> is undefined.
-     */
-    /*public int[] get_pathDate() {
+  /**
+   * Set method for private instance variable <code>pathValue</code>.
+   *
+   * @param pathValue the value to set for the instance variable <code>pathValue</code>.
+   */
+  public void set_pathValue(float[] pathValue) {
+    this.pathValue = pathValue;
+  }
+  /**
+   * Accessor method for private instance variable <code>pathDate</code>.
+   *
+   * @return Value of instance variable <code>pathDate</code>.
+   * @exception DemoException thrown if instance variable <code>pathDate</code> is undefined.
+   */
+  /*public int[] get_pathDate() {
        return(this.pathDate);
     }*/
-    /**
-     * Set method for private instance variable <code>pathDate</code>.
-     *
-     * @param pathDate the value to set for the instance variable <code>pathDate</code>.
-     */
-    public void set_pathDate(int[] pathDate) {
-       this.pathDate = pathDate;
-    }
-    //------------------------------------------------------------------------
-    /**
-     * Method to return the terminal value for a given rate path, as used
-     * in derivative calculations.
-     * 
-     * @return The last value in the rate path.
-     */
-    public float getEndPathValue() {
-       return( getPathValue(pathValue.length-1) );
+  /**
+   * Set method for private instance variable <code>pathDate</code>.
+   *
+   * @param pathDate the value to set for the instance variable <code>pathDate</code>.
+   */
+  public void set_pathDate(int[] pathDate) {
+    this.pathDate = pathDate;
+  }
+  //------------------------------------------------------------------------
+  /**
+   * Method to return the terminal value for a given rate path, as used
+   * in derivative calculations.
+   * 
+   * @return The last value in the rate path.
+   */
+  public float getEndPathValue() {
+    return( getPathValue(pathValue.length-1) );
+  }
+  /**
+   * Method to return the value for a given rate path, at a given index.
+   * <i>One may want to index this in a more user friendly manner!</i>
+   * 
+   * @param index the index on which to return the path value.
+   * @return The value of the path at the designated index.
+   */
+  public float getPathValue(int index) {
+    return(pathValue[index]);
+  }
+  /**
+   * Method for calculating the returns on a given rate path, via the
+   * definition for the instantaneous compounded return.
+   *       u_i = \ln{\frac{S_i}{S_{i-1}}}
+   * 
+   * @return the return, as defined.
+   * @exception DemoException thrown if there is a problem with the
+   *                          calculation.
+   */
+  public ReturnPath getReturnCompounded() {
+    int length = this.nAcceptedPathValue;
+    float[] pathvalue = this.pathValue;
+    if( pathvalue == null || length == 0 ) {
+      return null;
     }
-    /**
-     * Method to return the value for a given rate path, at a given index.
-     * <i>One may want to index this in a more user friendly manner!</i>
-     * 
-     * @param index the index on which to return the path value.
-     * @return The value of the path at the designated index.
-     */
-    public float getPathValue(int index) {
-       return(pathValue[index]);
+    float[] returnPathValue = new float[length];
+    returnPathValue[0] = (float)0.0;
+    for(int i=1; i< length; i++ ) {
+      returnPathValue[i] = Math.logf(pathvalue[i] / pathvalue[i-1]);
     }
-    /**
-     * Method for calculating the returns on a given rate path, via the
-     * definition for the instantaneous compounded return.
-     *       u_i = \ln{\frac{S_i}{S_{i-1}}}
-     * 
-     * @return the return, as defined.
-     * @exception DemoException thrown if there is a problem with the
-     *                          calculation.
-     */
-    public ReturnPath getReturnCompounded() {
-       int length = this.nAcceptedPathValue;
-       float[] pathvalue = this.pathValue;
-       if( pathvalue == null || length == 0 ) {
-           return null;
-       }
-       float[] returnPathValue = new float[length];
-       returnPathValue[0] = (float)0.0;
-       for(int i=1; i< length; i++ ) {
-           returnPathValue[i] = Math.logf(pathvalue[i] / pathvalue[i-1]);
-       }
 
-       ReturnPath rPath = new ReturnPath(returnPathValue, length, 1);
-       //
-       // Copy the PathId information to the ReturnPath object.
-       rPath.copyInstanceVariables(this);
-       rPath.estimatePath();
-       return(rPath);
+    ReturnPath rPath = new ReturnPath(returnPathValue, length, 1);
+    //
+    // Copy the PathId information to the ReturnPath object.
+    rPath.copyInstanceVariables(this);
+    rPath.estimatePath();
+    return(rPath);
+  }
+  /**
+   * Method for calculating the returns on a given rate path, via the
+   * definition for the instantaneous non-compounded return.
+   *       u_i = \frac{S_i - S_{i-1}}{S_i}
+   * 
+   * @return the return, as defined.
+   * @exception DemoException thrown if there is a problem with the
+   *                          calculation.
+   */
+  public ReturnPath getReturnNonCompounded() {
+    int length = this.nAcceptedPathValue;
+    float[] pathvalue = this.pathValue;
+    if( pathvalue == null || length == 0 ) {
+      return null;
     }
-    /**
-     * Method for calculating the returns on a given rate path, via the
-     * definition for the instantaneous non-compounded return.
-     *       u_i = \frac{S_i - S_{i-1}}{S_i}
-     * 
-     * @return the return, as defined.
-     * @exception DemoException thrown if there is a problem with the
-     *                          calculation.
-     */
-    public ReturnPath getReturnNonCompounded() {
-       int length = this.nAcceptedPathValue;
-       float[] pathvalue = this.pathValue;
-       if( pathvalue == null || length == 0 ) {
-           return null;
-       }
-       float[] returnPathValue = new float[length];
-       returnPathValue[0] = (float)0.0;
-       for(int i=1; i< length; i++ ) {
-           returnPathValue[i] = (pathvalue[i] - pathvalue[i-1])/pathvalue[i];
-       }
-       
-       ReturnPath rPath = new ReturnPath(returnPathValue, length, 2);
-       //
-       // Copy the PathId information to the ReturnPath object.
-       rPath.copyInstanceVariables(this);
-       rPath.estimatePath();
-       return(rPath);
+    float[] returnPathValue = new float[length];
+    returnPathValue[0] = (float)0.0;
+    for(int i=1; i< length; i++ ) {
+      returnPathValue[i] = (pathvalue[i] - pathvalue[i-1])/pathvalue[i];
     }
-    //------------------------------------------------------------------------
-    // Private methods.
-    //------------------------------------------------------------------------
-    /**
-     * Method for reading in data file, in a given format.
-     * Namely:
+
+    ReturnPath rPath = new ReturnPath(returnPathValue, length, 2);
+    //
+    // Copy the PathId information to the ReturnPath object.
+    rPath.copyInstanceVariables(this);
+    rPath.estimatePath();
+    return(rPath);
+  }
+  //------------------------------------------------------------------------
+  // Private methods.
+  //------------------------------------------------------------------------
+  /**
+   * Method for reading in data file, in a given format.
+   * Namely:
       <pre>
       881003,0.0000,14.1944,13.9444,14.0832,2200050,0
       881004,0.0000,14.1668,14.0556,14.1668,1490850,0
@@ -339,43 +339,43 @@ public class RatePath extends PathId {
       990111,35.8125,35.8750,34.8750,35.1250,3920800,0
       990112,34.8750,34.8750,34.0000,34.0625,3577500,0
       </pre>
-     * <p>Where the fields represent, one believes, the following:
-     * <ol>
-     *   <li>The date in 'YYMMDD' format</li>
-     *   <li>Open</li>
-     *   <li>High</li>
-     *   <li>Low</li>
-     *   <li>Last</li>
-     *   <li>Volume</li>
-     *   <li>Open Interest</li>
-     * </ol>
-     * One will probably make use of the closing price, but this can be
-     * redefined via the class variable <code>DATUMFIELD</code>.  Note that
-     * since the read in data are then used to compute the return, this would
-     * be a good place to trap for zero values in the data, which will cause
-     * all sorts of problems.
-     *
-     * @param dirName the directory in which to search for the data file.
-     * @param filename the data filename itself.
-     * @exception DemoException thrown if there was a problem with the data
-     *                          file.
-     */
-    private void readRatesFile(){
-       //
-       // Now create an array to store the rates data.
-       int minimumdate = MINIMUMDATE;
-       float epsilon = EPSILON;
-       int nLines = 1000; //200;
-       int year = 88;
-       int month = 10;
-       int day = 3;
-       this.pathValue = new float[nLines];
-       this.pathDate  = new int[nLines];
-       float[] pathvalue = this.pathValue;
-       int[] pathdate = this.pathDate;
-       nAcceptedPathValue=0;
-       int iLine=0;
-       /*char[] date = new char[9];
+   * <p>Where the fields represent, one believes, the following:
+   * <ol>
+   *   <li>The date in 'YYMMDD' format</li>
+   *   <li>Open</li>
+   *   <li>High</li>
+   *   <li>Low</li>
+   *   <li>Last</li>
+   *   <li>Volume</li>
+   *   <li>Open Interest</li>
+   * </ol>
+   * One will probably make use of the closing price, but this can be
+   * redefined via the class variable <code>DATUMFIELD</code>.  Note that
+   * since the read in data are then used to compute the return, this would
+   * be a good place to trap for zero values in the data, which will cause
+   * all sorts of problems.
+   *
+   * @param dirName the directory in which to search for the data file.
+   * @param filename the data filename itself.
+   * @exception DemoException thrown if there was a problem with the data
+   *                          file.
+   */
+  private void readRatesFile(){
+    //
+    // Now create an array to store the rates data.
+    int minimumdate = MINIMUMDATE;
+    float epsilon = EPSILON;
+    int nLines = 1000; //200;
+    int year = 88;
+    int month = 10;
+    int day = 3;
+    this.pathValue = new float[nLines];
+    this.pathDate  = new int[nLines];
+    float[] pathvalue = this.pathValue;
+    int[] pathdate = this.pathDate;
+    nAcceptedPathValue=0;
+    int iLine=0;
+    /*char[] date = new char[9];
        date[0] = '1';
        date[1] = '9';
        date[2] = (char)(year/10 + '0');
@@ -385,13 +385,13 @@ public class RatePath extends PathId {
        date[6] = (char)(day/10 + '0');
        date[7] = (char)(day%10 + '0');
        date[8] = '\0';*/
-       int aDate = 19881003;
-       /*for(int di = 0; di < 9; di++) {
+    int aDate = 19881003;
+    /*for(int di = 0; di < 9; di++) {
            aDate = aDate * 10 + (int)date[di];
        }*/
-       for(int k = 0; k < 20; /*40;*/ k++ ) {
-           for(int j = 0; j < 50; /*5;*/ j++) {
-               /*String date = "19"+String.valueOf(year);
+    for(int k = 0; k < 20; /*40;*/ k++ ) {
+      for(int j = 0; j < 50; /*5;*/ j++) {
+        /*String date = "19"+String.valueOf(year);
                if(month < 10) {
                    date += "0";
                } 
@@ -400,36 +400,36 @@ public class RatePath extends PathId {
                    date += "0";
                }
                date +=  String.valueOf(day);*/
-               //int aDate = Integer.parseInt(date);           
-               day++;
-               aDate++;
-               /*if(date[7] == '9') {
+        //int aDate = Integer.parseInt(date);          
+        day++;
+        aDate++;
+        /*if(date[7] == '9') {
                    date[7] = '0';
                    date[6] = (char)(date[6] + 1);
                } else {
                    date[7] = (char)(date[7] + 1);
                }*/
-               if(month == 2) {
-                   if(day == 29) {
-                       day = 1;
-                       month++;
-                       /*date[6] = '0';
+        if(month == 2) {
+          if(day == 29) {
+            day = 1;
+            month++;
+            /*date[6] = '0';
                        date[7] = '1';
                        date[5] = '3';*/
-                       aDate += 72;// - day(29) + 101;
-                   }
-               } else {
-                   if(day == 31) {
-                       day = 1;
-                       month++;
-                       aDate += 70;
-                       /*date[6] = '0';
+            aDate += 72;// - day(29) + 101;
+          }
+        } else {
+          if(day == 31) {
+            day = 1;
+            month++;
+            aDate += 70;
+            /*date[6] = '0';
                        date[7] = '1';*/
-                       if(month == 13) {
-                           month = 1;
-                           year++;
-                           aDate += 8800;
-                           /*date[4] = '0';
+            if(month == 13) {
+              month = 1;
+              year++;
+              aDate += 8800;
+              /*date[4] = '0';
                            date[5] = '1';
                            if(date[3] == '9') {
                                if(date[2] == '9') {
@@ -447,7 +447,7 @@ public class RatePath extends PathId {
                            } else {
                                date[3] = (char)(date[3] + 1);
                            }*/
-                       } /*else {
+            } /*else {
                            if(date[5] == '9') {
                                date[4] = '1';
                                date[5] = '0';
@@ -455,29 +455,29 @@ public class RatePath extends PathId {
                                date[5] = (char)(date[5] + 1);
                            }
                        }*/
-                   }
-               }
-               //
-               // static float float.parsefloat() method is a feature of JDK1.2!
-               int tmp = k + j;
-               float aPathValue = (float)(121.7500 - tmp);
-               if( (aDate <= minimumdate) /*| (Math.abs(aPathValue) < epsilon)*/ ) {
-                   //System.printString("Skipped erroneous data indexed by date="+date+".");
-               } else {
-                   pathdate[iLine] = aDate;
-                   pathvalue[iLine] = aPathValue;
-                   iLine++;
-               }
-           }
-       }
-       //
-       // Record the actual number of accepted data points.
-       nAcceptedPathValue = iLine;
-       //
-       // Now to fill in the structures from the 'PathId' class.
-       this.name = "rate";
-       this.startDate = pathdate[0];
-       this.endDate = pathdate[iLine-1];
-       this.dTime = (float)(1.0/365.0);
+          }
+        }
+        //
+        // static float float.parsefloat() method is a feature of JDK1.2!
+        int tmp = k + j;
+        float aPathValue = (float)(121.7500 - tmp);
+        if( (aDate <= minimumdate) /*| (Math.abs(aPathValue) < epsilon)*/ ) {
+          //System.printString("Skipped erroneous data indexed by date="+date+".");
+        } else {
+          pathdate[iLine] = aDate;
+          pathvalue[iLine] = aPathValue;
+          iLine++;
+        }
+      }
     }
+    //
+    // Record the actual number of accepted data points.
+    nAcceptedPathValue = iLine;
+    //
+    // Now to fill in the structures from the 'PathId' class.
+    this.name = "rate";
+    this.startDate = pathdate[0];
+    this.endDate = pathdate[iLine-1];
+    this.dTime = (float)(1.0/365.0);
+  }
 }
index 1f1eaee9c91ce4a95fef6db0e6a4b79bfceaa2d4..83c0d9a84bed73aee8e0b10d89dd82e1615df473 100644 (file)
-/** Banboo Version  **/
+package JGFMonteCarlo;
 
 /**************************************************************************
-*                                                                         *
-*         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
-*                                                                         *
-*                            produced by                                  *
-*                                                                         *
-*                  Java Grande Benchmarking Project                       *
-*                                                                         *
-*                                at                                       *
-*                                                                         *
-*                Edinburgh Parallel Computing Centre                      *
-*                                                                         *
-*                email: epcc-javagrande@epcc.ed.ac.uk                     *
-*                                                                         *
-*      Original version of this code by Hon Yau (hwyau@epcc.ed.ac.uk)     *
-*                                                                         *
-*      This version copyright (c) The University of Edinburgh, 2001.      *
-*                         All rights reserved.                            *
-*                                                                         *
-**************************************************************************/
+ *                                                                         *
+ *         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
+ *                                                                         *
+ *                            produced by                                  *
+ *                                                                         *
+ *                  Java Grande Benchmarking Project                       *
+ *                                                                         *
+ *                                at                                       *
+ *                                                                         *
+ *                Edinburgh Parallel Computing Centre                      *
+ *                                                                         *
+ *                email: epcc-javagrande@epcc.ed.ac.uk                     *
+ *                                                                         *
+ *      Original version of this code by Hon Yau (hwyau@epcc.ed.ac.uk)     *
+ *                                                                         *
+ *      This version copyright (c) The University of Edinburgh, 2001.      *
+ *                         All rights reserved.                            *
+ *                                                                         *
+ **************************************************************************/
 
 
 /**
 * Class for representing the returns of a given security.
 *
 * <p>To do list:
 * <ol>
 *   <li>Define a window over which the mean drift and volatility
 *       are calculated.</li>
 *   <li>Hash table to reference {DATE}->{pathValue-index}.</li>
 * </ol>
 *
 * @author H W Yau
 * @version $Revision: 1.1 $ $Date: 2011/07/13 23:49:52 $
 */
+ * Class for representing the returns of a given security.
+ *
+ * <p>To do list:
+ * <ol>
+ *   <li>Define a window over which the mean drift and volatility
+ *       are calculated.</li>
+ *   <li>Hash table to reference {DATE}->{pathValue-index}.</li>
+ * </ol>
+ *
+ * @author H W Yau
* @version $Revision: 1.2 $ $Date: 2011/07/14 21:28:29 $
+ */
 public class ReturnPath extends PathId {
   /**
-    * Flag for indicating one of the return definitions, via:
-    *       u_i = \ln{\frac{S_i}{S_{i-1}}}
-    * corresponding to the instantaneous compounded return.
-    */
+   * Flag for indicating one of the return definitions, via:
+   *       u_i = \ln{\frac{S_i}{S_{i-1}}}
+   * corresponding to the instantaneous compounded return.
+   */
   public int COMPOUNDED;
 
   /**
-    * Flag for indicating one of the return definitions, via:
-    *       u_i = \frac{S_i - S_{i-1}}{S_i}
-    * corresponding to the instantaneous non-compounded return.
-    */
+   * Flag for indicating one of the return definitions, via:
+   *       u_i = \frac{S_i - S_{i-1}}{S_i}
+   * corresponding to the instantaneous non-compounded return.
+   */
   public int NONCOMPOUNDED;
 
   //------------------------------------------------------------------------
   // Instance variables.
   //------------------------------------------------------------------------
   /**
-    * An instance variable, for storing the return values.
-    */
+   * An instance variable, for storing the return values.
+   */
   public float[] pathValue;
   /**
-    * The number of accepted values in the rate path.
-    */
+   * The number of accepted values in the rate path.
+   */
   public int nPathValue;
   /**
-    * Integer flag for indicating how the return was calculated.
-    */
+   * Integer flag for indicating how the return was calculated.
+   */
   public int returnDefinition;
   /**
-    * Value for the expected return rate.
-    */
+   * Value for the expected return rate.
+   */
   public float expectedReturnRate;
   /**
-    * Value for the volatility, calculated from the return data.
-    */
+   * Value for the volatility, calculated from the return data.
+   */
   public float volatility;
   /**
-    * Value for the volatility-squared, a more natural quantity
-    * to use for many of the calculations.
-    */
+   * Value for the volatility-squared, a more natural quantity
+   * to use for many of the calculations.
+   */
   public float volatility2;
   /**
-    * Value for the mean of this return.
-    */
+   * Value for the mean of this return.
+   */
   public float mean;
   /**
-    * Value for the variance of this return.
-    */
+   * Value for the variance of this return.
+   */
   public float variance;
 
   //------------------------------------------------------------------------
   // Constructors.
   //------------------------------------------------------------------------
   /**
-    * Default constructor.
-    */
+   * Default constructor.
+   */
   public ReturnPath() {
     super();
-    
+
     this.COMPOUNDED = 1;
     this.NONCOMPOUNDED = 2;
     this.nPathValue=-1;
@@ -108,21 +108,21 @@ public class ReturnPath extends PathId {
   }
 
   /**
-    * Another constructor.
-    *
-    * @param pathValue for creating a return path with a precomputed path
-    *                  value.  Indexed from 1 to <code>nPathArray-1</code>.
-    * @param nPathValue the number of accepted data points in the array.
-    * @param returnDefinition to tell this class how the return path values
-    *                         were computed.
-    */
+   * Another constructor.
+   *
+   * @param pathValue for creating a return path with a precomputed path
+   *                  value.  Indexed from 1 to <code>nPathArray-1</code>.
+   * @param nPathValue the number of accepted data points in the array.
+   * @param returnDefinition to tell this class how the return path values
+   *                         were computed.
+   */
   public ReturnPath(float[] pathValue, 
-                   int nPathValue, 
-                   int returnDefinition) {
+      int nPathValue, 
+      int returnDefinition) {
     this.pathValue = pathValue;
     this.nPathValue = nPathValue;
     this.returnDefinition = returnDefinition;
-    
+
     this.COMPOUNDED = 1;
     this.NONCOMPOUNDED = 2;
     this.expectedReturnRate = (float)0.0;
@@ -140,205 +140,205 @@ public class ReturnPath extends PathId {
   // Generated by 'makeJavaAccessor.pl' script.  HWY.  20th January 1999.
   //------------------------------------------------------------------------
   /**
-    * Accessor method for private instance variable <code>pathValue</code>.
-    *
-    * @return Value of instance variable <code>pathValue</code>.
-    * @exception DemoException thrown if instance variable <code>pathValue</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>pathValue</code>.
+   *
+   * @return Value of instance variable <code>pathValue</code>.
+   * @exception DemoException thrown if instance variable <code>pathValue</code> is undefined.
+   */
   /*public float[] get_pathValue(){
     return(this.pathValue);
   }*/
   /**
-    * Set method for private instance variable <code>pathValue</code>.
-    *
-    * @param pathValue the value to set for the instance variable <code>pathValue</code>.
-    */
+   * Set method for private instance variable <code>pathValue</code>.
+   *
+   * @param pathValue the value to set for the instance variable <code>pathValue</code>.
+   */
   public void set_pathValue(float[] pathValue) {
     this.pathValue = pathValue;
   }
   /**
-    * Accessor method for private instance variable <code>nPathValue</code>.
-    *
-    * @return Value of instance variable <code>nPathValue</code>.
-    * @exception DemoException thrown if instance variable <code>nPathValue</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>nPathValue</code>.
+   *
+   * @return Value of instance variable <code>nPathValue</code>.
+   * @exception DemoException thrown if instance variable <code>nPathValue</code> is undefined.
+   */
   /*public int get_nPathValue() {
     return(this.nPathValue);
   }*/
   /**
-    * Set method for private instance variable <code>nPathValue</code>.
-    *
-    * @param nPathValue the value to set for the instance variable <code>nPathValue</code>.
-    */
+   * Set method for private instance variable <code>nPathValue</code>.
+   *
+   * @param nPathValue the value to set for the instance variable <code>nPathValue</code>.
+   */
   public void set_nPathValue(int nPathValue) {
     this.nPathValue = nPathValue;
   }
   /**
-    * Accessor method for private instance variable <code>returnDefinition</code>.
-    *
-    * @return Value of instance variable <code>returnDefinition</code>.
-    * @exception DemoException thrown if instance variable <code>returnDefinition</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>returnDefinition</code>.
+   *
+   * @return Value of instance variable <code>returnDefinition</code>.
+   * @exception DemoException thrown if instance variable <code>returnDefinition</code> is undefined.
+   */
   /*public int get_returnDefinition() {
     return(this.returnDefinition);
   }*/
   /**
-    * Set method for private instance variable <code>returnDefinition</code>.
-    *
-    * @param returnDefinition the value to set for the instance variable <code>returnDefinition</code>.
-    */
+   * Set method for private instance variable <code>returnDefinition</code>.
+   *
+   * @param returnDefinition the value to set for the instance variable <code>returnDefinition</code>.
+   */
   public void set_returnDefinition(int returnDefinition) {
     this.returnDefinition = returnDefinition;
   }
   /**
-    * Accessor method for private instance variable <code>expectedReturnRate</code>.
-    *
-    * @return Value of instance variable <code>expectedReturnRate</code>.
-    * @exception DemoException thrown if instance variable <code>expectedReturnRate</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>expectedReturnRate</code>.
+   *
+   * @return Value of instance variable <code>expectedReturnRate</code>.
+   * @exception DemoException thrown if instance variable <code>expectedReturnRate</code> is undefined.
+   */
   /*public float get_expectedReturnRate() {
     return(this.expectedReturnRate);
   }*/
   /**
-    * Set method for private instance variable <code>expectedReturnRate</code>.
-    *
-    * @param expectedReturnRate the value to set for the instance variable <code>expectedReturnRate</code>.
-    */
+   * Set method for private instance variable <code>expectedReturnRate</code>.
+   *
+   * @param expectedReturnRate the value to set for the instance variable <code>expectedReturnRate</code>.
+   */
   public void set_expectedReturnRate(float expectedReturnRate) {
     this.expectedReturnRate = expectedReturnRate;
   }
   /**
-    * Accessor method for private instance variable <code>volatility</code>.
-    *
-    * @return Value of instance variable <code>volatility</code>.
-    * @exception DemoException thrown if instance variable <code>volatility</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>volatility</code>.
+   *
+   * @return Value of instance variable <code>volatility</code>.
+   * @exception DemoException thrown if instance variable <code>volatility</code> is undefined.
+   */
   /*public float get_volatility() {
     return(this.volatility);
   }*/
   /**
-    * Set method for private instance variable <code>volatility</code>.
-    *
-    * @param volatility the value to set for the instance variable <code>volatility</code>.
-    */
+   * Set method for private instance variable <code>volatility</code>.
+   *
+   * @param volatility the value to set for the instance variable <code>volatility</code>.
+   */
   public void set_volatility(float volatility) {
     this.volatility = volatility;
   }
   /**
-    * Accessor method for private instance variable <code>volatility2</code>.
-    *
-    * @return Value of instance variable <code>volatility2</code>.
-    * @exception DemoException thrown if instance variable <code>volatility2</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>volatility2</code>.
+   *
+   * @return Value of instance variable <code>volatility2</code>.
+   * @exception DemoException thrown if instance variable <code>volatility2</code> is undefined.
+   */
   /*public float get_volatility2() {
     return(this.volatility2);
   }*/
   /**
-    * Set method for private instance variable <code>volatility2</code>.
-    *
-    * @param volatility2 the value to set for the instance variable <code>volatility2</code>.
-    */
+   * Set method for private instance variable <code>volatility2</code>.
+   *
+   * @param volatility2 the value to set for the instance variable <code>volatility2</code>.
+   */
   public void set_volatility2(float volatility2) {
     this.volatility2 = volatility2;
   }
   /**
-    * Accessor method for private instance variable <code>mean</code>.
-    *
-    * @return Value of instance variable <code>mean</code>.
-    * @exception DemoException thrown if instance variable <code>mean</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>mean</code>.
+   *
+   * @return Value of instance variable <code>mean</code>.
+   * @exception DemoException thrown if instance variable <code>mean</code> is undefined.
+   */
   /*public float get_mean() {
     return(this.mean);
   }*/
   /**
-    * Set method for private instance variable <code>mean</code>.
-    *
-    * @param mean the value to set for the instance variable <code>mean</code>.
-    */
+   * Set method for private instance variable <code>mean</code>.
+   *
+   * @param mean the value to set for the instance variable <code>mean</code>.
+   */
   public void set_mean(float mean) {
     this.mean = mean;
   }
   /**
-    * Accessor method for private instance variable <code>variance</code>.
-    *
-    * @return Value of instance variable <code>variance</code>.
-    * @exception DemoException thrown if instance variable <code>variance</code> is undefined.
-    */
+   * Accessor method for private instance variable <code>variance</code>.
+   *
+   * @return Value of instance variable <code>variance</code>.
+   * @exception DemoException thrown if instance variable <code>variance</code> is undefined.
+   */
   /*public float get_variance() {
     return(this.variance);
   }*/
   /**
-    * Set method for private instance variable <code>variance</code>.
-    *
-    * @param variance the value to set for the instance variable <code>variance</code>.
-    */
+   * Set method for private instance variable <code>variance</code>.
+   *
+   * @param variance the value to set for the instance variable <code>variance</code>.
+   */
   public void set_variance(float variance) {
     this.variance = variance;
   }
   //------------------------------------------------------------------------
   /**
-    * Method to calculate the expected return rate from the return data,
-    * using the relationship:
-    *    \mu = \frac{\bar{u}}{\Delta t} + \frac{\sigma^2}{2}
-    *
-    * @exception DemoException thrown one tries to obtain an undefined variable.
-    */
+   * Method to calculate the expected return rate from the return data,
+   * using the relationship:
+   *    \mu = \frac{\bar{u}}{\Delta t} + \frac{\sigma^2}{2}
+   *
+   * @exception DemoException thrown one tries to obtain an undefined variable.
+   */
   public void computeExpectedReturnRate() {
     this.expectedReturnRate = mean/(float)this.dTime + (float)0.5*volatility2;
   }
   /**
-    * Method to calculate <code>volatility</code> and <code>volatility2</code>
-    * from the return path data, using the relationship, based on the
-    * precomputed <code>variance</code>. 
-    *   \sigma^2 = s^2\Delta t
-    
-    * @exception DemoException thrown if one of the quantites in the
-    *                          computation are undefined.
-    */
+   * Method to calculate <code>volatility</code> and <code>volatility2</code>
+   * from the return path data, using the relationship, based on the
+   * precomputed <code>variance</code>. 
+   *   \sigma^2 = s^2\Delta t
+   * 
+   * @exception DemoException thrown if one of the quantites in the
+   *                          computation are undefined.
+   */
   public void computeVolatility() {
     this.volatility2 = this.variance / (float)this.dTime;
     this.volatility  = Math.sqrtf(volatility2);
   }
   /**
-    * Method to calculate the mean of the return, for use by other
-    * calculations.
-    *
-    * @exception DemoException thrown if <code>nPathValue</code> is
-    *            undefined.
-    */
+   * Method to calculate the mean of the return, for use by other
+   * calculations.
+   *
+   * @exception DemoException thrown if <code>nPathValue</code> is
+   *            undefined.
+   */
   public void computeMean() {
-      float sum = (float) 0.0;
-      float[] tmpvalue = this.pathValue;
-      int length = this.nPathValue;
-      for( int i=1; i < length; i++ ) {
-         sum += tmpvalue[i];
-      }
-      this.mean = sum / ((float)(length - (float)1.0));
+    float sum = (float) 0.0;
+    float[] tmpvalue = this.pathValue;
+    int length = this.nPathValue;
+    for( int i=1; i < length; i++ ) {
+      sum += tmpvalue[i];
+    }
+    this.mean = sum / ((float)(length - (float)1.0));
   }
   /**
-    * Method to calculate the variance of the retrun, for use by other
-    * calculations.
-    *
-    * @exception DemoException thrown if the <code>mean</code> or
-    *            <code>nPathValue</code> values are undefined.
-    */
+   * Method to calculate the variance of the retrun, for use by other
+   * calculations.
+   *
+   * @exception DemoException thrown if the <code>mean</code> or
+   *            <code>nPathValue</code> values are undefined.
+   */
   public void computeVariance() {
-      float sum = (float) 0.0; 
-      int length = this.nPathValue;
-      float[] tmpvalue = this.pathValue;
-      float tmpmean = this.mean;
+    float sum = (float) 0.0; 
+    int length = this.nPathValue;
+    float[] tmpvalue = this.pathValue;
+    float tmpmean = this.mean;
     for( int i=1; i < length; i++ ) {
-       sum += (tmpvalue[i] - tmpmean)*(tmpvalue[i] - tmpmean);
+      sum += (tmpvalue[i] - tmpmean)*(tmpvalue[i] - tmpmean);
     }
     this.variance = sum / ((float)(length - (float)1.0));
   }
   /**
-    * A single method for invoking all the necessary methods which
-    * estimate the parameters.
-    *
-    * @exception DemoException thrown if there is a problem reading any
-    *            variables.
-    */
+   * A single method for invoking all the necessary methods which
+   * estimate the parameters.
+   *
+   * @exception DemoException thrown if there is a problem reading any
+   *            variables.
+   */
   public void estimatePath() {
     computeMean();
     computeVariance();
@@ -346,15 +346,15 @@ public class ReturnPath extends PathId {
     computeVolatility();
   }
   /**
-    * Dumps the contents of the fields, to standard-out, for debugging.
-    */
+   * Dumps the contents of the fields, to standard-out, for debugging.
+   */
   public void dbgDumpFields() {
     super.dbgDumpFields();
-//    dbgPrintln("nPathValue="        +this.nPathValue);
-//    dbgPrintln("expectedReturnRate="+this.expectedReturnRate);
-//    dbgPrintln("volatility="        +this.volatility);
-//    dbgPrintln("volatility2="       +this.volatility2);
-//    dbgPrintln("mean="              +this.mean);
-//    dbgPrintln("variance="          +this.variance);
+    //    dbgPrintln("nPathValue="        +this.nPathValue);
+    //    dbgPrintln("expectedReturnRate="+this.expectedReturnRate);
+    //    dbgPrintln("volatility="        +this.volatility);
+    //    dbgPrintln("volatility2="       +this.volatility2);
+    //    dbgPrintln("mean="              +this.mean);
+    //    dbgPrintln("variance="          +this.variance);
   }
 }
index b1cf010f3a1d540cbf5fffe27dbb0be00ddb057d..738455321abc52a229d0b2cf34c8b7811dab7044 100644 (file)
@@ -1,33 +1,33 @@
-/** Banboo Version  **/
+package JGFMonteCarlo;
 
 /**************************************************************************
-*                                                                         *
-*         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
-*                                                                         *
-*                            produced by                                  *
-*                                                                         *
-*                  Java Grande Benchmarking Project                       *
-*                                                                         *
-*                                at                                       *
-*                                                                         *
-*                Edinburgh Parallel Computing Centre                      *
-*                                                                         *
-*                email: epcc-javagrande@epcc.ed.ac.uk                     *
-*                                                                         *
-*      Original version of this code by Hon Yau (hwyau@epcc.ed.ac.uk)     *
-*                                                                         *
-*      This version copyright (c) The University of Edinburgh, 2001.      *
-*                         All rights reserved.                            *
-*                                                                         *
-**************************************************************************/
+ *                                                                         *
+ *         Java Grande Forum Benchmark Suite - Thread Version 1.0          *
+ *                                                                         *
+ *                            produced by                                  *
+ *                                                                         *
+ *                  Java Grande Benchmarking Project                       *
+ *                                                                         *
+ *                                at                                       *
+ *                                                                         *
+ *                Edinburgh Parallel Computing Centre                      *
+ *                                                                         *
+ *                email: epcc-javagrande@epcc.ed.ac.uk                     *
+ *                                                                         *
+ *      Original version of this code by Hon Yau (hwyau@epcc.ed.ac.uk)     *
+ *                                                                         *
+ *      This version copyright (c) The University of Edinburgh, 2001.      *
+ *                         All rights reserved.                            *
+ *                                                                         *
+ **************************************************************************/
 
 /**
 * Class for defining the results of a task.  Currently, this is simply
 * the Monte Carlo generate rate path.
 *
 * @author H W Yau
 * @version $Revision: 1.1 $ $Date: 2011/07/13 23:49:52 $
 */
+ * Class for defining the results of a task.  Currently, this is simply
+ * the Monte Carlo generate rate path.
+ *
+ * @author H W Yau
* @version $Revision: 1.2 $ $Date: 2011/07/14 21:28:29 $
+ */
 public class ToResult {
   //private String header;
   public float expectedReturnRate;
@@ -37,17 +37,17 @@ public class ToResult {
   public float[] pathValue;
 
   /**
-    * Constructor, for the results from a computation.
-    *
-    * @param header Simple header string.
-    * @param pathValue Data computed by the Monte Carlo generator.
-    */
+   * Constructor, for the results from a computation.
+   *
+   * @param header Simple header string.
+   * @param pathValue Data computed by the Monte Carlo generator.
+   */
   public ToResult(/*String header, */
-                 float expectedReturnRate, 
-                 float volatility, 
-                 float volatility2, 
-                 float finalStockPrice, 
-                 float[] pathValue) {
+      float expectedReturnRate, 
+      float volatility, 
+      float volatility2, 
+      float finalStockPrice, 
+      float[] pathValue) {
     //this.header=header;
     this.expectedReturnRate = expectedReturnRate;
     this.volatility = volatility;
@@ -56,10 +56,10 @@ public class ToResult {
     this.pathValue = pathValue;
   }
   /**
-    * Gives a simple string representation of this object.
-    *
-    * @return String representation of this object.
-    */
+   * Gives a simple string representation of this object.
+   *
+   * @return String representation of this object.
+   */
   /*public String toString(){
     return(header);
   }*/
@@ -68,100 +68,100 @@ public class ToResult {
   // Generated by 'makeJavaAccessor.pl' script.  HWY.  20th January 1999.
   //------------------------------------------------------------------------
   /**
-    * Accessor method for private instance variable <code>header</code>.
-    *
-    * @return Value of instance variable <code>header</code>.
-    */
+   * Accessor method for private instance variable <code>header</code>.
+   *
+   * @return Value of instance variable <code>header</code>.
+   */
   /*public String get_header() {
     return(this.header);
   }*/
   /**
-    * Set method for private instance variable <code>header</code>.
-    *
-    * @param header the value to set for the instance variable <code>header</code>.
-    */
+   * Set method for private instance variable <code>header</code>.
+   *
+   * @param header the value to set for the instance variable <code>header</code>.
+   */
   /*public void set_header(String header) {
     this.header = header;
   }*/
   /**
-    * Accessor method for private instance variable <code>expectedReturnRate</code>.
-    *
-    * @return Value of instance variable <code>expectedReturnRate</code>.
-    */
+   * Accessor method for private instance variable <code>expectedReturnRate</code>.
+   *
+   * @return Value of instance variable <code>expectedReturnRate</code>.
+   */
   /*public float get_expectedReturnRate() {
     return(this.expectedReturnRate);
   }*/
   /**
-    * Set method for private instance variable <code>expectedReturnRate</code>.
-    *
-    * @param expectedReturnRate the value to set for the instance variable 
-    * <code>expectedReturnRate</code>.
-    */
+   * Set method for private instance variable <code>expectedReturnRate</code>.
+   *
+   * @param expectedReturnRate the value to set for the instance variable 
+   * <code>expectedReturnRate</code>.
+   */
   public void set_expectedReturnRate(float expectedReturnRate) {
     this.expectedReturnRate = expectedReturnRate;
   }
   /**
-    * Accessor method for private instance variable <code>volatility</code>.
-    *
-    * @return Value of instance variable <code>volatility</code>.
-    */
+   * Accessor method for private instance variable <code>volatility</code>.
+   *
+   * @return Value of instance variable <code>volatility</code>.
+   */
   /*public float get_volatility() {
     return(this.volatility);
   }*/
   /**
-    * Set method for private instance variable <code>volatility</code>.
-    *
-    * @param volatility the value to set for the instance variable <code>volatility</code>.
-    */
+   * Set method for private instance variable <code>volatility</code>.
+   *
+   * @param volatility the value to set for the instance variable <code>volatility</code>.
+   */
   public void set_volatility(float volatility) {
     this.volatility = volatility;
   }
   /**
-    * Accessor method for private instance variable <code>volatility2</code>.
-    *
-    * @return Value of instance variable <code>volatility2</code>.
-    */
+   * Accessor method for private instance variable <code>volatility2</code>.
+   *
+   * @return Value of instance variable <code>volatility2</code>.
+   */
   /*public float get_volatility2() {
     return(this.volatility2);
   }*/
   /**
-    * Set method for private instance variable <code>volatility2</code>.
-    *
-    * @param volatility2 the value to set for the instance variable <code>volatility2</code>.
-    */
+   * Set method for private instance variable <code>volatility2</code>.
+   *
+   * @param volatility2 the value to set for the instance variable <code>volatility2</code>.
+   */
   public void set_volatility2(float volatility2) {
     this.volatility2 = volatility2;
   }
   /**
-    * Accessor method for private instance variable <code>finalStockPrice</code>.
-    *
-    * @return Value of instance variable <code>finalStockPrice</code>.
-    */
+   * Accessor method for private instance variable <code>finalStockPrice</code>.
+   *
+   * @return Value of instance variable <code>finalStockPrice</code>.
+   */
   /*public float get_finalStockPrice() {
     return(this.finalStockPrice);
   }*/
   /**
-    * Set method for private instance variable <code>finalStockPrice</code>.
-    *
-    * @param finalStockPrice the value to set for the instance variable 
-    * <code>finalStockPrice</code>.
-    */
+   * Set method for private instance variable <code>finalStockPrice</code>.
+   *
+   * @param finalStockPrice the value to set for the instance variable 
+   * <code>finalStockPrice</code>.
+   */
   public void set_finalStockPrice(float finalStockPrice) {
     this.finalStockPrice = finalStockPrice;
   }
   /**
-    * Accessor method for private instance variable <code>pathValue</code>.
-    *
-    * @return Value of instance variable <code>pathValue</code>.
-    */
+   * Accessor method for private instance variable <code>pathValue</code>.
+   *
+   * @return Value of instance variable <code>pathValue</code>.
+   */
   /*public float[] get_pathValue() {
     return(this.pathValue);
   }*/
   /**
-    * Set method for private instance variable <code>pathValue</code>.
-    *
-    * @param pathValue the value to set for the instance variable <code>pathValue</code>.
-    */
+   * Set method for private instance variable <code>pathValue</code>.
+   *
+   * @param pathValue the value to set for the instance variable <code>pathValue</code>.
+   */
   public void set_pathValue(float[] pathValue) {
     this.pathValue = pathValue;
   }
index 08f0322ca42db93e37f65661f51ebbd6f83c4fb6..373a8491d6fd9089205571cef54849ec118abefc 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 public class Composer {
 
   int numCore;
@@ -8,7 +10,7 @@ public class Composer {
   public long result1;
 
   public Composer(int numCore,
-                  int size) {
+      int size) {
     this.numCore = numCore;
     this.num_composed = 0;
     heightPerCore = size/this.numCore;
@@ -18,7 +20,7 @@ public class Composer {
     this.result = 0;
     this.result1 = 0;
   }
-  
+
   public boolean compose(TestRunner tr) {
     this.num_composed++;
     int startidx=0; //heightPerCore * tr.id;
index 653dd8b85a0cb2bdd6d26f4feff89eefe0531fd7..7c1ceba489b2d06773d4eb91e473061d5395e772 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index 5f7aca3f6d403c90885290f0998edcb8bb150e97..1d58ae2d9c65e298fd1939cf3a4370c6e4d89e51 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index 05750ede428440da921d6f8e353dcde0d55c8c3c..ca89298f91e51b268f051569d0d2472feb8658a1 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index ce0cf56d07cfcc813345ceb44cf4edfdb2dc37d4..3ccafae141151b1d760e63a1bd147fa38c0dc492 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index 7d86ecad8bbab35c4478709b97afcbc32e1368fd..659870e6360aa9b3e0b3fe2a9773648959aba457 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index 35b114ca0f1a48792a8ffa315c2501ee29f6674b..2cb307e8218f0342a2c39d9d53e18c6db2d2a0ed 100644 (file)
@@ -1,3 +1,4 @@
+package RayTracer;
 
 /**************************************************************************
  * * Java Grande Forum Benchmark Suite - Version 2.0 * * produced by * * Java
index 38b3e409af359835cc563a462b025792689677e3..f32cca5cdda54d3588454691ca743fd9fc5ef260 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index 24957b776c2098dd700cb71f8512b820589e749c..67d2ba402283f29c9be304a2a0d0888141800b7f 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
@@ -28,7 +30,7 @@ public class Sphere extends Primitive
 {
   Vec      c;
   float   r, r2;
-//Vec      v,b; // temporary vecs used to minimize the memory load
+  //Vec      v,b; // temporary vecs used to minimize the memory load
 
 
   public Sphere(Vec center, float radius) {
@@ -36,8 +38,8 @@ public class Sphere extends Primitive
     c = center;
     r = radius;
     r2 = r*r;
-//  v=new Vec();
-//  b=new Vec();
+    //  v=new Vec();
+    //  b=new Vec();
   }
 
   public float dot(float x1, float y1, float z1, float x2, float y2, float z2){
@@ -69,7 +71,7 @@ public class Sphere extends Primitive
     ip = new Isect();
     ip.t = t;
     ip.enter = dot(x,y,z,x,y,z) > r2 + 1e-6 ? 1 : 0;
-//  ip.enter = Vec.dot(v, v) > r2 + 1e-6 ? 1 : 0;
+    //  ip.enter = Vec.dot(v, v) > r2 + 1e-6 ? 1 : 0;
     ip.prim = this;
     ip.surf = surf;
     return ip;
index 2bdc20eece5d9db14e42683f2fd3cb4663f04cf2..d0e1ecc9c733b24c9ffcb3ad1a40348d458a6402 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index 46ff50c2d453de9b73e364fe78d77cf0f88c2552..2c39a7c457ce008d3991ce4cca91c02901d6a4be 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  * * Java Grande Forum Benchmark Suite - Version 2.0 * * produced by * * Java
  * Grande Benchmarking Project * * at * * Edinburgh Parallel Computing Centre *
@@ -83,10 +85,7 @@ public class TestRunner extends RayTracer {
     Scene scene = rt.createScene();
     for(int i = 0; i < threadnum; ++i) {
       TestRunner tr = new TestRunner(i, threadnum, size, scene);
-      tr.run();
-      if(comp.compose(tr)) {
-        long r = comp.result;
-      }
+      tr.start();
     }
   }
 }
index 1daa0f06d9cad355859372407cc19787990d585e..2c4fd70599d1799aa328e9e092b9ea8fe89b1e61 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
@@ -130,9 +132,9 @@ public class Vec
 
   public static Vec cross(Vec a, Vec b) {
     return
-    new Vec(a.y*b.z - a.z*b.y,
-        a.z*b.x - a.x*b.z,
-        a.x*b.y - a.y*b.x);
+        new Vec(a.y*b.z - a.z*b.y,
+            a.z*b.x - a.x*b.z,
+            a.x*b.y - a.y*b.x);
   }
 
   public static float dot(Vec a, Vec b) {
@@ -141,9 +143,9 @@ public class Vec
 
   public static Vec comb(float a, Vec A, float b, Vec B) {
     return
-    new Vec(a * A.x + b * B.x,
-        a * A.y + b * B.y,
-        a * A.z + b * B.z);
+        new Vec(a * A.x + b * B.x,
+            a * A.y + b * B.y,
+            a * A.z + b * B.z);
   }
 
   public final void comb2(float a,Vec A,float b,Vec B) {
index f22e4ce92e2a174c83de39a0515ad0f7b6ca4996..3b46dc59ebea988b89a5de3240517a4f42adab73 100644 (file)
@@ -1,3 +1,5 @@
+package RayTracer;
+
 /**************************************************************************
  *                                                                         *
  *             Java Grande Forum Benchmark Suite - Version 2.0             *
index bc341f499e70ffa442c310b91feae141564cdf2f..0800f409cee7f28783de550db714733fa2e2083f 100644 (file)
@@ -1,3 +1,4 @@
+package bh;
 
 /**
  * A class used to representing particles in the N-body simulation.
index 4e83ee96cf430d8f93e2b9a2e22a33bd293baaa6..322998505946bbac57b7eb99f8b8d0c74c98a461 100644 (file)
@@ -1,3 +1,4 @@
+package bh;
 
 /**
  * A class used to represent internal nodes in the tree
index a13c3079aa4ed8123d89d380d5a3cd986facf0d9..6ee4ec7f1c08a434f80d9542351226e29683ef2b 100644 (file)
Binary files a/Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/MathVector.class and b/Robust/src/Benchmarks/Scheduling/GC/NON_BAMBOO/bh/MathVector.class differ
index e81e826650b7d8d5d7386b2f1d6dccea1d2ecc6e..02d654f8f15df9011d2a1a6b0d739b6c66394da1 100644 (file)
@@ -1,3 +1,4 @@
+package bh;
 
 /**
  * A class representing a three dimensional vector that implements
index 2d2cbaaa0060b13c114a32d06acb630fa856e716..f596e923440dbb83a532c876aa2814f93cafbe10 100644 (file)
@@ -1,3 +1,4 @@
+package bh;
 
 /**
  * A class that represents the common fields of a cell or body
@@ -40,7 +41,7 @@ class Node
     int i = 0;
     for (int k = 0; k < 3/*MathVector.NDIM*/; k++) {
       if (((int)ic.value(k) & l) != 0)
-    i += 8/*Cell.NSUB*/ >> (k + 1);
+        i += 8/*Cell.NSUB*/ >> (k + 1);
     }
     return i;
   }
@@ -73,40 +74,3 @@ class Node
     return hg;
   }
 }
-
-/**
- * A class which is used to compute and save information during the 
- * gravity computation phse.
- **/
-public class HG
-{
-  /**
-   * Body to skip in force evaluation
-   **/
-  public Body       pskip;
-  /**
-   * Point at which to evaluate field
-   **/
-  public MathVector pos0;  
-  /**
-   * Computed potential at pos0
-   **/
-  public double     phi0;  
-  /** 
-   * computed acceleration at pos0
-   **/
-  public MathVector acc0;  
-
-  /**
-   * Create a HG  object.
-   * @param b the body object
-   * @param p a vector that represents the body
-   **/
-  public HG(Body b, MathVector p)
-  {
-    pskip = b;
-    pos0  = (MathVector)p.clone();
-    phi0  = 0.0;
-    acc0  = new MathVector();
-  }
-}
index 213a708449b42f638f080ef3386161c677ad84a9..de3ffcbdbe2aef66e4444f61cdcfc08f98ab0c09 100644 (file)
@@ -1,4 +1,4 @@
-
+package bh;
 /*import java.util.Enumeration;
 import java.lang.Math;*/
 
@@ -17,7 +17,7 @@ import java.lang.Math;*/
  **/
 public class TestRunner extends Thread
 {
-  
+
   /**
    * The user specified number of bodies to create.
    **/
@@ -39,7 +39,7 @@ public class TestRunner extends Thread
 
   public  double DTIME; // = 0.0125;
   public  double TSTOP; // = 2.0;
-  
+
   public TestRunner(int nbody) {
     this.nbody = nbody;
     this.nsteps = 10;
@@ -91,10 +91,10 @@ public class TestRunner extends Thread
    * @param seed the seed to the generator
    * @return a random number
    **/
-  public  double myRand(double seed)
+  public double myRand(double seed)
   {
     double t = 16807.0*seed + 1;
-    
+
     seed = t - 2147483647.0 * Math.floor(t / 2147483647.0f);
     return seed;
   }
@@ -108,7 +108,7 @@ public class TestRunner extends Thread
    * @param r seed
    * @return a doubleing point randon number
    **/
-  public  double xRand(double xl, double xh, double r)
+  public double xRand(double xl, double xh, double r)
   {
     double res = xl + (xh-xl)*r/2147483647.0;
     return res;
@@ -119,7 +119,7 @@ public class TestRunner extends Thread
     int nbody = 700;
     for(int i = 0; i < threadnum; ++i) {
       TestRunner tr = new TestRunner(nbody);
-      tr.run();
+      tr.start();
     }
   }
 }
index 6dea99a84878f2d6a6e6e293aa0cf6a808e08144..821f62006d11ed40d1e5b05b669e00065a846a81 100644 (file)
@@ -1,3 +1,4 @@
+package bh;
 
 //import java.util.Enumeration;
 
@@ -8,7 +9,7 @@
 class Tree
 {
   public double DTIME; 
-  
+
   MathVector rmin;
   public double     rsize;
   /**
@@ -38,7 +39,7 @@ class Tree
     rmin.value(0, -2.0);
     rmin.value(1, -2.0);
     rmin.value(2, -2.0);
-    
+
     this.DTIME = DTIME;
   }
 
@@ -87,7 +88,7 @@ class Tree
     double res = xl + (xh-xl)*r/2147483647.0;
     return res;
   }
-  
+
   /**
    * Create the testdata used in the benchmark.
    * @param nbody the number of bodies to create
@@ -188,7 +189,7 @@ class Tree
     this.root = null;
 
     makeTree(nstep);
-    
+
     Body next = null;
     Body b = this.bodyTabRev;
     do {
@@ -270,7 +271,7 @@ class Tree
     MathVector dacc = new MathVector();
     MathVector dvel = new MathVector();
     double dthf = 0.5 * this.DTIME;
-    
+
     Body b = p;
     do {
       MathVector acc1 = (MathVector)b.newAcc.clone();
@@ -291,7 +292,7 @@ class Tree
       b.pos = (MathVector)dpos.clone();
       vel1.addition(dvel);
       b.vel = (MathVector)vel1.clone();
-      
+
       b = b.getProcNext();
     } while(b != null);
   }
index b22808d9c833daa451a80083bc5a22ecb0f6830a..9a91b4cc37c3deb92b97aebe58268f2caf209e31 100644 (file)
@@ -1,4 +1,6 @@
-public class TestRunner {
+package lcss;
+
+public class TestRunner extends Thread {
 
   int[] testargs;
 
@@ -240,7 +242,7 @@ public class TestRunner {
     args[5] = 240;
     for(int i = 0; i < threadnum; ++i) {
       TestRunner tr = new TestRunner(args);
-      tr.run();
+      tr.start();
     }
   }
 }
\ No newline at end of file
index 28f5ae2d23d98e98f5e04b62abdeadd663f78842..ce70adc480bbb0e4946d9dc7f1164e5ea48fcd3e 100644 (file)
@@ -1,3 +1,4 @@
+package tsp;
 
 //import java.io.*;
 
@@ -13,7 +14,7 @@
  **/
 public class TestRunner extends Thread
 {
-  
+
   /**
    * Number of cities in the problem.
    **/
@@ -26,7 +27,7 @@ public class TestRunner extends Thread
    * Set to true to print informative messages
    **/
   //private static boolean printMsgs = false;
-  
+
   public TestRunner(int cities) {
     this.cities = cities;
   }
@@ -41,7 +42,7 @@ public class TestRunner extends Thread
 
     if (printMsgs)
       System.out.println("Building tree of size " + cities);
-    
+
     long start0 = System.currentTimeMillis();*/
     Tree_tsp  t = Tree_tsp.buildTree(this.cities, false, 0.0f, 1.0f, 0.0f, 1.0f);
     /*long end0 = System.currentTimeMillis();
@@ -107,7 +108,7 @@ public class TestRunner extends Thread
     int ncities = 4080*2;
     for(int i = 0; i < threadnum; ++i) {
       TestRunner tr = new TestRunner(ncities);
-      tr.run();
+      tr.start();
     }
   }
 }
index 706ba059bc377d697cb05172ca19350787591c4a..164438aaa88e128f64b35845f7c3659572f67a14 100644 (file)
@@ -1,3 +1,4 @@
+package tsp;
 
 //import java.util.Random;
 
@@ -54,7 +55,7 @@ final class Tree_tsp
     M_E3  = 20.08553692318766774179f;
     M_E6  = 403.42879349273512264299f;
     M_E12 = 162754.79141900392083592475f;*/
-    
+
     sz = size;
     this.x = x;
     this.y = y;
@@ -298,7 +299,7 @@ final class Tree_tsp
       choice = 4;
 
     if (choice == 1) {
-    //case 1:
+      //case 1:
       // 1:p1,this this,p2 n2,n1 -- reverse 2!
       n2.reverse();
       p1.next = this;
@@ -309,7 +310,7 @@ final class Tree_tsp
       n1.prev = n2;
       //break;
     } else if(choice == 2) {
-    //case 2:
+      //case 2:
       // 2:p1,this this,n2 p2,n1 -- OK
       p1.next = this;
       this.prev = p1;
@@ -319,7 +320,7 @@ final class Tree_tsp
       n1.prev = p2;
       //break;
     } else if(choice == 3) {
-    //case 3:
+      //case 3:
       // 3:p2,this this,n1 p1,n2 -- OK
       p2.next = this;
       this.prev = p2;
@@ -329,7 +330,7 @@ final class Tree_tsp
       n2.prev = p1;
       //break;
     } else if(choice == 4) {
-    //case 4:
+      //case 4:
       // 4:n1,this this,n2 p2,p1 -- reverse 1!
       n1.reverse();
       n1.next = this;
@@ -388,7 +389,7 @@ final class Tree_tsp
     float M_E3  = 20.08553692318766774179f;
     float M_E6  = 403.42879349273512264299f;
     float M_E12 = 162754.79141900392083592475f;
-    
+
     // get random value in [0.0, 1.0)
     float t = (new Random()).nextFloat();
 
index b2819deaf39b1ada2512a6d2bf5595f00a2bbbdd..bd88150ff2d3b2b695c2cc360375690cdbae416e 100644 (file)
@@ -1,3 +1,4 @@
+package voronoi;
 
 /**
  * A class that represents the quad edge data structure which implements
index 0778de0172d6f1d27dca49c0dba3515f6c3d84b4..b8dffa4bb57a3992e1655086008feeea8a548cba 100644 (file)
@@ -1,4 +1,4 @@
-
+package voronoi;
 
 /**
  * A class that represents an edge pair
index c995c9cc10327eeee4f30bc2db4390d65d163bfb..1fe14f64e3ff7973634d39c8867d0e58f98a616b 100644 (file)
@@ -1,4 +1,4 @@
-
+package voronoi;
 
 /**
  * A class that represents a wrapper around a double value so 
index aa2f0f582be258a12550a13c71ba773fc0266bc7..52de99cab8e1064a58a4dddc51851670889ae1e9 100644 (file)
@@ -1,6 +1,7 @@
-
+package voronoi;
 
 /**
+ * 
  * A Java implementation of the <tt>voronoi</tt> Olden benchmark. Voronoi
  * generates a random set of points and computes a Voronoi diagram for
  * the points.
  **/
 public class TestRunner extends Thread
 {
-  
+
   /**
    * The number of points in the diagram
    **/
   private int points;
-  
+
   public TestRunner(int npoints) {
     this.points = npoints;
   }
@@ -41,13 +42,13 @@ public class TestRunner extends Thread
     Vertex point = v.createPoints(points-1, new MyDouble(extra.X()), points-1);
     Edge edge = point.buildDelaunayTriangulation(extra);
   }
-  
+
   public static void main(String[] args) {
     int threadnum = 62;
     int npoints = 32000;
     for(int i = 0; i < threadnum; ++i) {
       TestRunner tr = new TestRunner(npoints);
-      tr.run();
+      tr.start();
     }
   }
 }
index 10d1da9e2cd23485327b6ec26c96d03c791461b3..7feabff49a681d056265735190eae0925aa40c50 100644 (file)
@@ -1,4 +1,4 @@
-
+package voronoi;
 
 /**
  * Vector Routines from CMU vision library.  
@@ -11,7 +11,7 @@ class Vec2
   float norm;
 
   public Vec2() {}
-  
+
   public Vec2(float xx, float yy) 
   {
     x = xx;
@@ -33,7 +33,7 @@ class Vec2
   {
     return norm;
   }
-  
+
   public void setNorm(float d)
   {
     norm = d;
@@ -99,10 +99,10 @@ class Vec2
 
   Vec2 sub(Vec2 v)
   {
-     return(new Vec2((float)(x - v.x), (float)(y - v.y)));
+    return(new Vec2((float)(x - v.x), (float)(y - v.y)));
   }
 
-/* V2_magn: magnitude of vector */
+  /* V2_magn: magnitude of vector */
 
   float magn()
   {
@@ -118,4 +118,4 @@ class Vec2
 }
 
 
+
index 6ab45d72e12dfd7ffe443658f831bdfbcd941427..571caa1a3f8b6ace5bbe36e0e86332be84206793 100644 (file)
@@ -1,4 +1,4 @@
-
+package voronoi;
 
 /**
  * A class that represents a voronoi diagram.  The diagram is represnted
@@ -33,7 +33,7 @@ class Vertex extends Vec2
   {
     left = l;
   }
-  
+
   public void setRight(Vertex r)
   {
     right = r;
@@ -43,7 +43,7 @@ class Vertex extends Vec2
   {
     return left;
   }
-  
+
   public Vertex getRight()
   {
     return right;
@@ -68,7 +68,7 @@ class Vertex extends Vec2
     cur.right = right;
     curmax.value = (float)cur.X();
     Vertex left = cur.createPoints(n/2, curmax, i-1);
-    
+
     cur.left = left;
     return cur;
   }
@@ -100,7 +100,7 @@ class Vertex extends Vec2
 
       Edge e = new Edge();
       retval = e.doMerge(delleft.getLeft(), delleft.getRight(), 
-                           delright.getLeft(), delright.getRight());
+          delright.getLeft(), delright.getRight());
 
       Edge ldo = retval.getLeft();
       while (ldo.orig() != minx) { 
@@ -146,7 +146,7 @@ class Vertex extends Vec2
   /*void print()
   {
     Vertex tleft, tright;
-    
+
     System.out.println("X=" + X() + " Y=" + Y());
     if (left == null)
       System.out.println("NULL");
@@ -165,17 +165,17 @@ class Vertex extends Vec2
   {
     Vertex temp;
     Vertex tree = this;
-    
+
     while ((temp=tree.getLeft()) != null)
       tree = temp;
     return tree;
   } 
-  
+
   /****************************************************************/
   /*   Geometric primitives
-  ****************************************************************/
+   ****************************************************************/
   boolean incircle(Vertex b, Vertex c, Vertex d)
-    /* incircle, as in the Guibas-Stolfi paper. */
+  /* incircle, as in the Guibas-Stolfi paper. */
   {
     float adx, ady, bdx, bdy, cdx, cdy, dx, dy, anorm, bnorm, cnorm, dnorm;
     float dret ;
@@ -195,14 +195,14 @@ class Vertex extends Vec2
     dret += (float)((cnorm - dnorm) * (adx * bdy - ady * bdx));
     return( (0.0f < dret) ? true : false );
   }
-  
+
   boolean ccw(Vertex b, Vertex c)
   /* TRUE iff this, B, C form a counterclockwise oriented triangle */
   {
     float dret ;
     float xa,ya,xb,yb,xc,yc;
     Vertex loc_a,loc_b,loc_c;
-       
+
     int donexa,doneya,donexb,doneyb,donexc,doneyc;
 
     loc_a = this;
@@ -253,10 +253,10 @@ class Vertex extends Vec2
   {
     this.seed = this.random(this.seed);
     float retval = ((float)this.seed) /
-      (float) 2147483647;
+        (float) 2147483647;
     return retval;
   }
-  
+
 }
 
+