Skip to content

Commit

Permalink
fix the reversed columns and rows #508
Browse files Browse the repository at this point in the history
  • Loading branch information
clem-xry committed Aug 8, 2024
1 parent 6290490 commit 6f74889
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lphy/src/main/java/lphy/core/model/datatype/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ public String[] getColumnNames() {
return keySet().toArray(new String[0]);
}

@MethodInfo(description = "return the 2d matrix of phi and psi angles.")
@MethodInfo(description = "return the array of (array) records for selected column indices.")
public Double[][] getColumnAsMatrix(Integer... ArrayIndex) {
Double[][] anglesMatrix = new Double[ArrayIndex.length][];

List[] columns = new List[ArrayIndex.length];
for (int i = 0; i < ArrayIndex.length; i++) {
columns[i] = getColumn(ArrayIndex[i]);
}

Double[][] anglesMatrix = new Double[columns[0].size()][ArrayIndex.length];

for (int i = 0; i < anglesMatrix.length; i++) {
List column = getColumn(ArrayIndex[i]); //get column 1 and column 2
anglesMatrix[i] = new Double[column.size()];
for (int j = 0; j < column.size(); j++) {
anglesMatrix[i][j] = Double.parseDouble(column.get(j).toString());
for (int j = 0; j < anglesMatrix[i].length; j++) {
anglesMatrix[i][j] = Double.parseDouble(columns[j].get(i).toString());
}
}
return anglesMatrix;
Expand Down

0 comments on commit 6f74889

Please sign in to comment.