Class NDArrayMath


  • public class NDArrayMath
    extends Object
    Author:
    Adam Gibson
    • Method Detail

      • offsetForSlice

        public static long offsetForSlice​(INDArray arr,
                                          int slice)
        Compute the offset for a given slice
        Parameters:
        arr - the array to compute the offset frm
        slice - the slice to compute the offset for
        Returns:
        the offset for a given slice
      • lengthPerSlice

        public static long lengthPerSlice​(INDArray arr,
                                          int... dimension)
        The number of elements in a slice along a set of dimensions
        Parameters:
        arr - the array to calculate the length per slice for
        dimension - the dimensions to do the calculations along
        Returns:
        the number of elements in a slice along arbitrary dimensions
      • lengthPerSlice

        public static long lengthPerSlice​(INDArray arr)
        Return the length of a slice
        Parameters:
        arr - the array to get the length of a slice for
        Returns:
        the number of elements per slice in an array
      • numVectors

        public static long numVectors​(INDArray arr)
        Return the number of vectors for an array the number of vectors for an array
        Parameters:
        arr - the array to calculate the number of vectors for
        Returns:
        the number of vectors for the given array
      • vectorsPerSlice

        public static long vectorsPerSlice​(INDArray arr)
        The number of vectors in each slice of an ndarray.
        Parameters:
        arr - the array to get the number of vectors per slice for
        Returns:
        the number of vectors per slice
      • tensorsPerSlice

        public static long tensorsPerSlice​(INDArray arr,
                                           int[] tensorShape)
        Computes the tensors per slice given a tensor shape and array
        Parameters:
        arr - the array to get the tensors per slice for
        tensorShape - the desired tensor shape
        Returns:
        the tensors per slice of an ndarray
      • matricesPerSlice

        public static long matricesPerSlice​(INDArray arr)
        The number of vectors in each slice of an ndarray.
        Parameters:
        arr - the array to get the number of vectors per slice for
        Returns:
        the number of vectors per slice
      • vectorsPerSlice

        public static long vectorsPerSlice​(INDArray arr,
                                           int... rank)
        The number of vectors in each slice of an ndarray.
        Parameters:
        arr - the array to get the number of vectors per slice for
        rank - the dimensions to get the number of vectors per slice for
        Returns:
        the number of vectors per slice
      • sliceOffsetForTensor

        public static long sliceOffsetForTensor​(int index,
                                                INDArray arr,
                                                int[] tensorShape)
        calculates the offset for a tensor
        Parameters:
        index -
        arr -
        tensorShape -
        Returns:
      • sliceOffsetForTensor

        public static long sliceOffsetForTensor​(int index,
                                                INDArray arr,
                                                long[] tensorShape)
      • mapIndexOntoTensor

        public static int mapIndexOntoTensor​(int index,
                                             INDArray arr,
                                             int... rank)
        This maps an index of a vector on to a vector in the matrix that can be used for indexing in to a tensor
        Parameters:
        index - the index to map
        arr - the array to use for indexing
        rank - the dimensions to compute a slice for
        Returns:
        the mapped index
      • mapIndexOntoVector

        public static long mapIndexOntoVector​(int index,
                                              INDArray arr)
        This maps an index of a vector on to a vector in the matrix that can be used for indexing in to a tensor
        Parameters:
        index - the index to map
        arr - the array to use for indexing
        Returns:
        the mapped index