Compare commits
No commits in common. "281b42b0fb288643b1f646313659b3b98b0250b0" and "ffcf9fa975a02e53b19e838d00566750e2026134" have entirely different histories.
281b42b0fb
...
ffcf9fa975
2 changed files with 0 additions and 32 deletions
|
@ -11,7 +11,6 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.ejml:ejml-all:0.41'
|
implementation 'org.ejml:ejml-all:0.41'
|
||||||
implementation 'org.knowm.xchart:xchart:3.8.1'
|
|
||||||
implementation 'com.opencsv:opencsv:5.6'
|
implementation 'com.opencsv:opencsv:5.6'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
|
||||||
|
|
|
@ -7,45 +7,14 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class Utilities {
|
public class Utilities {
|
||||||
private static final double STANDARD_GAUSSIAN_FACTOR = 1.0d;
|
|
||||||
|
|
||||||
public static SimpleMatrix ones(int rows, int columns) {
|
public static SimpleMatrix ones(int rows, int columns) {
|
||||||
SimpleMatrix mat = new SimpleMatrix(rows, columns);
|
SimpleMatrix mat = new SimpleMatrix(rows, columns);
|
||||||
Arrays.fill(mat.getDDRM().data, 1);
|
Arrays.fill(mat.getDDRM().data, 1);
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleMatrix gaussianMatrix(int rows, int columns, double mean, double stddev, double factor) {
|
|
||||||
SimpleMatrix mat = new SimpleMatrix(rows, columns);
|
|
||||||
Random random = new Random();
|
|
||||||
|
|
||||||
for (int i = 0; i < mat.getNumElements(); i++) {
|
|
||||||
mat.set(i, factor * random.nextGaussian(mean, stddev));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SimpleMatrix gaussianMatrix(int rows, int columns, double mean, double stddev) {
|
|
||||||
return gaussianMatrix(rows, columns, mean, stddev, STANDARD_GAUSSIAN_FACTOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double[] linspace(double start, double end, int num) {
|
|
||||||
double[] result = new double[num];
|
|
||||||
double stepSize = Math.abs(end - start) / num;
|
|
||||||
double nextEntry = start;
|
|
||||||
|
|
||||||
for (int i = 0; i < num; i++) {
|
|
||||||
result[i] = nextEntry;
|
|
||||||
nextEntry += stepSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<List<String>> readCSV(String filename) {
|
public static List<List<String>> readCSV(String filename) {
|
||||||
List<List<String>> entries = new ArrayList<>();
|
List<List<String>> entries = new ArrayList<>();
|
||||||
try (CSVReader csvReader = new CSVReader(new FileReader(filename))) {
|
try (CSVReader csvReader = new CSVReader(new FileReader(filename))) {
|
||||||
|
|
Loading…
Reference in a new issue