// ---------------------------------------------------------------------------------------- public void createAndBroadcastMatrix( String[] rowNames, String[] columnNames, double[] data, String matrixName) { // System.out.println (" ------- RShellGoose.cabm"); // System.out.println (" row name count: " + rowNames.length); // System.out.println (" col name count: " + columnNames.length); // System.out.println (" data length: " + data.length); // System.out.println (" name: " + matrixName); DataMatrix matrix = new DataMatrix(); int rowCount = rowNames.length; int columnCount = columnNames.length; matrix.setSize(rowCount, columnCount); if (matrixName != null) { matrix.setShortName(matrixName); // matrix.setName(matrixName); } matrix.setRowTitles(rowNames); matrix.setColumnTitles(columnNames); for (int r = 0; r < rowCount; r++) { double[] rowValues = new double[columnCount]; int fromPosition = r * columnCount; System.arraycopy(data, fromPosition, rowValues, 0, columnCount); matrix.set(r, rowValues); } // for r broadcastMatrix(matrix); } // createAndBroadcastMatrix
// ---------------------------------------------------------------------------------------- public void handleMatrix(String source, DataMatrix matrix) { this.matrix = matrix; System.out.println( "matrix ready, dimension " + this.matrix.getRowCount() + " x " + this.matrix.getColumnCount()); defaultSpecies = matrix.getSpecies(); }
// ---------------------------------------------------------------------------------------- public double[] getAllMatrixData() { if (matrix == null) { System.out.println("The R goose has not received a matrix broadcast."); return new double[0]; } int rowCount = matrix.getRowCount(); int columnCount = matrix.getColumnCount(); int total = rowCount * columnCount; double result[] = new double[total]; for (int r = 0; r < rowCount; r++) { double[] rowValues = matrix.get(r); int toPosition = r * columnCount; System.arraycopy(rowValues, 0, result, toPosition, columnCount); } // for r return result; } // getAllMatrixData
// ---------------------------------------------------------------------------------------- void broadcastMatrix(DataMatrix matrix) { try { matrix.setSpecies(defaultSpecies); // matrix.setName(); gaggleBoss.broadcastMatrix(myGaggleName, targetGoose, matrix); } catch (RemoteException rex) { System.err.println( "error rmi selecting at boss, from RShellGoose.broadcastMatrix() " + myGaggleName); } } // broadcastMatrix
// ---------------------------------------------------------------------------------------- public double[] getMatrixRow(int rowNumber) { if (matrix == null) return new double[0]; else return matrix.get(rowNumber); }
// ---------------------------------------------------------------------------------------- public String[] getMatrixColumnNames() { if (matrix == null) return new String[0]; else return matrix.getColumnTitles(); }
// ---------------------------------------------------------------------------------------- public String[] getMatrixRowNames() { if (matrix == null) return new String[0]; else return matrix.getRowTitles(); }
// ---------------------------------------------------------------------------------------- public int getMatrixColumnCount() { if (matrix == null) return 0; else return matrix.getColumnCount(); }
// ---------------------------------------------------------------------------------------- public int getMatrixRowCount() { if (matrix == null) return 0; else return matrix.getRowCount(); }