This method returns AllocationShape for specific array, that takes in account its real shape: offset, length, etc

@param array
@return
434626
public static AllocationShape buildAllocationShape(INDArray array) {
        AllocationShape shape = new AllocationShape();
        shape.setDataType(array.data().dataType());
        shape.setLength(array.length());
        shape.setDataType(array.data().dataType());

        return shape;
    }
453123
static double[] sortAndRevert(final double[] array) {
		final int[] indexes = sort(array);

		// Copy the elements in reversed order.
		final double[] result = new double[array.length];
		for (int i = 0; i < result.length; ++i) {
			result[indexes[result.length - 1 - i]] = array[indexes[i]];
		}

		return result;
	}
819565
@Nullable
  public static int[] getIntArray(@Nullable final JsonArray array) {
    if (null == array) return null;
    return IntStream.range(0, array.size()).map(i -> array.get(i).getAsInt()).toArray();
  }
1053198
public static Slice wrappedIntArray(int[] array, int offset, int length)
    {
        if (length == 0) {
            return EMPTY_SLICE;
        }
        return new Slice(array, offset, length);
    }
129190
public static byte[] cat(byte[]... arrays) {
        int size = 0;
        for(byte[] a: arrays)
            if(a != null)
                size += a.length;
        byte[] cated = new byte[size];
        int pos = 0;
        for(byte[] a: arrays) {
            if(a != null) {
                System.arraycopy(a, 0, cated, pos, a.length);
                pos += a.length;
            }
        }

        return cated;
    }
49477
public static IntStreamEx of(Integer[] array) {
        return seq(Arrays.stream(array).mapToInt(Integer::intValue));
    }
1215029
public static <T> List<T> arrayToList(T[] array) {
        List<T> list = null;
        if (array != null) {
            list = new ArrayList<>();
            for (T e : array) {
                list.add(e);
            }
        }
        return list;
    }
160584
public static Object flatten(Object array) {
        Preconditions.checkArgument(array.getClass().isArray(), "array");

        Class<?> type = getType(array);
        int[] dimensions = getDimensions(array);
        int length = length(dimensions);

        Object flattened = Array.newInstance(type, length);

        flatten(array, flattened, dimensions, 0);

        return flattened;
    }
599196
private int getTableAccessOffset(int[] assignment) {
        assert(assignment.length == dimensions.length);
        int offset = 0;
        for (int i = 0; i < assignment.length; i++) {
            assert(assignment[i] < dimensions[i]);
            offset = (offset*dimensions[i]) + assignment[i];
        }
        return offset;
    }
458474
public static <T> Set<T> arrayToSet(T [] array) {
        return new HashSet<T>(Arrays.asList(array));
    }
1045701
public static long sum(long[] array) {
		if (array == null) {
			return 0L;
		}
		long sum = 0;
		for (int i = 0; i < array.length; i++) {
			sum += array[i];
		}
		return sum;
	}
1325059
function( array ){
	var i = array.length, j, swap;
	while( i ){
		j = Math.floor( Math.random() * i-- );
		swap = array[i];
		array[i] = array[j];
		array[j] = swap;
	}
	return array;
}
144327
public static function getRectangularDimensions(array $array)
    {
        $return = -1;
        $allArrays = array_map('is_array', $array);
        // all elements are arrays, iterate through them and call the static function recursively
        if (self::allElementsEqual($allArrays, true)) {
            $elementsPerArray = array();
            foreach ($array as $row) {
                $noElements = self::getRectangularDimensions($row);
                if ($noElements == -1) {
                    return $noElements;
                }
                $elementsPerArray[] = $noElements;
            }
            if (!self::allElementsEqual($elementsPerArray)) {
                return -1;
            } else {
                $return   = reset($elementsPerArray);
                $return[] = count($elementsPerArray);
            }
        } // none of the elements are arrays, return number of elements of the "bottom" array
        elseif (self::allElementsEqual($allArrays, false)) {
            $return = array(0 => count($array));
        }

        return $return;
    }
621118
public static byte[] combine(final Collection<byte[]> arrays) {
        int length = 0;
        for (final byte[] array : arrays) {
            length += array.length;
        }
        final byte[] joinedArray = new byte[length];
        
        int position = 0;
        for (final byte[] array : arrays) {
            System.arraycopy(array, 0, joinedArray, position, array.length);
            position += array.length;
        }
        return joinedArray;
    }
984202
public static Array array(Object array) {
        if (array instanceof Object[]) {
            return array((Object[]) array);
        }
        switch (tId(array.getClass())) {
            case I_BOOLEAN:     return array((boolean[]) array);
            case I_BYTE:        return array((byte[]) array);
            case I_CHARACTER:   return array((char[]) array);
            case I_DOUBLE:      return array((double[]) array);
            case I_FLOAT:       return array((float[]) array);
            case I_INTEGER:     return array((int[]) array);
            case I_LONG:        return array((long[]) array);
            case I_SHORT:       return array((short[]) array);
        }
        throw new IllegalArgumentException("No array: " + array);
    }
1170503
private Object cloneArray(Object array) {
		Class<?> type = array.getClass();

		if (type == byte[].class) {
			byte[] byteArray = (byte[]) array;
			return byteArray.clone();
		}
		if (type == char[].class) {
			char[] charArray = (char[]) array;
			return charArray.clone();
		}
		if (type == double[].class) {
			double[] doubleArray = (double[]) array;
			return doubleArray.clone();
		}
		if (type == float[].class) {
			float[] floatArray = (float[]) array;
			return floatArray.clone();
		}
		if (type == int[].class) {
			int[] intArray = (int[]) array;
			return intArray.clone();
		}
		if (type == long[].class) {
			long[] longArray = (long[]) array;
			return longArray.clone();
		}
		if (type == short[].class) {
			short[] shortArray = (short[]) array;
			return shortArray.clone();
		}
		if (type == boolean[].class) {
			boolean[] booleanArray = (boolean[]) array;
			return booleanArray.clone();
		}

		Object[] objectArray = (Object[]) array;
		return objectArray.clone();
	}
739251
public static LinkedBuffer wrap(byte[] array, int offset, int length)
    {
        return new LinkedBuffer(array, offset, offset + length);
    }