-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindFactor.java
More file actions
31 lines (27 loc) · 1.12 KB
/
Copy pathFindFactor.java
File metadata and controls
31 lines (27 loc) · 1.12 KB
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
package operations;
public class FindFactor extends AbstractOperation {
/*
Operation A[i][k] represents finding factor that will be needed while subtracting row i from row k.
factor = M[i][i]/M[k][i]
*/
private final int targetRow;
public FindFactor(double[][] matrix, Double[][] eliminationFactors, Double[] normalizationFactors, int sourceRow, int targetRow){
super(matrix, eliminationFactors, normalizationFactors);
this.sourceRow = sourceRow;
this.targetRow = targetRow;
this.operationSymbol = 'A';
}
@Override
public Void call() {
//if target element is 0, then there is no need for multiplying, null is also a reason to use Double instead of double
if (Math.abs(matrix[targetRow][sourceRow]) < 1e-32)
eliminationFactors[sourceRow][targetRow] = null;
else
eliminationFactors[sourceRow][targetRow] = matrix[sourceRow][sourceRow]/matrix[targetRow][sourceRow];
return null;
}
@Override
public String toString(){
return "%c(%d, %d)".formatted(operationSymbol, sourceRow, targetRow);
}
}