DirectNDArray
Date: 2017-11-20

jep

## Class DirectNDArray<T extends java.nio.Buffer>

- java.lang.Object
- - jep.DirectNDArray<T>

-     public class DirectNDArray<T extends java.nio.Buffer>
      extends java.lang.Object

  Represents a numpy.ndarray in Java. If Jep was compiled with numpy support, this object will not be wrapped as a PyJobject in the Python sub-interpreter(s), it will instead be wrapped as a numpy.ndarray automatically. The numpy.ndarray will reference the exact same memory as the buffer so changes in either language will be immediately visible in both.

  DirectNDArrays only support direct buffers as the underlying type of data. The data can conceptually be multi-dimensional, but it must be represented as a one-dimensional direct buffer in Java to ensure the memory is contiguous.

  Since:
    3.7

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected T` | `data`
    `protected int[]` | `dimensions`
    `protected boolean` | `unsigned`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DirectNDArray(T data)` Constructor for a Java DirectNDArray.
    `DirectNDArray(T data, boolean unsigned)` Constructor for a Java DirectNDArray.
    `DirectNDArray(T data, boolean unsigned, int... dimensions)` Constructor for a Java DirectNDArray.
    `DirectNDArray(T data, int... dimensions)` Constructor for a Java DirectNDArray.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)`
    `T` | `getData()`
    `int[]` | `getDimensions()`
    `int` | `getLength(T data)` Get the total length of the data object.
    `int` | `hashCode()`
    `boolean` | `isUnsigned()`
    `protected void` | `validate(T data)` Validate that this data is usable as an NDArray.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### data

          protected final T data

    - #### dimensions

          protected final int[] dimensions

    - #### unsigned

          protected final boolean unsigned

  - ### Constructor Detail

    - #### DirectNDArray

          public DirectNDArray(T data)

      Constructor for a Java DirectNDArray. Presumes the data is one dimensional.
      Parameters:
        `data` - a direct Buffer

    - #### DirectNDArray

          public DirectNDArray(T data,
                               boolean unsigned)

      Constructor for a Java DirectNDArray. Presumes the data is one dimensional.
      Parameters:
        `data` - a direct Buffer
        `unsigned` - whether the data is to be interpreted as unsigned

    - #### DirectNDArray

          public DirectNDArray(T data,
                               int... dimensions)

      Constructor for a Java DirectNDArray.
      Parameters:
        `data` - a direct Buffer
        `dimensions` - the conceptual dimensions of the data (corresponds to the numpy.ndarray dimensions in C-contiguous order)

    - #### DirectNDArray

          public DirectNDArray(T data,
                               boolean unsigned,
                               int... dimensions)

      Constructor for a Java DirectNDArray.
      Parameters:
        `data` - a direct Buffer
        `unsigned` - whether the data is to be interpreted as unsigned
        `dimensions` - the conceptual dimensions of the data (corresponds to the numpy.ndarray dimensions in C-contiguous order)

  - ### Method Detail

    - #### validate

          protected void validate(T data)

      Validate that this data is usable as an NDArray. This will be called from the constuctor and should throw an IllegalArgumentException if the data object is not valid.
      Parameters:
        `data` - a data object

    - #### getLength

          public int getLength(T data)

      Get the total length of the data object.
      Parameters:
        `data` - a data object

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### getDimensions

          public int[] getDimensions()

    - #### isUnsigned

          public boolean isUnsigned()

    - #### getData

          public T getData()