コード例 #1
0
  // ----------------------------------------------------------------------------------------
  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
コード例 #2
0
  // ----------------------------------------------------------------------------------------
  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