File tree Expand file tree Collapse file tree 4 files changed +63
-35
lines changed
src/com/evanstella/jnp/math Expand file tree Collapse file tree 4 files changed +63
-35
lines changed Original file line number Diff line number Diff line change 39
39
*
40
40
* @author Evan Stella
41
41
*****************************************************************************/
42
- public final class ElementWiseExecutor {
42
+ public final class ElementWiseExecutor extends ParallelExecutor {
43
43
44
- public int threadCount ;
45
- private final ExecutorService executorService ;
46
-
47
- // no instances for you
48
- public ElementWiseExecutor (int threadCount ) {
49
- this .threadCount = threadCount ;
50
- executorService = Executors .newFixedThreadPool (threadCount );
51
- }
52
-
53
- public void shutdown ( ) {
54
- executorService .shutdown ();
55
- }
56
-
57
- //TODO
58
- private static class executionWorker implements Runnable {
59
- final int startIdx , endIdx ;
60
- public executionWorker ( int start , int end ) {
61
- startIdx = start ;
62
- endIdx = end ;
63
- }
64
- public void run ( ) {}
44
+ public ElementWiseExecutor ( int threadCount ) {
45
+ super ( threadCount );
65
46
}
66
47
67
-
68
- private void await ( CountDownLatch count ) {
69
- try {
70
- count .await ();
71
- } catch ( InterruptedException e ) {
72
- throw new ExecutionInterruptedException (
73
- "Parallel execution was interrupted"
74
- );
75
- }
76
- }
77
-
78
-
79
48
/**************************************************************************
80
49
* <p>Take the negative of A element wise
81
50
*
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public final class Matrix {
40
40
// no instances for you
41
41
private Matrix ( ) {}
42
42
43
- private static void validateMatrixFatal ( Numeric N ) {
43
+ public static void validateMatrixFatal ( Numeric N ) {
44
44
if ( N .shape ().length == 2 )
45
45
return ;
46
46
Original file line number Diff line number Diff line change
1
+ package com .evanstella .jnp .math ;
2
+
3
+ import java .util .concurrent .ExecutorService ;
4
+ import java .util .concurrent .Executors ;
5
+
6
+ public final class MatrixExecutor extends ParallelExecutor {
7
+
8
+ public MatrixExecutor ( int threadCount ) {
9
+ super (threadCount );
10
+ }
11
+
12
+
13
+
14
+
15
+
16
+
17
+ }
Original file line number Diff line number Diff line change
1
+ package com .evanstella .jnp .math ;
2
+
3
+ import java .util .concurrent .CountDownLatch ;
4
+ import java .util .concurrent .ExecutorService ;
5
+ import java .util .concurrent .Executors ;
6
+
7
+ public class ParallelExecutor {
8
+
9
+ public int threadCount ;
10
+ protected final ExecutorService executorService ;
11
+
12
+ // no instances for you
13
+ public ParallelExecutor ( int threadCount ) {
14
+ this .threadCount = threadCount ;
15
+ executorService = Executors .newFixedThreadPool (threadCount );
16
+ }
17
+
18
+ public void shutdown ( ) {
19
+ executorService .shutdown ();
20
+ }
21
+
22
+ //TODO
23
+ protected static class executionWorker implements Runnable {
24
+ final int startIdx , endIdx ;
25
+ public executionWorker ( int start , int end ) {
26
+ startIdx = start ;
27
+ endIdx = end ;
28
+ }
29
+ public void run ( ) {}
30
+ }
31
+
32
+ protected void await ( CountDownLatch count ) {
33
+ try {
34
+ count .await ();
35
+ } catch ( InterruptedException e ) {
36
+ throw new ExecutionInterruptedException (
37
+ "Parallel execution was interrupted"
38
+ );
39
+ }
40
+ }
41
+
42
+ }
You can’t perform that action at this time.
0 commit comments