Documentation of 'org.nd4j.linalg.util.ArrayUtil' Java class
ArrayUtil
org.nd4j.linalg.util

Class ArrayUtil



  • public class ArrayUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor and Description
      ArrayUtil() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static boolean anyLess(int[] target, int[] test) 
      static boolean anyMore(int[] target, int[] test) 
      static void assertSquare(double[]... d) 
      static int[] calcStrides(int[] shape)
      Computes the standard packed array strides for a given shape.
      static int[] calcStrides(int[] shape, int startValue)
      Computes the standard packed array strides for a given shape.
      static int[] calcStridesFortran(int[] shape)
      Computes the standard packed array strides for a given shape.
      static int[] calcStridesFortran(int[] shape, int startNum)
      Computes the standard packed array strides for a given shape.
      static <E> E[] combine(E[]... arrs) 
      static double[] combine(float[]... ints)
      Combines a applyTransformToDestination of int arrays in to one flat int array
      static int[] combine(int[]... ints)
      Combines a applyTransformToDestination of int arrays in to one flat int array
      static float[] combine(java.util.List<float[]> nums)
      Combines a applyTransformToDestination of int arrays in to one flat int array
      static double[] combineDouble(java.util.List<double[]> nums)
      Combines a applyTransformToDestination of int arrays in to one flat int array
      static float[] combineFloat(java.util.List<float[]> nums)
      Combines a applyTransformToDestination of int arrays in to one flat int array
      static int[] consArray(int a, int[] as) 
      static int[] copy(int[] copy) 
      static int dotProduct(int[] xs, int[] ys) 
      static double[] doubleCopyOf(float[] data) 
      static int[] empty() 
      static boolean equals(float[] data, double[] data2) 
      static double[] flatten(double[][] arr) 
      static int[] flatten(int[][] arr) 
      static float[] floatCopyOf(double[] data) 
      static boolean isZero(int[] as) 
      static int nonOneStride(int[] arr)
      For use with row vectors to ensure consistent strides with varying offsets
      static int[] of(int... arr) 
      static int[] plus(int[] ints, int mult) 
      static int prod(int[] mult) 
      static int[] randomPermutation(int size)
      Credit to mikio braun from jblas Create a random permutation of the numbers 0, ..., size - 1.
      static double[] range(double[] data, int to)
      Returns a subset of an array from 0 to "to"
      static double[] range(double[] data, int to, int stride)
      Returns a subset of an array from 0 to "to" using the specified stride
      static double[] range(double[] data, int to, int stride, int numElementsEachStride)
      Returns a subset of an array from 0 to "to" using the specified stride
      static int[] range(int from, int to)
      Generate an int array ranging from from to to.
      static int[] range(int from, int to, int increment)
      Generate an int array ranging from from to to.
      static double[] read(int length, java.io.DataInputStream dis) 
      static double[] readDouble(int length, java.io.DataInputStream dis) 
      static float[] readFloat(int length, java.io.DataInputStream dis) 
      static int[] removeIndex(int[] data, int index)
      Return a copy of this array with the given index omitted
      static java.lang.Integer[] removeIndex(java.lang.Integer[] data, int index)
      Returns the array with the item in index removed, if the array is empty it will return the array itself
      static int[] replace(int[] data, int index, int newValue)
      Return a copy of this array with the given index omitted
      static <E> void reverse(E[] e) 
      static void reverse(int[] e)
      Reverse the passed in array in place
      static <E> E[] reverseCopy(E[] e) 
      static float[] reverseCopy(float[] e) 
      static int[] reverseCopy(int[] e)
      Create a backwards copy of the given array
      static int[] times(int[] ints, int mult) 
      static int[] times(int[] ints, int[] mult) 
      static int[] toArray(java.util.List<java.lang.Integer> list) 
      static double[] toArrayDouble(java.util.List<java.lang.Double> list) 
      static double[][] toDouble(int[][] arr) 
      static double[] toDoubles(int[] ints) 
      static double[] toDoubles(int[][] ints) 
      static float[] toFloats(int[] ints) 
      static int[] toInts(INDArray n) 
      static INDArray toNDArray(int[] nums) 
      static INDArray toNDArray(int[][] nums) 
      static int[] toOutcomeArray(int outcome, int numOutcomes) 
      static void write(double[] data, java.io.DataOutputStream dos) 
      static void write(float[] data, java.io.DataOutputStream dos) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArrayUtil

        public ArrayUtil()
    • Method Detail

      • randomPermutation

        public static int[] randomPermutation(int size)
        Credit to mikio braun from jblas Create a random permutation of the numbers 0, ..., size - 1. see Algorithm P, D.E. Knuth: The Art of Computer Programming, Vol. 2, p. 145
      • toNDArray

        public static INDArray toNDArray(int[][] nums)
      • toNDArray

        public static INDArray toNDArray(int[] nums)
      • toInts

        public static int[] toInts(INDArray n)
      • prod

        public static int prod(int[] mult)
      • equals

        public static boolean equals(float[] data,
                                     double[] data2)
      • consArray

        public static int[] consArray(int a,
                                      int[] as)
      • isZero

        public static boolean isZero(int[] as)
      • anyMore

        public static boolean anyMore(int[] target,
                                      int[] test)
      • anyLess

        public static boolean anyLess(int[] target,
                                      int[] test)
      • dotProduct

        public static int dotProduct(int[] xs,
                                     int[] ys)
      • empty

        public static int[] empty()
      • of

        public static int[] of(int... arr)
      • copy

        public static int[] copy(int[] copy)
      • doubleCopyOf

        public static double[] doubleCopyOf(float[] data)
      • floatCopyOf

        public static float[] floatCopyOf(double[] data)
      • range

        public static double[] range(double[] data,
                                     int to)
        Returns a subset of an array from 0 to "to"
        Parameters:
        data - the data to getFromOrigin a subset of
        to - the end point of the data
        Returns:
        the subset of the data specified
      • range

        public static double[] range(double[] data,
                                     int to,
                                     int stride)
        Returns a subset of an array from 0 to "to" using the specified stride
        Parameters:
        data - the data to getFromOrigin a subset of
        to - the end point of the data
        stride - the stride to go through the array
        Returns:
        the subset of the data specified
      • range

        public static double[] range(double[] data,
                                     int to,
                                     int stride,
                                     int numElementsEachStride)
        Returns a subset of an array from 0 to "to" using the specified stride
        Parameters:
        data - the data to getFromOrigin a subset of
        to - the end point of the data
        stride - the stride to go through the array
        numElementsEachStride - the number of elements to collect at each stride
        Returns:
        the subset of the data specified
      • toArray

        public static int[] toArray(java.util.List<java.lang.Integer> list)
      • toArrayDouble

        public static double[] toArrayDouble(java.util.List<java.lang.Double> list)
      • range

        public static int[] range(int from,
                                  int to,
                                  int increment)
        Generate an int array ranging from from to to. if from is > to this method will count backwards
        Parameters:
        from - the from
        to - the end point of the data
        increment - the amount to increment by
        Returns:
        the int array with a length equal to absoluteValue(from - to)
      • range

        public static int[] range(int from,
                                  int to)
        Generate an int array ranging from from to to. if from is > to this method will count backwards
        Parameters:
        from - the from
        to - the end point of the data
        Returns:
        the int array with a length equal to absoluteValue(from - to)
      • toDoubles

        public static double[] toDoubles(int[] ints)
      • toDoubles

        public static double[] toDoubles(int[][] ints)
      • toFloats

        public static float[] toFloats(int[] ints)
      • replace

        public static int[] replace(int[] data,
                                    int index,
                                    int newValue)
        Return a copy of this array with the given index omitted
        Parameters:
        data - the data to copy
        index - the index of the item to remove
        newValue - the newValue to replace
        Returns:
        the new array with the omitted item
      • removeIndex

        public static int[] removeIndex(int[] data,
                                        int index)
        Return a copy of this array with the given index omitted
        Parameters:
        data - the data to copy
        index - the index of the item to remove
        Returns:
        the new array with the omitted item
      • removeIndex

        public static java.lang.Integer[] removeIndex(java.lang.Integer[] data,
                                                      int index)
        Returns the array with the item in index removed, if the array is empty it will return the array itself
        Parameters:
        data - the data to remove data from
        index - the index of the item to remove
        Returns:
        a copy of the array with the removed item, or the array itself if empty
      • calcStridesFortran

        public static int[] calcStridesFortran(int[] shape,
                                               int startNum)
        Computes the standard packed array strides for a given shape.
        Parameters:
        shape - the shape of a matrix:
        startNum - the start number for the strides
        Returns:
        the strides for a matrix of n dimensions
      • calcStridesFortran

        public static int[] calcStridesFortran(int[] shape)
        Computes the standard packed array strides for a given shape.
        Parameters:
        shape - the shape of a matrix:
        Returns:
        the strides for a matrix of n dimensions
      • calcStrides

        public static int[] calcStrides(int[] shape,
                                        int startValue)
        Computes the standard packed array strides for a given shape.
        Parameters:
        shape - the shape of a matrix:
        startValue - the startValue for the strides
        Returns:
        the strides for a matrix of n dimensions
      • plus

        public static int[] plus(int[] ints,
                                 int mult)
      • times

        public static int[] times(int[] ints,
                                  int mult)
      • times

        public static int[] times(int[] ints,
                                  int[] mult)
      • nonOneStride

        public static int nonOneStride(int[] arr)
        For use with row vectors to ensure consistent strides with varying offsets
        Parameters:
        arr - the array to getScalar the stride for
        Returns:
        the stride
      • calcStrides

        public static int[] calcStrides(int[] shape)
        Computes the standard packed array strides for a given shape.
        Parameters:
        shape - the shape of a matrix:
        Returns:
        the strides for a matrix of n dimensions
      • reverseCopy

        public static int[] reverseCopy(int[] e)
        Create a backwards copy of the given array
        Parameters:
        e - the array to createComplex a reverse clone of
        Returns:
        the reversed copy
      • read

        public static double[] read(int length,
                                    java.io.DataInputStream dis)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public static void write(double[] data,
                                 java.io.DataOutputStream dos)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readDouble

        public static double[] readDouble(int length,
                                          java.io.DataInputStream dis)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • readFloat

        public static float[] readFloat(int length,
                                        java.io.DataInputStream dis)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public static void write(float[] data,
                                 java.io.DataOutputStream dos)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • assertSquare

        public static void assertSquare(double[]... d)
      • reverse

        public static void reverse(int[] e)
        Reverse the passed in array in place
        Parameters:
        e - the array to reverse
      • reverseCopy

        public static float[] reverseCopy(float[] e)
      • reverseCopy

        public static <E> E[] reverseCopy(E[] e)
      • reverse

        public static <E> void reverse(E[] e)
      • flatten

        public static int[] flatten(int[][] arr)
      • flatten

        public static double[] flatten(double[][] arr)
      • toDouble

        public static double[][] toDouble(int[][] arr)
      • combineFloat

        public static float[] combineFloat(java.util.List<float[]> nums)
        Combines a applyTransformToDestination of int arrays in to one flat int array
        Parameters:
        nums - the int arrays to combineDouble
        Returns:
        one combined int array
      • combine

        public static float[] combine(java.util.List<float[]> nums)
        Combines a applyTransformToDestination of int arrays in to one flat int array
        Parameters:
        nums - the int arrays to combineDouble
        Returns:
        one combined int array
      • combineDouble

        public static double[] combineDouble(java.util.List<double[]> nums)
        Combines a applyTransformToDestination of int arrays in to one flat int array
        Parameters:
        nums - the int arrays to combineDouble
        Returns:
        one combined int array
      • combine

        public static double[] combine(float[]... ints)
        Combines a applyTransformToDestination of int arrays in to one flat int array
        Parameters:
        ints - the int arrays to combineDouble
        Returns:
        one combined int array
      • combine

        public static int[] combine(int[]... ints)
        Combines a applyTransformToDestination of int arrays in to one flat int array
        Parameters:
        ints - the int arrays to combineDouble
        Returns:
        one combined int array
      • combine

        public static <E> E[] combine(E[]... arrs)
      • toOutcomeArray

        public static int[] toOutcomeArray(int outcome,
                                           int numOutcomes)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.