Class AbstractMDArray

java.lang.Object
com.linkedin.dagli.math.mdarray.AbstractMDArray
All Implemented Interfaces:
MDArray, java.io.Serializable, java.lang.AutoCloseable
Direct Known Subclasses:
VectorAsMDArray

public abstract class AbstractMDArray
extends java.lang.Object
implements MDArray
Base class for MDArrays. It is recommended that all MDArray implementations extend this class.
See Also:
Serialized Form
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected long[] _shape  
  • Constructor Summary

    Constructors
    Constructor Description
    AbstractMDArray​(long[] shape)
    Creates a new instance with the specified shape.
  • Method Summary

    Modifier and Type Method Description
    long[] shape()
    Gets the shape (dimensions) of this MDArray, expressed as a long[].
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.linkedin.dagli.math.mdarray.MDArray

    asVector, close, getAsDouble, getAsDouble, getAsDoubleUnsafe, getAsLong, getAsLong, getAsLongUnsafe, subarrayAt, valueType
  • Field Details

    • _shape

      protected final long[] _shape
  • Constructor Details

    • AbstractMDArray

      public AbstractMDArray​(long[] shape)
      Creates a new instance with the specified shape. Note that the instance keeps a reference to the provided shape array, which should not be modified subsequently.
      Parameters:
      shape - the shape of this instance
  • Method Details

    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • shape

      public final long[] shape()
      Description copied from interface: MDArray
      Gets the shape (dimensions) of this MDArray, expressed as a long[]. The shape is fixed for any particular MDArray instance (i.e. calls to this method will always return the same value). As a special case, a "scalar" MDArray has 0 dimensions and thus this method will return a 0-length array. The caller must not modify the returned array.
      Specified by:
      shape in interface MDArray
      Returns:
      a (read-only) long[] representing the dimensions of the MDArray