Class SelectedDenseDoubleMatrix1D

All Implemented Interfaces:
Serializable, Cloneable

class SelectedDenseDoubleMatrix1D extends DoubleMatrix1D
Selection view on dense 1-d matrices holding double elements. First see the package summary and javadoc tree view to get the broad picture.

Implementation:

Objects of this class are typically constructed via viewIndexes methods on some source matrix. The interface introduced in abstract super classes defines everything a user can do. From a user point of view there is nothing special about this class; it presents the same functionality with the same signatures and semantics as its abstract superclass(es) while introducing no additional functionality. Thus, this class need not be visible to users. By the way, the same principle applies to concrete DenseXXX, SparseXXX classes: they presents the same functionality with the same signatures and semantics as abstract superclass(es) while introducing no additional functionality. Thus, they need not be visible to users, either. Factory methods could hide all these concrete types.

This class uses no delegation. Its instances point directly to the data. Cell addressing overhead is 1 additional array index access per get/set.

Note that this implementation is not synchronized.

Memory requirements:

memory [bytes] = 4*indexes.length. Thus, an index view with 1000 indexes additionally uses 4 KB.

Time complexity:

Depends on the parent view holding cells.

Version:
1.0, 09/24/99
  • Field Details

    • elements

      protected double[] elements
      The elements of this matrix.
    • offsets

      protected int[] offsets
      The offsets of visible indexes of this matrix.
    • offset

      protected int offset
      The offset.
  • Constructor Details

    • SelectedDenseDoubleMatrix1D

      protected SelectedDenseDoubleMatrix1D(double[] elements, int[] offsets)
      Constructs a matrix view with the given parameters.
      Parameters:
      elements - the cells.
      indexes - The indexes of the cells that shall be visible.
    • SelectedDenseDoubleMatrix1D

      protected SelectedDenseDoubleMatrix1D(int size, double[] elements, int zero, int stride, int[] offsets, int offset)
      Constructs a matrix view with the given parameters.
      Parameters:
      size - the number of cells the matrix shall have.
      elements - the cells.
      zero - the index of the first element.
      stride - the number of indexes between any two elements, i.e. index(i+1)-index(i).
      offsets - the offsets of the cells that shall be visible.
      offset -
  • Method Details

    • _offset

      protected int _offset(int absRank)
      Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. Default implementation. Override, if necessary.
      Overrides:
      _offset in class AbstractMatrix1D
      Parameters:
      rank - the absolute rank of the element.
      Returns:
      the position.
    • getQuick

      public double getQuick(int index)
      Returns the matrix cell value at coordinate index.

      Provided with invalid parameters this method may return invalid objects without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): index<0 || index>=size().

      Specified by:
      getQuick in class DoubleMatrix1D
      Parameters:
      index - the index of the cell.
      Returns:
      the value of the specified cell.
    • haveSharedCellsRaw

      protected boolean haveSharedCellsRaw(DoubleMatrix1D other)
      Returns true if both matrices share at least one identical cell.
      Overrides:
      haveSharedCellsRaw in class DoubleMatrix1D
    • index

      protected int index(int rank)
      Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array. You may want to override this method for performance.
      Overrides:
      index in class AbstractMatrix1D
      Parameters:
      rank - the rank of the element.
    • like

      public DoubleMatrix1D like(int size)
      Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size. For example, if the receiver is an instance of type DenseDoubleMatrix1D the new matrix must also be of type DenseDoubleMatrix1D, if the receiver is an instance of type SparseDoubleMatrix1D the new matrix must also be of type SparseDoubleMatrix1D, etc. In general, the new matrix should have internal parametrization as similar as possible.
      Specified by:
      like in class DoubleMatrix1D
      Parameters:
      size - the number of cell the matrix shall have.
      Returns:
      a new empty matrix of the same dynamic type.
    • like2D

      public DoubleMatrix2D like2D(int rows, int columns)
      Construct and returns a new 2-d matrix of the corresponding dynamic type, entirelly independent of the receiver. For example, if the receiver is an instance of type DenseDoubleMatrix1D the new matrix must be of type DenseDoubleMatrix2D, if the receiver is an instance of type SparseDoubleMatrix1D the new matrix must be of type SparseDoubleMatrix2D, etc.
      Specified by:
      like2D in class DoubleMatrix1D
      Parameters:
      rows - the number of rows the matrix shall have.
      columns - the number of columns the matrix shall have.
      Returns:
      a new matrix of the corresponding dynamic type.
    • setQuick

      public void setQuick(int index, double value)
      Sets the matrix cell at coordinate index to the specified value.

      Provided with invalid parameters this method may access illegal indexes without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): index<0 || index>=size().

      Specified by:
      setQuick in class DoubleMatrix1D
      Parameters:
      index - the index of the cell.
      value - the value to be filled into the specified cell.
    • setUp

      protected void setUp(int size)
      Sets up a matrix with a given number of cells.
      Overrides:
      setUp in class AbstractMatrix1D
      Parameters:
      size - the number of cells the matrix shall have.
    • viewSelectionLike

      protected DoubleMatrix1D viewSelectionLike(int[] offsets)
      Construct and returns a new selection view.
      Specified by:
      viewSelectionLike in class DoubleMatrix1D
      Parameters:
      offsets - the offsets of the visible elements.
      Returns:
      a new view.