示例#1
0
  /** {@inheritDoc} */
  @Override
  public void setSubMatrix(final double[][] subMatrix, final int row, final int column)
      throws NoDataException, OutOfRangeException, DimensionMismatchException,
          NullArgumentException {
    if (data == null) {
      if (row > 0) {
        throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
      }
      if (column > 0) {
        throw new MathIllegalStateException(
            LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
      }
      MathUtils.checkNotNull(subMatrix);
      final int nRows = subMatrix.length;
      if (nRows == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
      }

      final int nCols = subMatrix[0].length;
      if (nCols == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
      }
      data = new double[subMatrix.length][nCols];
      for (int i = 0; i < data.length; ++i) {
        if (subMatrix[i].length != nCols) {
          throw new DimensionMismatchException(subMatrix[i].length, nCols);
        }
        System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
      }
    } else {
      super.setSubMatrix(subMatrix, row, column);
    }
  }