I'm trying to make a matrix arithmetic operation method using multidimensional arrays ([verybigrow][2]). I'm new at this, and I just can't find what I'm doing wrong. I'd really appreciate any help in telling me what it is.
try {
Stream<String> Matrix = Files.lines(Paths.get(file)).parallel();
String[][] DataSet = Matrix.map(mapping -> mapping.split(",")).toArray(String[][]::new);
Double[][] distanceTable = new Double[DataSet.length - 1][];
/* START WANT TO REPLACE THIS MATRIX CALCULATION WITH PARALLEL STREAM RATHER THAN USE TRADITIONAL ARRAY ARITHMETICS START */
for (int i = 0; i < distanceTable.length - 1; ++i) {
distanceTable[i] = new Double[i + 1];
for (int j = 0; j <= i; ++j) {
double distance = 0.0;
for (int k = 0; k < DataSet[i + 1].length; ++k) {
double difference = Double.parseDouble(DataSet[j][k]) - Double.parseDouble(DataSet[i + 1][k]);
distance += difference * difference;
}
distanceTable[i][j] = distance;
}
}
/* END WANT TO REPLACE THIS MATRIX CALCULATION WITH PARALLEL STREAM RATHER THAN USE TRADITIONAL ARRAY ARITHMETICS START */
} catch ( Exception except ){
System.out.println ( except );
}
I had rather not use libraries or anything like that, I'm mostly doing this to learn how it works. Thank you so much in advance. if you asking the data looks like :
4,53
5,63
10,59
9,77
13,49
The Output of data processing should look like this :
[101] <- ((4-5)^2) + ((53-63)^2)
[72, 41] <- ( ((4-10)^2) + ((53-59)^2) ), ( ((5,10)^2) + ((63-59)^2))
[601.0, 212.0, 325.0]
[97.0, 260.0, 109.0, 800.0]
[337.0, 100.0, 109.0, 80.0, 400.0]