From a12eec50def8020994016013225a17f8a654b54b Mon Sep 17 00:00:00 2001 From: clementineyan Date: Wed, 24 Jul 2024 15:54:14 +1200 Subject: [PATCH] getColumnAsMatrix for Table #508 --- .../main/java/lphy/core/model/datatype/Table.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lphy/src/main/java/lphy/core/model/datatype/Table.java b/lphy/src/main/java/lphy/core/model/datatype/Table.java index 3a694b7d..960bde01 100644 --- a/lphy/src/main/java/lphy/core/model/datatype/Table.java +++ b/lphy/src/main/java/lphy/core/model/datatype/Table.java @@ -37,6 +37,19 @@ public String[] getColumnNames() { return keySet().toArray(new String[0]); } + @MethodInfo(description = "return the 2d matrix of phi and psi angles.") + public Double[][] getColumnAsMatrix(Integer... ArrayIndex) { + Double[][] anglesMatrix = new Double[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()); + } + } + return anglesMatrix; + } + //TODO set column type ?