-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputGenerator.java
More file actions
72 lines (55 loc) · 1.37 KB
/
Copy pathInputGenerator.java
File metadata and controls
72 lines (55 loc) · 1.37 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
public class InputGenerator {
double currentSeed;
public InputGenerator(double seed) {
currentSeed = seed;
// per evitare numeri < 0
getRandomNumber();
}
public double getRandomNumber(){
int a = 16087;
int m = 2147483647;
int q = 127773;
int r = 2836;
double hi = Math.ceil(currentSeed / q);
double lo = currentSeed - q * hi;
double test = a * lo - r * hi;
if (test < 0.0) {
currentSeed = test + m;
} else {
currentSeed = test;
}
return currentSeed / m;
}
/**
* Metodo che ritorna una stringa valida come input.
*/
public String getNewStringArray() {
double[] array = new double[4000000];
String output = "";
for (int i = 0; i < array.length; i++) {
array[i] = this.getRandomNumber();
if (i == 0) {
output = array[i] + "";
} else {
output = output + ", " + array[i];
}
}
return output + ".";
}
/**
* Genera un array di Double
*/
public double[] getNewArray(int dim) {
double[] array = new double[dim];
for (int i = 0; i < array.length; i++) {
array[i] = this.getRandomNumber();
}
return array;
}
public static void main(String[] args) {
// stampa in std output una stringa valida come input per l'algoritmo calcInferiorMedian().
InputGenerator inputGen = new InputGenerator(System.currentTimeMillis());
String output = inputGen.getNewStringArray();
System.out.println(output);
}
}