77 |
|
} |
78 |
|
} |
79 |
|
|
80 |
< |
|
81 |
< |
abstract static class MatrixTree extends CountedCompleter { |
80 |
> |
abstract static class MatrixTree extends CountedCompleter<Void> { |
81 |
|
// maximum difference between old and new values |
82 |
|
double maxDiff; |
83 |
< |
MatrixTree(CountedCompleter p, int c) { super(p, c); } |
83 |
> |
MatrixTree(CountedCompleter<?> p, int c) { super(p, c); } |
84 |
|
} |
85 |
|
|
87 |
– |
|
86 |
|
static final class LeafNode extends MatrixTree { |
87 |
|
final double[][] A; // matrix to get old values from |
88 |
|
final double[][] B; // matrix to put new values into |
93 |
|
|
94 |
|
int steps = 0; // track even/odd steps |
95 |
|
|
96 |
< |
LeafNode(CountedCompleter p, |
96 |
> |
LeafNode(CountedCompleter<?> p, |
97 |
|
double[][] A, double[][] B, |
98 |
|
int loRow, int hiRow, |
99 |
|
int loCol, int hiCol) { |
132 |
|
MatrixTree q2; |
133 |
|
MatrixTree q3; |
134 |
|
MatrixTree q4; |
135 |
< |
FourNode(CountedCompleter p) { |
135 |
> |
FourNode(CountedCompleter<?> p) { |
136 |
|
super(p, 3); |
137 |
|
} |
138 |
|
|
139 |
< |
public void onCompletion(CountedCompleter caller) { |
139 |
> |
public void onCompletion(CountedCompleter<?> caller) { |
140 |
|
double md = q1.maxDiff, m; |
141 |
|
if ((m = q2.maxDiff) > md) |
142 |
|
md = m; |
156 |
|
} |
157 |
|
} |
158 |
|
|
161 |
– |
|
159 |
|
static final class TwoNode extends MatrixTree { |
160 |
|
MatrixTree q1; |
161 |
|
MatrixTree q2; |
162 |
|
|
163 |
< |
TwoNode(CountedCompleter p) { |
163 |
> |
TwoNode(CountedCompleter<?> p) { |
164 |
|
super(p, 1); |
165 |
|
} |
166 |
|
|
167 |
< |
public void onCompletion(CountedCompleter caller) { |
167 |
> |
public void onCompletion(CountedCompleter<?> caller) { |
168 |
|
double md = q1.maxDiff, m; |
169 |
|
if ((m = q2.maxDiff) > md) |
170 |
|
md = m; |
176 |
|
q2.fork(); |
177 |
|
q1.compute(); |
178 |
|
} |
182 |
– |
|
179 |
|
} |
180 |
|
|
181 |
|
static final class Driver extends RecursiveAction { |
201 |
|
this.leafs = leafs; |
202 |
|
mat = build(null, A, B, firstRow, lastRow, firstCol, lastCol, leafs); |
203 |
|
System.out.println("Using " + nleaf + " segments"); |
208 |
– |
|
204 |
|
} |
205 |
|
|
206 |
|
MatrixTree build(MatrixTree p, |
255 |
|
System.out.println("max diff after " + steps + " steps = " + md); |
256 |
|
} |
257 |
|
} |
263 |
– |
|
264 |
– |
|
258 |
|
} |