Class BasicIntegerNDArray

    • Constructor Detail

      • BasicIntegerNDArray

        public BasicIntegerNDArray​(int... shape)
        Simple constructor that defines only the shape of the NDArray and fills it with zeros.
        Parameters:
        shape - dimensions / shape of the NDArray
      • BasicIntegerNDArray

        public BasicIntegerNDArray​(NDArray<? extends Number> array)
        Copy constructor.
        Parameters:
        array - NDArray from which entries are copied from.
    • Method Detail

      • of

        public static NDArray<Integer> of​(float... array)
        Factory method that creates an NDArray from a list or 1D array of int values.
        Parameters:
        array - a list or 1D array of int values from which a BasicIntegerNDArray is created.
        Returns:
        an NDArray created from a list or 1D array of int values
      • of

        public static NDArray<Integer> of​(double... array)
        Factory method that creates an NDArray from a list or 1D array of int values.
        Parameters:
        array - a list or 1D array of int values from which a BasicIntegerNDArray is created.
        Returns:
        an NDArray created from a list or 1D array of int values
      • of

        public static NDArray<Integer> of​(byte... array)
        Factory method that creates an NDArray from a list or 1D array of int values.
        Parameters:
        array - a list or 1D array of int values from which a BasicIntegerNDArray is created.
        Returns:
        an NDArray created from a list or 1D array of int values
      • of

        public static NDArray<Integer> of​(short... array)
        Factory method that creates an NDArray from a list or 1D array of int values.
        Parameters:
        array - a list or 1D array of int values from which a BasicIntegerNDArray is created.
        Returns:
        an NDArray created from a list or 1D array of int values
      • of

        public static NDArray<Integer> of​(int... array)
        Factory method that creates an NDArray from a list or 1D array of int values.
        Parameters:
        array - a list or 1D array of int values from which a BasicIntegerNDArray is created.
        Returns:
        an NDArray created from a list or 1D array of int values
      • of

        public static NDArray<Integer> of​(long... array)
        Factory method that creates an NDArray from a list or 1D array of int values.
        Parameters:
        array - a list or 1D array of int values from which a BasicIntegerNDArray is created.
        Returns:
        an NDArray created from a list or 1D array of int values
      • readFromFile

        public static BasicIntegerNDArray readFromFile​(File file)
                                                throws IOException
        Load the content of the given file into a new BasicIntegerNDArray.

        Only the files written by function writeToFile can be loaded by this function.

        • Example:
        
         NDArray<Float> array = new BasicFloatNDArray(128, 128).fill(5);
         array.writeToFile(new File("array.nda"));
         NDArray<Integer> array2 = BasicIntegerNDArray.readFromFile(new File("array.nda"));
         assertEquals(array, array2);
         
        Parameters:
        file - file from which the content of the NDArray is read (the extension of the file can be arbitrary, but .nda is recommended)
        Returns:
        a new BasicIntegerNDArray whose shape and content is loaded from the given file
        Throws:
        IOException - when the given file cannot be opened for read
      • of

        public static NDArray<Integer> of​(Object[] array)
        Factory method that creates an NDArray from a multi-dimensional array of numeric values.
        Parameters:
        array - a multi-dimensional array of numeric values from which a BasicIntegerNDArray is created.
        Returns:
        an NDArray created from a multi-dimensional array of numeric values
      • copyFrom

        public NDArray<Integer> copyFrom​(NDArray<?> array)
        Description copied from interface: NDArray
        Updates this NDArray with the elements of the NDArray given as parameter.

        Note: the parameter NDArray must have the same shape and this NDArray!

        Specified by:
        copyFrom in interface NDArray<Integer>
        Overrides:
        copyFrom in class AbstractRealNDArray<Integer>
        Parameters:
        array - NDArray from which values are copied to this NDArray
        Returns:
        this NDArray
      • getNamePrefix

        public String getNamePrefix()
        Description copied from interface: NDArray
        Returns a string that identifies the implementation behind this current object. The output of the toString() function starts with this string.
        Returns:
        a string that identifies the implementation
      • equals

        public boolean equals​(Object other)
        Description copied from interface: NDArray
        Compares the specified object with this NDArray for equality. Two arrays are equal, if they are both real or both complex, and they are element-wise equal. If the specified object is not NDArray then the function returns false.
        Specified by:
        equals in interface NDArray<Integer>
        Overrides:
        equals in class AbstractNDArray<Integer,​Integer>
        Parameters:
        other - Object to be compared for equality
        Returns:
        true if the specified object equals with this NDArray