ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/FJJacobi.java
(Generate patch)

Comparing jsr166/src/test/loops/FJJacobi.java (file contents):
Revision 1.7 by jsr166, Mon Sep 20 20:42:37 2010 UTC vs.
Revision 1.12 by jsr166, Thu Jan 15 18:34:19 2015 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   // Jacobi iteration on a mesh. Based loosely on a Filaments demo
# Line 10 | Line 10 | import java.util.concurrent.*;
10  
11   public class FJJacobi {
12  
13 <    static final int DEFAULT_GRANULARITY = 4096; // 1024;
13 >    //    static final int DEFAULT_GRANULARITY = 4096;
14 >    static final int DEFAULT_GRANULARITY = 256;
15  
16      /**
17       * The maximum number of matrix cells
18       * at which to stop recursing down and instead directly update.
19 <     **/
19 <
19 >     */
20      static final double EPSILON = 0.0001;  // convergence criterion
21  
22      public static void main(String[] args) throws Exception {
# Line 77 | Line 77 | public class FJJacobi {
77          }
78      }
79  
80
80      abstract static class MatrixTree extends RecursiveAction {
81          // maximum difference between old and new values
82          double maxDiff;
# Line 93 | Line 92 | public class FJJacobi {
92                  reinitialize();
93              }
94              double m = maxDiff;
95 <            return (md > m)? md : m;
95 >            return (md > m) ? md : m;
96          }
97  
98      }
99  
101
100      static final class LeafNode extends MatrixTree {
101          final double[][] A; // matrix to get old values from
102          final double[][] B; // matrix to put new values into
# Line 119 | Line 117 | public class FJJacobi {
117  
118          public void compute() {
119              boolean AtoB = (steps++ & 1) == 0;
120 <            double[][] a = (AtoB)? A : B;
121 <            double[][] b = (AtoB)? B : A;
120 >            double[][] a = AtoB ? A : B;
121 >            double[][] b = AtoB ? B : A;
122  
123              double md = 0.0; // local for computing max diff
124  
# Line 162 | Line 160 | public class FJJacobi {
160          }
161      }
162  
165
163      static final class TwoNode extends MatrixTree {
164          final MatrixTree q1;
165          final MatrixTree q2;
# Line 178 | Line 175 | public class FJJacobi {
175  
176      }
177  
181
178      static final class Driver extends RecursiveAction {
179          MatrixTree mat;
180          double[][] A; double[][] B;
# Line 250 | Line 246 | public class FJJacobi {
246              System.out.println("max diff after " + steps + " steps = " + md);
247          }
248      }
253
254
249   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines