Class DoubleDenseNdArray

All Implemented Interfaces:
DoubleNdArray, NdArray<Double>, Shaped

public class DoubleDenseNdArray extends AbstractDenseNdArray<Double, DoubleNdArray> implements DoubleNdArray
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public static DoubleNdArray create(DoubleDataBuffer buffer, Shape shape)
    • getDouble

      public double getDouble(long... indices)
      Description copied from interface: DoubleNdArray
      Returns the double value of the scalar found at the given coordinates.

      To access the scalar element, the number of coordinates provided must be equal to the number of dimensions of this array (i.e. its rank). For example:

       DoubleNdArray matrix = NdArrays.ofDoubles(shape(2, 2));  // matrix rank = 2
       matrix.getDouble(0, 1);  // succeeds, returns 0.0
       matrix.getDouble(0);  // throws IllegalRankException
      
       DoubleNdArray scalar = matrix.get(0, 1);  // scalar rank = 0
       scalar.getDouble();  // succeeds, returns 0.0
      
      Specified by:
      getDouble in interface DoubleNdArray
      Parameters:
      indices - coordinates of the scalar to resolve
      Returns:
      value of that scalar
    • setDouble

      public DoubleNdArray setDouble(double value, long... indices)
      Description copied from interface: DoubleNdArray
      Assigns the double value of the scalar found at the given coordinates.

      To access the scalar element, the number of coordinates provided must be equal to the number of dimensions of this array (i.e. its rank). For example:

       DoubleNdArray matrix = NdArrays.ofDoubles(shape(2, 2));  // matrix rank = 2
       matrix.setDouble(10.0, 0, 1);  // succeeds
       matrix.setDouble(10.0, 0);  // throws IllegalRankException
      
       DoubleNdArray scalar = matrix.get(0, 1);  // scalar rank = 0
       scalar.setDouble(10.0);  // succeeds
      
      Specified by:
      setDouble in interface DoubleNdArray
      Parameters:
      value - value to assign
      indices - coordinates of the scalar to assign
      Returns:
      this array
    • copyTo

      public DoubleNdArray copyTo(NdArray<Double> dst)
      Description copied from interface: NdArray
      Copy the content of this array to the destination array.

      The Shaped.shape() of the destination array must be equal to the shape of this array, or an exception is thrown. After the copy, the content of both arrays can be altered independently, without affecting each other.

      Specified by:
      copyTo in interface DoubleNdArray
      Specified by:
      copyTo in interface NdArray<Double>
      Parameters:
      dst - array to receive a copy of the content of this array
      Returns:
      this array
    • copyTo

      public DoubleNdArray copyTo(DoubleDataBuffer dst)
      Specified by:
      copyTo in interface DoubleNdArray
    • copyFrom

      public DoubleNdArray copyFrom(DoubleDataBuffer src)
      Specified by:
      copyFrom in interface DoubleNdArray
    • buffer

      protected DoubleDataBuffer buffer()
      Specified by:
      buffer in class AbstractDenseNdArray<Double, DoubleNdArray>
    • dimensions

      public DimensionalSpace dimensions()
    • shape

      public Shape shape()
      Specified by:
      shape in interface Shaped
      Returns:
      the shape of this container
    • scalars

      public NdArraySequence<DoubleNdArray> scalars()
      Description copied from interface: NdArray
      Returns a sequence of all scalars in this array.

      This is equivalent to call elements(shape().numDimensions() - 1)

      Specified by:
      scalars in interface NdArray<T>
      Returns:
      an NdArray sequence
    • slowHashCode

      protected int slowHashCode()
    • slowEquals

      protected boolean slowEquals(NdArray<?> array)