-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrizWorker.java
More file actions
36 lines (30 loc) · 993 Bytes
/
MatrizWorker.java
File metadata and controls
36 lines (30 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class MatrizWorker extends Thread{
private int[][] matriz1;
private int[][] matriz2;
private int[][] resultado;
private int rowOffset;
public MatrizWorker(int[][] m1, int[][] m2, int rowOffset) {
this.matriz1 = m1;
this.matriz2 = m2;
this.rowOffset = rowOffset;
}
public int[][] getResultado() {return this.resultado;}
public int getRowOffset() { return this.rowOffset;}
public void run() {
resultado = multiplicar(matriz1, matriz2);
}
public static int[][] multiplicar(int[][] A, int[][] B) {
int rowsA = A.length;
int colsA = A[0].length;
int colsB = B[0].length;
int[][] result = new int[rowsA][colsB];
for (int i = 0; i < rowsA; i++) {
for (int j = 0; j < colsB; j++) {
for (int k = 0; k < colsA; k++) {
result[i][j] += A[i][k] * B[k][j];
}
}
}
return result;
}
}