-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindAndModify.java
More file actions
39 lines (35 loc) · 1.39 KB
/
Copy pathFindAndModify.java
File metadata and controls
39 lines (35 loc) · 1.39 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
32
33
34
35
36
37
38
39
package cn.edu.ustc.aaron.encoder;
import java.util.*;
import Jama.*;
public class FindAndModify {
public static double showSign (double value) {
if (value == 0.0) {
return 0.0;
}
else {
return (value / Math.abs(value));
}
}
public static void findModifyLessThan (Matrix modifyTarget, Matrix findTarget, double beta) {
double [][] findTar = findTarget.getArray();
double [][] modifyTar = modifyTarget.getArray();
for (int row = 0; row < findTarget.getRowDimension(); row++) {
for (int col = 0; col < findTarget.getColumnDimension(); col++) {
if (Math.abs(findTar[row][col]) < 1.0 / beta) {
modifyTar[row][col] = 0.0;
}
}
}
}
public static void findModifyMoreThan (Matrix modifyTarget, Matrix findTarget, double beta) {
double [][] findTar = findTarget.getArray();
double [][] modifyTar = modifyTarget.getArray();
for (int row = 0; row < findTarget.getRowDimension(); row++) {
for (int col = 0; col < findTarget.getColumnDimension(); col++) {
if (Math.abs(findTar[row][col]) > 1.0 / beta) {
modifyTar[row][col] = findTar[row][col] - 1.0 / beta * showSign(findTar[row][col]);
}
}
}
}
}