Esempio n. 1
0
  public LongMatrix2D viewStrides(final int _rowStride, final int _columnStride) {
    if (_rowStride <= 0 || _columnStride <= 0)
      throw new IndexOutOfBoundsException("illegal stride");
    WrapperLongMatrix2D view =
        new WrapperLongMatrix2D(this) {
          /** */
          private static final long serialVersionUID = 1L;

          public synchronized long getQuick(int row, int column) {
            return content.getQuick(_rowStride * row, _columnStride * column);
          }

          public synchronized void setQuick(int row, int column, long value) {
            content.setQuick(_rowStride * row, _columnStride * column, value);
          }

          public synchronized long get(int row, int column) {
            return content.get(_rowStride * row, _columnStride * column);
          }

          public synchronized void set(int row, int column, long value) {
            content.set(_rowStride * row, _columnStride * column, value);
          }
        };
    if (rows != 0) view.rows = (rows - 1) / _rowStride + 1;
    if (columns != 0) view.columns = (columns - 1) / _columnStride + 1;
    view.isNoView = false;

    return view;
  }
Esempio n. 2
0
  public LongMatrix2D viewPart(final int row, final int column, int height, int width) {
    checkBox(row, column, height, width);
    WrapperLongMatrix2D view =
        new WrapperLongMatrix2D(this) {
          /** */
          private static final long serialVersionUID = 1L;

          public synchronized long getQuick(int i, int j) {
            return content.getQuick(row + i, column + j);
          }

          public synchronized void setQuick(int i, int j, long value) {
            content.setQuick(row + i, column + j, value);
          }

          public synchronized long get(int i, int j) {
            return content.get(row + i, column + j);
          }

          public synchronized void set(int i, int j, long value) {
            content.set(row + i, column + j, value);
          }
        };
    view.rows = height;
    view.columns = width;
    view.isNoView = false;

    return view;
  }
Esempio n. 3
0
  public LongMatrix2D viewRowFlip() {
    if (rows == 0) return this;
    WrapperLongMatrix2D view =
        new WrapperLongMatrix2D(this) {
          /** */
          private static final long serialVersionUID = 1L;

          public synchronized long getQuick(int row, int column) {
            return content.getQuick(rows - 1 - row, column);
          }

          public synchronized void setQuick(int row, int column, long value) {
            content.setQuick(rows - 1 - row, column, value);
          }

          public synchronized long get(int row, int column) {
            return content.get(rows - 1 - row, column);
          }

          public synchronized void set(int row, int column, long value) {
            content.set(rows - 1 - row, column, value);
          }
        };
    view.isNoView = false;
    return view;
  }
Esempio n. 4
0
  public LongMatrix2D viewDice() {
    WrapperLongMatrix2D view =
        new WrapperLongMatrix2D(this) {
          /** */
          private static final long serialVersionUID = 1L;

          public synchronized long getQuick(int row, int column) {
            return content.getQuick(column, row);
          }

          public synchronized void setQuick(int row, int column, long value) {
            content.setQuick(column, row, value);
          }

          public synchronized long get(int row, int column) {
            return content.get(column, row);
          }

          public synchronized void set(int row, int column, long value) {
            content.set(column, row, value);
          }
        };
    view.rows = columns;
    view.columns = rows;
    view.isNoView = false;

    return view;
  }
Esempio n. 5
0
  public LongMatrix2D viewSelection(int[] rowIndexes, int[] columnIndexes) {
    // check for "all"
    if (rowIndexes == null) {
      rowIndexes = new int[rows];
      for (int i = rows; --i >= 0; ) rowIndexes[i] = i;
    }
    if (columnIndexes == null) {
      columnIndexes = new int[columns];
      for (int i = columns; --i >= 0; ) columnIndexes[i] = i;
    }

    checkRowIndexes(rowIndexes);
    checkColumnIndexes(columnIndexes);
    final int[] rix = rowIndexes;
    final int[] cix = columnIndexes;

    WrapperLongMatrix2D view =
        new WrapperLongMatrix2D(this) {
          /** */
          private static final long serialVersionUID = 1L;

          public synchronized long getQuick(int i, int j) {
            return content.getQuick(rix[i], cix[j]);
          }

          public synchronized void setQuick(int i, int j, long value) {
            content.setQuick(rix[i], cix[j], value);
          }

          public synchronized long get(int i, int j) {
            return content.get(rix[i], cix[j]);
          }

          public synchronized void set(int i, int j, long value) {
            content.set(rix[i], cix[j], value);
          }
        };
    view.rows = rowIndexes.length;
    view.columns = columnIndexes.length;
    view.isNoView = false;

    return view;
  }