Documentation of 'mikera.matrixx.AMatrix' Java class
AMatrix
mikera.matrixx

Class AMatrix

    • Constructor Summary

      Constructors 
      Constructor and Description
      AMatrix() 
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      void abs()
      Replaces all elements of this array with their absolute values, according to Math.abs(double)
      void add(AMatrix m)
      Adds another matrix to this matrix.
      void add(AVector v)
      Adds a vector to every row of this matrix.
      void add(double d)
      Adds a double value to all elements in this array.
      void add(INDArray a)
      Adds all the elements of another array to this array, in an elementwise order.
      void add2(AMatrix a, AMatrix b)
      Adds two matrices to this matrix.
      void addAt(int i, int j, double d)
      Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operation
      AMatrix addCopy(AMatrix a)
      Adds another matrix to this matrix, returning a new matrix
      Matrix addCopy(AStridedMatrix a)
      Adds a dense matrix to this matrix, returning a new dense Matrix
      AMatrix addCopy(AVector v)
      Adds a vector to every row of this matrix, returning a new matrix
      AMatrix addCopy(double d)
      Creates a new array equal to this array with a constant value added to every element
      INDArray addCopy(INDArray a)
      Creates a new array equal to the sum of this array with another array.
      void addInnerProduct(AMatrix a, AMatrix b)
      Adds the inner product (matrix multiply) of two matrices to this matrix
      void addInnerProduct(AMatrix a, INDArray b)
      Adds the inner product of a matrix and an array to this array
      void addInnerProduct(INDArray a, INDArray b)
      Adds the inner product of two arrays to this array.
      void addMultiple(AMatrix m, double factor)
      Adds a scalar multiple of another matrix to this matrix
      void addMultiple(AVector v, double factor)
      Adds a scalar multiple of a vector to every row of this matrix
      void addMultiple(INDArray src, double factor)
      Adds a scaled multiple of another array to this array
      void addOuterProduct(AVector a, AVector b)
      Adds the outer product of two vectors to this matrix
      void addOuterProduct(INDArray a, INDArray b)
      Adds the outer product of two arrays to this array.
      void addOuterProductSparse(AVector a, AVector b)
      Adds the outer product of two vectors to this matrix.
      void addOuterProductSparse(INDArray a, INDArray b)
      Adds the outer product of two arrays to this array.
      void addRowMultiple(int src, int dst, double factor)
      Adds a multiple of a source row to a destination row This is an elementary row operation
      void addSparse(AVector a)
      Adds the corresponding elements of the source vector to the non-sparse elements in rows of this matrix
      void addSparse(INDArray a)
      Adds the corresponding elements of the source array the non-sparse elements of this array
      void addToArray(double[] data, int offset)
      Adds all the elements of this array to a double array at the specified offset, in row-major order
      void applyOp(IOperator op)
      Applies a unary operator to all elements of the array (in-place)
      void applyOp(Op op)
      Applies a unary operator to all elements of the array (in-place)
      void applyOp(Op2 op, AMatrix b) 
      void applyOp(Op2 op, AVector b) 
      void applyOp(Op2 op, double b)
      Applies a binary operator to this array and a double value.
      void applyOp(Op2 op, INDArray b)
      Applies a binary operator to this array and a second array.
      AMatrix applyOpCopy(Op op)
      Applies a unary operator to all elements of the array (creating a new array)
      double[] asDoubleArray()
      Returns the underlying double array representing the densely packed elements of this array.
      java.util.List<java.lang.Double> asElementList()
      Returns a List containing all elements of this array
      AVector asVector()
      Returns the matrix values as a single reference Vector in the form [row0 row1 row2....]
      int bandIndex(int i, int j)
      Returns the band index number for a specified position in the matrix.
      int bandLength(int band)
      Returns the length of a band of the matrix.
      int bandPosition(int i, int j)
      Returns the band position for a specified (i,j) index in the matrix.
      int bandStartColumn(int band)
      Returns the start column of a given band.
      int bandStartRow(int band)
      Returns the start row of a given band.
      INDArray broadcast(int... targetShape)
      Returns a view of this array broadcasted up to a larger shape
      INDArray broadcastCloneLike(INDArray target)
      Creates a mutable clone of the array, broadcasted upwards if necessary to match the shape of the target.
      INDArray broadcastCopyLike(INDArray target)
      Creates a copy of the array, broadcasted upwards if necessary to match the shape of the target Like broadCastCloneLike, but does not guarantee a fully mutable clone - hence may be faster when used with immutable or specialized arrays
      AMatrix broadcastLike(AMatrix target)
      Broadcasts an array to match the shape of the target matrix
      INDArray broadcastLike(INDArray target)
      Broadcasts an array to match the shape of the target
      int checkColumn(int column)
      Checks if the given column index is valid for this matrix.
      int checkRow(int row)
      Checks if the given rows index is valid for this matrix.
      int checkSquare()
      Checks if a matrix is square.
      void clamp(double min, double max)
      Clamps all the elements of this array within the specified [min,max] range
      AMatrix clone()
      Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original.
      void composeWith(AMatrix a) 
      AMatrix copy()
      Returns a defensive copy of the array data.
      void copyColumnTo(int j, double[] dest, int destOffset)
      Copies the elements in a selected row of this matrix to a double array
      void copyRowTo(int i, double[] dest, int destOffset)
      Copies the elements in a selected row of this matrix to a double array
      AMatrix dense()
      Coerces this INDArray to a dense format, without changing its element values.
      Matrix denseClone()
      Creates a fully mutable dense clone of this array.
      double determinant()
      Calculates the determinant of the matrix.
      double diagonalProduct()
      Computes the product of entries on the main diagonal of a matrix
      int dimensionality()
      Returns the dimensionality of the array (i.e.
      void divide(AMatrix m)
      Divides this matrix in-place by another in an entrywise manner.
      void divide(AVector v)
      Divides every row of this matrix by the given vector
      void divide(double factor)
      Divides all elements by a given factor
      void divide(INDArray a)
      Divides all elements in place by the equivalent elements in a second array
      AMatrix divideCopy(double d)
      Returns a copy of the array with all elements divided by a single constant value
      long elementCount()
      Returns the total number of elements in this array.
      java.util.Iterator<java.lang.Double> elementIterator()
      Returns an iterator over all elements in this array, in row-major order
      boolean elementsEqual(double value)
      Returns true if all elements are equal to a specific value
      double elementSquaredSum()
      Returns the squared sum of all elements in this matrix
      double elementSum()
      Returns the sum of all elements in this matrix
      AMatrix ensureMutable()
      Ensures the array is a fully mutable representation.
      boolean epsilonEquals(AMatrix a)
      Returns true if this matrix is approximately equal to a second matrix, up to a default tolerance level
      boolean epsilonEquals(AMatrix a, double epsilon) 
      boolean epsilonEquals(INDArray a, double epsilon)
      Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape
      boolean equals(AMatrix a)
      Returns true if this matrix is exactly equal to another matrix
      boolean equals(INDArray v)
      Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
      boolean equals(java.lang.Object o) 
      boolean equalsArray(double[] data, int offset)
      Returns true if the elements in this array exactly match the elements in the given array, in row-major order
      boolean equalsTranspose(AMatrix a)
      Tests if this matrix is exactly equal to the transpose of another matrix
      abstract AMatrix exactClone()
      Creates a deep clone of an array, using the same class implementation as the original array
      void exp()
      Computes the function e^x (in-place) for all array elements
      void fill(double value)
      Fills this array with a single double value.
      double get()
      Returns the double value of a scalar array
      double get(AIndex ix)
      Returns the double value at the specified position in the array
      double get(int... indexes)
      Returns the double value at the specified index position in an array
      double get(int row)
      Returns the double value at the specified position in a 1D vector
      abstract double get(int i, int j)
      Returns the double value at the specified position in a 2D matrix
      AVector getBand(int band)
      Gets a specific band of the matrix, as a view vector.
      AVector getBandWrapped(int band) 
      AVector getColumn(int column)
      Returns a column of the matrix.
      AVector getColumnClone(int column)
      Returns a column of the matrix as a new cloned, mutable vector The cloned column may be modified without affecting the original matrix.
      java.util.List<AVector> getColumns()
      Gets a List of columns of a matrix.
      AVector getColumnView(int column)
      Returns a column of the matrix as a vector view.
      double getElement(long i)
      Gets a specific element of this array, indexed in row-major order
      void getElements(double[] dest, int offset)
      Copies all elements of this array a double array at the specified offset
      AVector getLeadingDiagonal()
      Returns a vector view of the leading diagonal values of the matrix
      long[] getLongShape()
      Returns the shape of the array as an array of longs.
      AVector getRow(int row)
      Returns a row of the matrix.
      AVector getRowClone(int row)
      Returns a row of the matrix as a new cloned, mutable vector.
      java.util.List<AVector> getRows()
      Gets a List of rows of a matrix.
      AVector getRowView(int row)
      Returns a row of the matrix as a vector view.
      int[] getShape()
      Returns the shape of the array as an array of ints.
      int getShape(int dim)
      Returns the dimension size for a specific dimension in the array's shape
      int[] getShapeClone()
      Returns the shape of the array as an array of ints, guaranteed to be a new array i.e.
      java.util.List<AVector> getSlices()
      Returns a list of all major slices of this array.
      java.util.List<AVector> getSlices(int dimension)
      Returns a list of all slices of this array along a given dimension.
      java.util.List<INDArray> getSliceViews()
      Returns a list of slices as mutable INDArray views.
      AMatrix getTranspose()
      Returns the transpose of this array.
      AMatrix getTransposeCopy()
      Gets a mutable transposed clone of the matrix
      AMatrix getTransposeView()
      Returns a transposed view of the array.
      int hashCode() 
      boolean hasOrthonormalColumns()
      Tests whether all columns in the matrix are orthonormal vectors
      boolean hasOrthonormalRows()
      Tests whether all rows in the matrix are orthonormal vectors
      boolean hasUncountable()
      Checks to see if any element in the matrix is NaN of Infinite.
      INDArray immutable()
      Returns an immutable version of this array.
      AMatrix innerProduct(AMatrix a)
      Computes the inner product of this matrix with another.
      AMatrix innerProduct(AScalar s)
      Calculates the inner product of this array with a scalar
      AVector innerProduct(AVector v)
      Computes the inner product of this array with a vector
      AMatrix innerProduct(double d)
      Calculates the inner product of this array with a double value
      INDArray innerProduct(INDArray a)
      Calculates the inner product of this array with another array.
      Vector innerProduct(Vector v)
      Transforms a dense source Vector using matrix multiplication (inner product).
      int inputDimensions()
      Returns the number of dimensions required for input vectors
      AMatrix inverse()
      Computes the inverse of a matrix.
      boolean isBoolean()
      Returns true if the array is boolean (contains only 0.0 or 1.0 values)
      boolean isDiagonal()
      Returns true iff this matrix is a square diagonal matrix
      boolean isElementConstrained()
      Returns true if this array has some constraints on element values
      abstract boolean isFullyMutable()
      If this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e.
      boolean isHermitian()
      Returns true if a matrix is Hermitian This is equivalent to isSymmetric(), since all Vectorz matrices have real values.
      boolean isIdentity()
      Checks if this is an identity matrix (i.e.
      boolean isInvertible()
      Checks if this is an invertible matrix (i.e.
      boolean isLowerTriangular()
      Returns true if a matrix is lower triangular.
      boolean isMutable()
      Returns true if the INDArray is mutable (at least partially)
      boolean isOrthogonal()
      Check to see if the matrix is orthogonal (default tolerance: 1e-8)
      boolean isOrthogonal(double tolerance)
      Check to see if the matrix is orthogonal
      boolean isPositiveDefinite()
      Returns true if a matrix is positive definite
      boolean isRectangularDiagonal()
      Returns true iff this matrix is a diagonal matrix (might not be square)
      boolean isSameShape(AMatrix a)
      Returns true iff this matrix is exactly the same shape as another matrix
      boolean isSameShape(INDArray a)
      Returns true if this array is the same shape as another array
      boolean isSquare()
      Checks if this is a square matrix
      boolean isSymmetric()
      Returns true if a matrix is symmetric
      boolean isUpperTriangular()
      Returns true if a matrix is upper triangular An upper triangular matrix is defined as having all elements equal to 0.0 where i > j
      boolean isView()
      Return true if this array is considered as a view type.
      boolean isZero()
      Returns true if the matrix is the zero matrix (all components zero)
      java.util.Iterator<AVector> iterator()
      Returns an iterator over rows in this Matrix
      INDArray join(INDArray a, int dimension)
      Joins an array with another array along a specified dimension.
      void log()
      Computes the natural logarithm (in-place) for all array elements
      int lowerBandwidth()
      Computes the lower bandwidth of a matrix, i.e.
      int lowerBandwidthLimit()
      A limit on the lower bandwidth of the banded matrix.
      void mul(AMatrix a)
      "Multiplies" this matrix by another, composing the transformation
      void multiply(AMatrix m)
      Multiplies this matrix in-place by another in an entrywise manner (Hadamard product).
      void multiply(AVector v)
      Multiply each row in this matrix by a vector.
      void multiply(double factor)
      Multiplies all elements of the array in place by a given double value
      void multiply(INDArray a)
      Multiplies all elements by the equivalent elements in a second array, i.e.
      AMatrix multiplyCopy(double factor)
      Returns a copy of the array with all elements multiplied by a single constant value
      void multiplyRow(int i, double factor)
      Multiplies a row by a constant factor This is an elementary row operation
      AMatrix mutable()
      Coerces this INDArray to a fully mutable format.
      void negate()
      Negates all elements in the array in place
      long nonZeroCount()
      Returns the number of non-zero elements in the array.
      INDArray outerProduct(INDArray a)
      Calculates the outer product of this array with another array.
      int outputDimensions()
      Returns the number of dimensions required for output vectors
      void pow(double exponent)
      Raises all elements of the array to a specified power in place
      int rank()
      Calculate the rank of a matrix.
      void reciprocal()
      Replaces all elements in the array with their reciprocal
      double reduce(Op2 op)
      Reduces over all elements of the array in row-major order.
      double reduce(Op2 op, double init)
      Reduces over all elements of the array in row-major order.
      AVector reduceSlices(Op2 op)
      Reduces each vector slice of the array by the given binary operator Reduces down to a single vector
      AVector reduceSlices(Op2 op, double init)
      Reduces each slice of the array by the given binary operator.
      AMatrix reorder(int[] order)
      Returns a re-ordered array by taking the specified order of slices along dimension 0
      AMatrix reorder(int dim, int[] order)
      Returns a re-ordered array by taking the specified order of slices along a given dimension May or may not use views of underlying slices (i.e.
      void replaceColumn(int i, AVector row)
      Replaces a column in a matrix, adding the column to the internal structure of the matrix.
      void replaceRow(int i, AVector row)
      Replaces a row in a matrix, adding the row to the internal structure of the matrix.
      INDArray reshape(int... dimensions)
      Returns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shape
      Matrix reshape(int rows, int cols) 
      INDArray rotateView(int dimension, int shift)
      Returns rotated view of this array
      double rowDotProduct(int i, AVector a)
      Returns the dot product of a specific row with a vector.
      void scaleAdd(double factor, double constant)
      Scales all elements of the array by a given double value and adds a constant value
      void scaleAdd(double factor, INDArray b, double bfactor, double constant)
      Scales all elements of the array by a given double value, adds a scaled second array and adds a constant value
      void set(AMatrix a)
      Sets this matrix with the element values from another matrix.
      void set(AVector v)
      Sets every row of this matrix with the element values from a vector.
      void set(double value)
      Sets all elements of an array to a specific double value
      void set(INDArray a)
      Sets this array to the element values contained in another array.
      void set(int[] indexes, double value)
      Sets the element at the given indexed position in a mutable array
      void set(int row, double value)
      Sets a value at a given position in a mutable 1D array
      abstract void set(int i, int j, double value)
      Sets a value at a given position in a mutable 2D array
      void set(long[] indexes, double value)
      Sets the element at the given indexed position in a mutable array
      void set(java.lang.Object o)
      Sets this array to the element values contained in the given object.
      void setApplyOp(Op op, AMatrix a)
      Sets this matrix to the result of applying an operator to another matrix
      void setApplyOp(Op op, INDArray a)
      Sets this array to the result of applying an operation to a source array
      void setColumn(int i, AVector col)
      Sets a column in a matrix.
      void setElements(double... values)
      Sets all elements in an array using the given double values
      void setElements(double[] values, int offset)
      Sets all elements in an array using the given double values
      void setMultiple(AMatrix a, AMatrix b)
      Sets this matrix to the elementwise product of two other matrices
      void setMultiple(AMatrix a, double b)
      Sets this matrix to a multiple of another matrix
      void setMultiple(AVector a, double b)
      Sets every row of this matrix to a multiple of a vector
      void setMultiple(INDArray a, double b)
      Sets this array to be the multiple of another array.
      void setMultiple(INDArray a, INDArray b)
      Sets this array to the element-wise multiple of two arrays.
      void setRow(int i, AVector row)
      Sets a row in a matrix to the value specified by the given vector
      void setSparse(AMatrix a)
      Sets the non-sparse elements in this matrix to the corresponding values in the source matrix
      void setSparse(INDArray a)
      Sets the non-sparse elements of this array to the corresponding elements of the source array
      void signum()
      Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
      AVector slice(int row)
      Returns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.
      AVector slice(int dimension, int index)
      Returns a slice view of this array along the specified dimension
      int sliceCount()
      Returns the number of major slices in this array (i.e.
      AMatrix sparse()
      Coerces this INDArray to a sparse format, without changing its element values.
      AMatrix sparseClone()
      Creates a fully mutable clone of this array.
      void sqrt()
      Computes the square root of all elements in the array
      void square()
      Squares all elements of the array in place
      void sub(AMatrix m)
      Subtracts another matrix from this one
      void sub(AVector v)
      Subtracts a vector from every row of this matrix.
      void sub(INDArray a)
      Subtracts all the elements of another array from this array, in an elementwise order.
      AMatrix subArray(int[] offsets, int[] shape)
      Returns a subarray view of a larger array
      AMatrix subCopy(AMatrix m)
      Subtracts another matrix from this one, returning a new matrix
      AMatrix subMatrix(int rowStart, int rows, int colStart, int cols)
      Gets a rectangular submatrix view of part of a matrix
      void swapColumns(int i, int j)
      Swaps two columns of the matrix in place
      void swapRows(int i, int j)
      Swaps two rows of the matrix in place This is an elementary row operation
      AAffineTransform toAffineTransform() 
      double[] toDoubleArray()
      Copies the elements of this array to a new double[] array.
      void toDoubleBuffer(java.nio.DoubleBuffer dest)
      Copies the elements of this INDArray to the specified double buffer.
      Matrix toMatrix()
      Coerces the matrix to the standard mutable Matrix type in row major order.
      Matrix toMatrixTranspose()
      Coerces the transpose of a matrix to the standard mutable Matrix type in row major order.
      AMatrix toMutableMatrix()
      Creates a fully mutable deep copy of this matrix
      double[][] toNestedDoubleArrays()
      Converts this matrix to nested double[][] array
      AVector[] toSliceArray()
      Copies the slices of this array to a new INDArray[] Throws an error if the array has no slices (i.e.
      java.lang.String toString() 
      java.lang.String toStringFull() 
      Vector toVector()
      Coerces the array into a flattened dense Vector, in row-major order.
      double trace()
      Computes the trace of a matrix, i.e.
      void transform(AVector source, AVector dest)
      Transforms a source vector into a destination vector, using matrix multiplication (inner product).
      void transform(Vector source, Vector dest) 
      void transformInPlace(ADenseArrayVector v) 
      void transformInPlace(AVector v) 
      AMatrix transposeInnerProduct(AMatrix s) 
      AMatrix transposeInnerProduct(Matrix s) 
      void transposeInPlace()
      Transposes a matrix in place, if possible.
      double unsafeGet(int i, int j)
      Gets an element in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
      void unsafeSet(int i, int j, double value)
      Sets an element value in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
      int upperBandwidth()
      Computes the upper bandwidth of a matrix, i.e.
      int upperBandwidthLimit()
      A limit on the upper bandwidth of the banded matrix.
      void validate()
      Validates the internal data structure of the INDArray.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Comparable

        compareTo
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • AMatrix

        public AMatrix()
    • Method Detail

      • get

        public abstract double get(int i,
                                   int j)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 2D matrix
        Specified by:
        get in interface INDArray
        Specified by:
        get in interface IMatrix
        Specified by:
        get in class AbstractArray<AVector>
      • set

        public abstract void set(int i,
                                 int j,
                                 double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 2D array
        Specified by:
        set in interface INDArray
        Specified by:
        set in interface IMatrix
        Overrides:
        set in class AbstractArray<AVector>
      • get

        public final double get(int row)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 1D vector
        Specified by:
        get in interface INDArray
        Specified by:
        get in class AbstractArray<AVector>
      • get

        public final double get()
        Description copied from interface: INDArray
        Returns the double value of a scalar array
        Specified by:
        get in interface INDArray
        Specified by:
        get in class AbstractArray<AVector>
      • set

        public void set(int row,
                        double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 1D array
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<AVector>
      • set

        public final void set(double value)
        Description copied from interface: INDArray
        Sets all elements of an array to a specific double value
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<AVector>
      • fill

        public void fill(double value)
        Description copied from interface: INDArray
        Fills this array with a single double value. Requires the array to be mutable.
        Specified by:
        fill in interface INDArray
        Overrides:
        fill in class AbstractArray<AVector>
      • unsafeSet

        public void unsafeSet(int i,
                              int j,
                              double value)
        Sets an element value in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
        Parameters:
        i -
        j -
      • unsafeGet

        public double unsafeGet(int i,
                                int j)
        Gets an element in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
        Parameters:
        i -
        j -
        Returns:
      • clamp

        public void clamp(double min,
                          double max)
        Description copied from interface: INDArray
        Clamps all the elements of this array within the specified [min,max] range
        Specified by:
        clamp in interface INDArray
        Overrides:
        clamp in class AbstractArray<AVector>
      • pow

        public void pow(double exponent)
        Description copied from interface: INDArray
        Raises all elements of the array to a specified power in place
        Specified by:
        pow in interface INDArray
        Overrides:
        pow in class AbstractArray<AVector>
      • set

        public void set(int[] indexes,
                        double value)
        Description copied from interface: INDArray
        Sets the element at the given indexed position in a mutable array
        Specified by:
        set in interface INDArray
      • set

        public void set(long[] indexes,
                        double value)
        Description copied from interface: INDArray
        Sets the element at the given indexed position in a mutable array
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<AVector>
      • dimensionality

        public final int dimensionality()
        Description copied from interface: INDArray
        Returns the dimensionality of the array (i.e. the number of dimensions in the array shape) e.g. 0 for a scalar, 1 for a vector, 2 for a matrix etc.
        Specified by:
        dimensionality in interface INDArray
      • inputDimensions

        public final int inputDimensions()
        Returns the number of dimensions required for input vectors
        Returns:
      • outputDimensions

        public final int outputDimensions()
        Returns the number of dimensions required for output vectors
        Returns:
      • elementCount

        public long elementCount()
        Description copied from interface: INDArray
        Returns the total number of elements in this array. Equivalent to the product of all dimension sizes.
        Specified by:
        elementCount in interface INDArray
      • slice

        public final AVector slice(int row)
        Description copied from interface: INDArray
        Returns the specified major slice of this array as a view (slice along dimension 0) 0 dimensional slice results are permitted, but attempting to slice a 0 dimensional array will result in an error.
        Specified by:
        slice in interface INDArray
      • slice

        public AVector slice(int dimension,
                             int index)
        Description copied from interface: INDArray
        Returns a slice view of this array along the specified dimension
        Specified by:
        slice in interface INDArray
      • sliceCount

        public int sliceCount()
        Description copied from interface: INDArray
        Returns the number of major slices in this array (i.e. the size of dimension 0)
        Specified by:
        sliceCount in interface INDArray
      • getSlices

        public final java.util.List<AVector> getSlices()
        Description copied from interface: INDArray
        Returns a list of all major slices of this array. Returns a list of Double values if a 1-dimensional array is sliced, otherwise a list of INDArray instances
        Specified by:
        getSlices in interface INDArray
        Overrides:
        getSlices in class AbstractArray<AVector>
      • getRows

        public java.util.List<AVector> getRows()
        Description copied from interface: IMatrix
        Gets a List of rows of a matrix. May return either copies or views, depending on the specific matrix type.
        Specified by:
        getRows in interface IMatrix
        Returns:
      • getColumns

        public java.util.List<AVector> getColumns()
        Description copied from interface: IMatrix
        Gets a List of columns of a matrix. May return either copies or views, depending on the specific matrix type.
        Specified by:
        getColumns in interface IMatrix
        Returns:
      • getSlices

        public final java.util.List<AVector> getSlices(int dimension)
        Description copied from interface: INDArray
        Returns a list of all slices of this array along a given dimension. Returns a list of Double values if a 1-dimensional array is sliced, otherwise a list of INDArray instances
        Specified by:
        getSlices in interface INDArray
        Overrides:
        getSlices in class AbstractArray<AVector>
      • join

        public INDArray join(INDArray a,
                             int dimension)
        Description copied from interface: INDArray
        Joins an array with another array along a specified dimension. Guarantees a view that combines the two joined arrays.
        Specified by:
        join in interface INDArray
        Overrides:
        join in class AbstractArray<AVector>
      • getShape

        public int[] getShape()
        Description copied from interface: INDArray
        Returns the shape of the array as an array of ints. WARNING: May return the internal int[] array describing the shape. Modifying this may cause undefined behaviour. If you want to guarantee a new int[] array that can be safely modified, use getShapeClone() instead
        Specified by:
        getShape in interface INDArray
      • getShapeClone

        public int[] getShapeClone()
        Description copied from interface: INDArray
        Returns the shape of the array as an array of ints, guaranteed to be a new array i.e. will perform a defensive copy of any internal shape array if required.
        Specified by:
        getShapeClone in interface INDArray
        Overrides:
        getShapeClone in class AbstractArray<AVector>
      • getShape

        public int getShape(int dim)
        Description copied from interface: INDArray
        Returns the dimension size for a specific dimension in the array's shape
        Specified by:
        getShape in interface INDArray
        Overrides:
        getShape in class AbstractArray<AVector>
      • get

        public double get(int... indexes)
        Description copied from interface: INDArray
        Returns the double value at the specified index position in an array
        Specified by:
        get in interface INDArray
      • get

        public final double get(AIndex ix)
        Description copied from interface: INDArray
        Returns the double value at the specified position in the array
        Specified by:
        get in interface INDArray
        Overrides:
        get in class AbstractArray<AVector>
      • getElement

        public double getElement(long i)
        Description copied from interface: INDArray
        Gets a specific element of this array, indexed in row-major order
        Specified by:
        getElement in interface INDArray
        Returns:
        The element value
      • getLeadingDiagonal

        public AVector getLeadingDiagonal()
        Returns a vector view of the leading diagonal values of the matrix
        Returns:
      • isIdentity

        public boolean isIdentity()
        Description copied from interface: IMatrix
        Checks if this is an identity matrix (i.e. 1.0 in leading diagonal, 0.0 elsewhere)
        Specified by:
        isIdentity in interface IMatrix
        Returns:
        true if this matrix is a square identity matrix, false otherwise.
      • isSquare

        public boolean isSquare()
        Description copied from interface: IMatrix
        Checks if this is a square matrix
        Specified by:
        isSquare in interface IMatrix
        Returns:
        true if square, false otherwise
      • isOrthogonal

        public boolean isOrthogonal()
        Check to see if the matrix is orthogonal (default tolerance: 1e-8)
        Returns:
      • isOrthogonal

        public boolean isOrthogonal(double tolerance)
        Check to see if the matrix is orthogonal
        Parameters:
        tolerance - inner product of a column with all of the next columns should be less than tolerance
        Returns:
      • hasOrthonormalColumns

        public boolean hasOrthonormalColumns()
        Tests whether all columns in the matrix are orthonormal vectors
        Returns:
      • hasOrthonormalRows

        public boolean hasOrthonormalRows()
        Tests whether all rows in the matrix are orthonormal vectors
        Returns:
      • reshape

        public INDArray reshape(int... dimensions)
        Description copied from interface: INDArray
        Returns a new array by rearranging the elements of this array into the desired shape Truncates or zero-pads the elements as required to fill the new shape
        Specified by:
        reshape in interface INDArray
        Overrides:
        reshape in class AbstractArray<AVector>
      • reshape

        public Matrix reshape(int rows,
                              int cols)
      • reorder

        public AMatrix reorder(int dim,
                               int[] order)
        Description copied from interface: INDArray
        Returns a re-ordered array by taking the specified order of slices along a given dimension May or may not use views of underlying slices (i.e. may be a reordered view)
        Specified by:
        reorder in interface INDArray
        Overrides:
        reorder in class AbstractArray<AVector>
      • subMatrix

        public AMatrix subMatrix(int rowStart,
                                 int rows,
                                 int colStart,
                                 int cols)
        Description copied from interface: IMatrix
        Gets a rectangular submatrix view of part of a matrix
        Specified by:
        subMatrix in interface IMatrix
      • transform

        public void transform(AVector source,
                              AVector dest)
        Description copied from interface: IMatrix
        Transforms a source vector into a destination vector, using matrix multiplication (inner product). The destination vector is overwritten.
        Specified by:
        transform in interface IMatrix
      • transform

        public void transform(Vector source,
                              Vector dest)
      • getRow

        public AVector getRow(int row)
        Description copied from interface: IMatrix
        Returns a row of the matrix. May or may not be a view, depending on matrix type. Intended for the fastest possible read access of the row. This often means a view, but might not be (e.g. getRow on a Matrix33 returns a Vector3).
        Specified by:
        getRow in interface IMatrix
      • getColumn

        public AVector getColumn(int column)
        Description copied from interface: IMatrix
        Returns a column of the matrix. May or may not be a view, depending on matrix type. Intended for the fastest possible read access of the column. This often means a view, but might not be (e.g. getColumn on a Matrix33 returns a Vector3).
        Specified by:
        getColumn in interface IMatrix
      • getRowView

        public AVector getRowView(int row)
        Description copied from interface: IMatrix
        Returns a row of the matrix as a vector view. May be used to modify the original matrix.
        Specified by:
        getRowView in interface IMatrix
      • getColumnView

        public AVector getColumnView(int column)
        Description copied from interface: IMatrix
        Returns a column of the matrix as a vector view. May be used to modify the original matrix.
        Specified by:
        getColumnView in interface IMatrix
      • getRowClone

        public AVector getRowClone(int row)
        Description copied from interface: IMatrix
        Returns a row of the matrix as a new cloned, mutable vector. The cloned row may be modified without affecting the original matrix.
        Specified by:
        getRowClone in interface IMatrix
      • getColumnClone

        public AVector getColumnClone(int column)
        Description copied from interface: IMatrix
        Returns a column of the matrix as a new cloned, mutable vector The cloned column may be modified without affecting the original matrix.
        Specified by:
        getColumnClone in interface IMatrix
      • set

        public void set(AMatrix a)
        Sets this matrix with the element values from another matrix. Source matrix must have the same shape.
        Parameters:
        a -
      • set

        public void set(INDArray a)
        Description copied from interface: INDArray
        Sets this array to the element values contained in another array. Broadcasts the source array if necessary to the shape of this array. Throws an exception if the shapes are incompatible.
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<AVector>
      • set

        public void set(AVector v)
        Sets every row of this matrix with the element values from a vector.
        Parameters:
        a -
      • set

        public void set(java.lang.Object o)
        Description copied from interface: INDArray
        Sets this array to the element values contained in the given object. Attempts to interpret the object as an array, and broadcasts the object to the shape of this array if required.
        Specified by:
        set in interface INDArray
        Overrides:
        set in class AbstractArray<AVector>
      • getElements

        public void getElements(double[] dest,
                                int offset)
        Description copied from interface: INDArray
        Copies all elements of this array a double array at the specified offset
        Specified by:
        getElements in interface INDArray
        Overrides:
        getElements in class AbstractArray<AVector>
      • setElements

        public final void setElements(double... values)
        Description copied from interface: INDArray
        Sets all elements in an array using the given double values
        Specified by:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<AVector>
        Parameters:
        values - Element values in a double[] array. There must be at least as many element values as elements in this array.
      • setMultiple

        public void setMultiple(AMatrix a,
                                AMatrix b)
        Sets this matrix to the elementwise product of two other matrices
        Parameters:
        a -
        b -
      • setMultiple

        public final void setMultiple(AMatrix a,
                                      double b)
        Sets this matrix to a multiple of another matrix
        Parameters:
        a -
        b -
      • setMultiple

        public final void setMultiple(AVector a,
                                      double b)
        Sets every row of this matrix to a multiple of a vector
        Parameters:
        a -
        b -
      • setElements

        public void setElements(double[] values,
                                int offset)
        Description copied from interface: INDArray
        Sets all elements in an array using the given double values
        Specified by:
        setElements in interface INDArray
        Overrides:
        setElements in class AbstractArray<AVector>
        Parameters:
        values - Element values in a double[] array. There must be at least as many element values as elements in this array.
        offset - Position in the values array from which to start taking values.
      • isFullyMutable

        public abstract boolean isFullyMutable()
        Description copied from interface: INDArray
        If this method returns true, the INDArray is guaranteed to be fully mutable in all positions i.e. every position can store any valid double value
        Specified by:
        isFullyMutable in interface INDArray
        Overrides:
        isFullyMutable in class AbstractArray<AVector>
      • clone

        public AMatrix clone()
        Description copied from interface: INDArray
        Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original. Clone should attempt to return the most efficient possible array type. Clone should preserve sparsity property where possible, but this is not guaranteed.
        Specified by:
        clone in interface INDArray
        Overrides:
        clone in class AbstractArray<AVector>
      • copy

        public AMatrix copy()
        Description copied from interface: INDArray
        Returns a defensive copy of the array data. Use this if the original array might change and you need a defensive copy. May return the same array if the original was immutable, otherwise will return a defensive copy.
        Specified by:
        copy in interface INDArray
        Overrides:
        copy in class AbstractArray<AVector>
      • determinant

        public double determinant()
        Calculates the determinant of the matrix.
      • rank

        public int rank()
        Calculate the rank of a matrix. This is equivalent to the maximum number of linearly independent rows or columns.
      • toMutableMatrix

        public AMatrix toMutableMatrix()
        Creates a fully mutable deep copy of this matrix
        Returns:
        A new matrix
      • transposeInPlace

        public void transposeInPlace()
        Description copied from interface: IMatrix
        Transposes a matrix in place, if possible. Throws an exception if this is not possible (e.g. if the matrix is not square or not sufficiently mutable)
        Specified by:
        transposeInPlace in interface IMatrix
      • getTranspose

        public AMatrix getTranspose()
        Description copied from interface: INDArray
        Returns the transpose of this array. A transpose of an array is equivalent to reversing the order of dimensions. May or may not return a view depending on the array type.
        Specified by:
        getTranspose in interface INDArray
        Specified by:
        getTranspose in interface IMatrix
        Overrides:
        getTranspose in class AbstractArray<AVector>
        Returns:
        the transpose of this matrix
      • add

        public void add(AMatrix m)
        Adds another matrix to this matrix. Matrices must be the same size.
      • add

        public void add(AVector v)
        Adds a vector to every row of this matrix.
      • sub

        public void sub(AVector v)
        Subtracts a vector from every row of this matrix.
      • scaleAdd

        public final void scaleAdd(double factor,
                                   double constant)
        Description copied from interface: INDArray
        Scales all elements of the array by a given double value and adds a constant value
        Specified by:
        scaleAdd in interface INDArray
        Overrides:
        scaleAdd in class AbstractArray<AVector>
      • scaleAdd

        public void scaleAdd(double factor,
                             INDArray b,
                             double bfactor,
                             double constant)
        Description copied from interface: INDArray
        Scales all elements of the array by a given double value, adds a scaled second array and adds a constant value
        Specified by:
        scaleAdd in interface INDArray
        Overrides:
        scaleAdd in class AbstractArray<AVector>
      • multiply

        public void multiply(double factor)
        Description copied from interface: INDArray
        Multiplies all elements of the array in place by a given double value
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AbstractArray<AVector>
      • multiplyCopy

        public AMatrix multiplyCopy(double factor)
        Description copied from interface: INDArray
        Returns a copy of the array with all elements multiplied by a single constant value
        Specified by:
        multiplyCopy in interface INDArray
        Overrides:
        multiplyCopy in class AbstractArray<AVector>
        Parameters:
        factor - A scalar factor
        Returns:
        A new array, with all element values scaled by the given factor
      • divideCopy

        public AMatrix divideCopy(double d)
        Description copied from interface: INDArray
        Returns a copy of the array with all elements divided by a single constant value
        Specified by:
        divideCopy in interface INDArray
        Overrides:
        divideCopy in class AbstractArray<AVector>
        Returns:
        A new array, with all element values scaled by the given factor
      • sub

        public void sub(AMatrix m)
        Subtracts another matrix from this one
        Parameters:
        m -
      • subCopy

        public AMatrix subCopy(AMatrix m)
        Subtracts another matrix from this one, returning a new matrix
        Parameters:
        m -
      • abs

        public void abs()
        Description copied from interface: INDArray
        Replaces all elements of this array with their absolute values, according to Math.abs(double)
        Specified by:
        abs in interface INDArray
        Overrides:
        abs in class AbstractArray<AVector>
      • log

        public void log()
        Description copied from interface: INDArray
        Computes the natural logarithm (in-place) for all array elements
        Specified by:
        log in interface INDArray
        Overrides:
        log in class AbstractArray<AVector>
      • exp

        public void exp()
        Description copied from interface: INDArray
        Computes the function e^x (in-place) for all array elements
        Specified by:
        exp in interface INDArray
        Overrides:
        exp in class AbstractArray<AVector>
      • signum

        public void signum()
        Description copied from interface: INDArray
        Calculates the signum of all elements of this mutable array Sets each component of the array to its sign value (-1, 0 or 1)
        Specified by:
        signum in interface INDArray
        Overrides:
        signum in class AbstractArray<AVector>
      • multiply

        public void multiply(AMatrix m)
        Multiplies this matrix in-place by another in an entrywise manner (Hadamard product).
        Parameters:
        m -
      • divide

        public void divide(AMatrix m)
        Divides this matrix in-place by another in an entrywise manner.
        Parameters:
        m -
      • mul

        public void mul(AMatrix a)
        "Multiplies" this matrix by another, composing the transformation
        Parameters:
        a -
      • multiplyRow

        public void multiplyRow(int i,
                                double factor)
        Multiplies a row by a constant factor This is an elementary row operation
      • addRowMultiple

        public void addRowMultiple(int src,
                                   int dst,
                                   double factor)
        Adds a multiple of a source row to a destination row This is an elementary row operation
      • addInnerProduct

        public void addInnerProduct(AMatrix a,
                                    AMatrix b)
        Adds the inner product (matrix multiply) of two matrices to this matrix
      • addOuterProductSparse

        public void addOuterProductSparse(AVector a,
                                          AVector b)
        Adds the outer product of two vectors to this matrix. Mutates only the non-sparse elements in this matrix
        Parameters:
        a -
        b -
      • addOuterProduct

        public void addOuterProduct(AVector a,
                                    AVector b)
        Adds the outer product of two vectors to this matrix
        Parameters:
        a -
        b -
      • addSparse

        public void addSparse(AVector a)
        Adds the corresponding elements of the source vector to the non-sparse elements in rows of this matrix
        Parameters:
        a -
      • setSparse

        public void setSparse(AMatrix a)
        Sets the non-sparse elements in this matrix to the corresponding values in the source matrix
        Parameters:
        a -
      • addToArray

        public void addToArray(double[] data,
                               int offset)
        Description copied from interface: INDArray
        Adds all the elements of this array to a double array at the specified offset, in row-major order
        Specified by:
        addToArray in interface INDArray
        Overrides:
        addToArray in class AbstractArray<AVector>
      • swapRows

        public void swapRows(int i,
                             int j)
        Swaps two rows of the matrix in place This is an elementary row operation
      • swapColumns

        public void swapColumns(int i,
                                int j)
        Swaps two columns of the matrix in place
      • composeWith

        public void composeWith(AMatrix a)
      • isView

        public boolean isView()
        Description copied from interface: INDArray
        Return true if this array is considered as a view type. This indicates (but does not guarantee): a) Data is *likely* to be shared with other arrays, so mutation of one may affect others b) It is *unlikely* to be in the most efficient general purpose format isView is intended to be used as for heuristics. It should *not* be used where the outcome might affect correctness.
        Specified by:
        isView in interface INDArray
      • addMultiple

        public void addMultiple(AVector v,
                                double factor)
        Adds a scalar multiple of a vector to every row of this matrix
        Parameters:
        m -
        factor -
      • addMultiple

        public void addMultiple(AMatrix m,
                                double factor)
        Adds a scalar multiple of another matrix to this matrix
        Parameters:
        m -
        factor -
      • iterator

        public java.util.Iterator<AVector> iterator()
        Returns an iterator over rows in this Matrix
        Specified by:
        iterator in interface java.lang.Iterable<AVector>
        Overrides:
        iterator in class AbstractArray<AVector>
      • epsilonEquals

        public final boolean epsilonEquals(INDArray a,
                                           double epsilon)
        Description copied from interface: INDArray
        Tests is this array is approximately equal to another array, up to a given tolerance (epsilon) The arrays must have the same shape
        Specified by:
        epsilonEquals in interface INDArray
        Overrides:
        epsilonEquals in class AbstractArray<AVector>
      • equals

        public boolean equals(AMatrix a)
        Returns true if this matrix is exactly equal to another matrix
      • equalsArray

        public boolean equalsArray(double[] data,
                                   int offset)
        Description copied from interface: INDArray
        Returns true if the elements in this array exactly match the elements in the given array, in row-major order
        Specified by:
        equalsArray in interface INDArray
        Overrides:
        equalsArray in class AbstractArray<AVector>
        Parameters:
        data - Array of double element values to check for equality
        offset - Offset into the data array
        Returns:
      • equalsTranspose

        public boolean equalsTranspose(AMatrix a)
        Tests if this matrix is exactly equal to the transpose of another matrix
        Parameters:
        a -
        Returns:
      • equals

        public boolean equals(INDArray v)
        Description copied from interface: INDArray
        Checks if two arrays are equal exactly in terms of both value and shape Element equality checks are consistent with compareTo
        Specified by:
        equals in interface INDArray
        Overrides:
        equals in class AbstractArray<AVector>
      • epsilonEquals

        public final boolean epsilonEquals(AMatrix a)
        Returns true if this matrix is approximately equal to a second matrix, up to a default tolerance level
      • epsilonEquals

        public boolean epsilonEquals(AMatrix a,
                                     double epsilon)
      • innerProduct

        public AMatrix innerProduct(AMatrix a)
        Description copied from interface: IMatrix
        Computes the inner product of this matrix with another. Equivalent to matrix x matrix multiplication
        Specified by:
        innerProduct in interface IMatrix
        Returns:
      • innerProduct

        public Vector innerProduct(Vector v)
        Description copied from interface: IMatrix
        Transforms a dense source Vector using matrix multiplication (inner product).
        Specified by:
        innerProduct in interface IMatrix
        Returns:
        A new dense vector
      • transposeInnerProduct

        public AMatrix transposeInnerProduct(AMatrix s)
      • transposeInnerProduct

        public AMatrix transposeInnerProduct(Matrix s)
      • rowDotProduct

        public double rowDotProduct(int i,
                                    AVector a)
        Returns the dot product of a specific row with a vector. Unsafe operation: performs no bounds checking
        Parameters:
        i -
        a -
        Returns:
      • inverse

        public AMatrix inverse()
        Computes the inverse of a matrix. Returns null if the matrix is singular. Throws an Exception is the matrix is not square
        Specified by:
        inverse in interface IMatrix
        Parameters:
        m -
        Returns:
      • trace

        public double trace()
        Description copied from interface: IMatrix
        Computes the trace of a matrix, i.e. the sum of all elements on the leading diagonal
        Specified by:
        trace in interface IMatrix
        Returns:
      • diagonalProduct

        public double diagonalProduct()
        Computes the product of entries on the main diagonal of a matrix
        Specified by:
        diagonalProduct in interface IMatrix
        Returns:
      • isInvertible

        public boolean isInvertible()
        Description copied from interface: IMatrix
        Checks if this is an invertible matrix (i.e. a square matrix with a non-zero determinant)
        Specified by:
        isInvertible in interface IMatrix
        Returns:
        true if invertible, false otherwise
      • toVector

        public Vector toVector()
        Description copied from interface: INDArray
        Coerces the array into a flattened dense Vector, in row-major order. May return the same array if it is already a Vector instance.
        Specified by:
        toVector in interface INDArray
        Overrides:
        toVector in class AbstractArray<AVector>
      • toMatrix

        public Matrix toMatrix()
        Coerces the matrix to the standard mutable Matrix type in row major order. Performs a copy if necessary.
      • toMatrixTranspose

        public Matrix toMatrixTranspose()
        Coerces the transpose of a matrix to the standard mutable Matrix type in row major order. Performs a copy if necessary.
      • toNestedDoubleArrays

        public double[][] toNestedDoubleArrays()
        Description copied from interface: IMatrix
        Converts this matrix to nested double[][] array
        Specified by:
        toNestedDoubleArrays in interface IMatrix
        Returns:
      • asDoubleArray

        public double[] asDoubleArray()
        Description copied from interface: INDArray
        Returns the underlying double array representing the densely packed elements of this array. Modifications to this double array will change the original array. Returns null if there is no such array.
        Specified by:
        asDoubleArray in interface INDArray
        Overrides:
        asDoubleArray in class AbstractArray<AVector>
      • setApplyOp

        public void setApplyOp(Op op,
                               AMatrix a)
        Sets this matrix to the result of applying an operator to another matrix
        Parameters:
        op -
        a -
      • applyOp

        public void applyOp(Op2 op,
                            INDArray b)
        Description copied from interface: INDArray
        Applies a binary operator to this array and a second array. Broadcasts the second array to the shape of this array if required.
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<AVector>
      • applyOp

        public void applyOp(Op2 op,
                            AMatrix b)
      • applyOp

        public void applyOp(Op2 op,
                            AVector b)
      • applyOp

        public void applyOp(Op2 op,
                            double b)
        Description copied from interface: INDArray
        Applies a binary operator to this array and a double value. Works as if the double value was broadcast to the shape of this array.
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<AVector>
      • applyOp

        public void applyOp(IOperator op)
        Description copied from interface: INDArray
        Applies a unary operator to all elements of the array (in-place)
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AbstractArray<AVector>
        Parameters:
        op - The operator to apply to the array
      • reduce

        public double reduce(Op2 op,
                             double init)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the initial/previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AbstractArray<AVector>
      • reduce

        public double reduce(Op2 op)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AbstractArray<AVector>
      • reduceSlices

        public AVector reduceSlices(Op2 op,
                                    double init)
        Description copied from interface: INDArray
        Reduces each slice of the array by the given binary operator. Results are returned in a vector with one element for each slice. Uses the specified initial value for reduction of each slice.
        Specified by:
        reduceSlices in interface INDArray
        Overrides:
        reduceSlices in class AbstractArray<AVector>
      • add

        public void add(INDArray a)
        Description copied from interface: INDArray
        Adds all the elements of another array to this array, in an elementwise order.
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AbstractArray<AVector>
      • multiply

        public void multiply(AVector v)
        Multiply each row in this matrix by a vector. Mutates this matrix.
        Parameters:
        v -
      • multiply

        public void multiply(INDArray a)
        Description copied from interface: INDArray
        Multiplies all elements by the equivalent elements in a second array, i.e. performs elementwise multiplication. If matrix-style multiplication is required, use innerProduct instead.
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AbstractArray<AVector>
      • divide

        public void divide(AVector v)
        Divides every row of this matrix by the given vector
        Parameters:
        v -
      • sub

        public void sub(INDArray a)
        Description copied from interface: INDArray
        Subtracts all the elements of another array from this array, in an elementwise order.
        Specified by:
        sub in interface INDArray
        Overrides:
        sub in class AbstractArray<AVector>
      • add

        public void add(double d)
        Description copied from interface: INDArray
        Adds a double value to all elements in this array. Implementations may optimize the case of 0.0
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AbstractArray<AVector>
      • addAt

        public void addAt(int i,
                          int j,
                          double d)
        Description copied from interface: IMatrix
        Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operation
        Specified by:
        addAt in interface IMatrix
      • broadcastCloneLike

        public INDArray broadcastCloneLike(INDArray target)
        Description copied from interface: INDArray
        Creates a mutable clone of the array, broadcasted upwards if necessary to match the shape of the target. If no upwards broadcasting is required, returns a regular clone() of this array.
        Specified by:
        broadcastCloneLike in interface INDArray
        Overrides:
        broadcastCloneLike in class AbstractArray<AVector>
        Parameters:
        target - The target array
      • broadcastCopyLike

        public INDArray broadcastCopyLike(INDArray target)
        Description copied from interface: INDArray
        Creates a copy of the array, broadcasted upwards if necessary to match the shape of the target Like broadCastCloneLike, but does not guarantee a fully mutable clone - hence may be faster when used with immutable or specialized arrays
        Specified by:
        broadcastCopyLike in interface INDArray
        Overrides:
        broadcastCopyLike in class AbstractArray<AVector>
        Parameters:
        target - The target array
      • isPositiveDefinite

        public boolean isPositiveDefinite()
        Returns true if a matrix is positive definite
      • isDiagonal

        public boolean isDiagonal()
        Description copied from interface: IMatrix
        Returns true iff this matrix is a square diagonal matrix
        Specified by:
        isDiagonal in interface IMatrix
      • isSameShape

        public boolean isSameShape(AMatrix a)
        Returns true iff this matrix is exactly the same shape as another matrix
        Parameters:
        a -
        Returns:
      • isRectangularDiagonal

        public boolean isRectangularDiagonal()
        Description copied from interface: IMatrix
        Returns true iff this matrix is a diagonal matrix (might not be square)
        Specified by:
        isRectangularDiagonal in interface IMatrix
      • isSymmetric

        public boolean isSymmetric()
        Returns true if a matrix is symmetric
        Specified by:
        isSymmetric in interface IMatrix
        Returns:
      • isHermitian

        public final boolean isHermitian()
        Returns true if a matrix is Hermitian This is equivalent to isSymmetric(), since all Vectorz matrices have real values.
      • isUpperTriangular

        public boolean isUpperTriangular()
        Returns true if a matrix is upper triangular An upper triangular matrix is defined as having all elements equal to 0.0 where i > j
      • isLowerTriangular

        public boolean isLowerTriangular()
        Returns true if a matrix is lower triangular. A lower triangular matrix is defined as having all elements equal to 0.0 where i < j
      • upperBandwidthLimit

        public int upperBandwidthLimit()
        A limit on the upper bandwidth of the banded matrix. Actual upper bandwidth is guaranteed to be less than or equal to this value. Implementation should be O(1).
        Returns:
      • lowerBandwidthLimit

        public int lowerBandwidthLimit()
        A limit on the lower bandwidth of the banded matrix. Actual lower bandwidth is guaranteed to be less than or equal to this value. Implementation should be O(1).
        Returns:
      • bandLength

        public int bandLength(int band)
        Returns the length of a band of the matrix. Returns 0 if the band is outside the matrix.
        Parameters:
        band -
        Returns:
      • bandStartRow

        public final int bandStartRow(int band)
        Returns the start row of a given band.
        Parameters:
        band -
        Returns:
      • bandStartColumn

        public final int bandStartColumn(int band)
        Returns the start column of a given band.
        Parameters:
        band -
        Returns:
      • bandIndex

        public final int bandIndex(int i,
                                   int j)
        Returns the band index number for a specified position in the matrix.
        Parameters:
        i -
        j -
        Returns:
      • bandPosition

        public final int bandPosition(int i,
                                      int j)
        Returns the band position for a specified (i,j) index in the matrix.
        Parameters:
        i -
        j -
        Returns:
      • upperBandwidth

        public int upperBandwidth()
        Computes the upper bandwidth of a matrix, i.e. the number of bands above the leading diagonal that cover all non-zero values
        Returns:
      • lowerBandwidth

        public int lowerBandwidth()
        Computes the lower bandwidth of a matrix, i.e. the number of bands below the leading diagonal that cover all non-zero values
        Returns:
      • getBand

        public AVector getBand(int band)
        Gets a specific band of the matrix, as a view vector. The band is truncated at the edges of the matrix, i.e. it does not wrap around the matrix.
        Specified by:
        getBand in interface IMatrix
        Parameters:
        band -
        Returns:
      • getBandWrapped

        public AVector getBandWrapped(int band)
      • setRow

        public void setRow(int i,
                           AVector row)
        Sets a row in a matrix to the value specified by the given vector
        Parameters:
        i -
        row -
      • replaceRow

        public void replaceRow(int i,
                               AVector row)
        Replaces a row in a matrix, adding the row to the internal structure of the matrix. Will throw UnsupportedOperationException if not possible for the given matrix type.
        Parameters:
        i -
        row -
      • replaceColumn

        public void replaceColumn(int i,
                                  AVector row)
        Replaces a column in a matrix, adding the column to the internal structure of the matrix. Will throw UnsupportedOperationException if not possible for the given matrix type.
        Parameters:
        i -
        row -
      • setColumn

        public void setColumn(int i,
                              AVector col)
        Sets a column in a matrix.
        Parameters:
        i -
        row -
      • exactClone

        public abstract AMatrix exactClone()
        Description copied from interface: INDArray
        Creates a deep clone of an array, using the same class implementation as the original array
        Specified by:
        exactClone in interface INDArray
        Returns:
        A clone of the original array
      • immutable

        public INDArray immutable()
        Description copied from interface: INDArray
        Returns an immutable version of this array. May return the same array if already immutable. Guarantees a defensive copy if the array is mutable.
        Specified by:
        immutable in interface INDArray
        Overrides:
        immutable in class AbstractArray<AVector>
      • sparse

        public AMatrix sparse()
        Description copied from interface: INDArray
        Coerces this INDArray to a sparse format, without changing its element values. May return the same INDArray if already sparse. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned sparse array may not be fully mutable in all elements.
        Specified by:
        sparse in interface INDArray
        Overrides:
        sparse in class AbstractArray<AVector>
      • dense

        public AMatrix dense()
        Description copied from interface: INDArray
        Coerces this INDArray to a dense format, without changing its element values. May return the same INDArray if already dense. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned dense array may not be fully mutable in all elements.
        Specified by:
        dense in interface INDArray
        Overrides:
        dense in class AbstractArray<AVector>
      • denseClone

        public final Matrix denseClone()
        Description copied from interface: INDArray
        Creates a fully mutable dense clone of this array. Will always use a dense format, even if the array data is sparse.
        Specified by:
        denseClone in interface INDArray
        Overrides:
        denseClone in class AbstractArray<AVector>
      • validate

        public void validate()
        Description copied from interface: INDArray
        Validates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.
        Specified by:
        validate in interface INDArray
        Overrides:
        validate in class AbstractArray<AVector>
      • copyRowTo

        public void copyRowTo(int i,
                              double[] dest,
                              int destOffset)
        Copies the elements in a selected row of this matrix to a double array
        Parameters:
        i - The index of the selected row
        dest - Destination double[] array
        destOffset - Offset into destination array
      • copyColumnTo

        public void copyColumnTo(int j,
                                 double[] dest,
                                 int destOffset)
        Copies the elements in a selected row of this matrix to a double array
        Parameters:
        i - The index of the selected column
        dest - Destination double[] array
        destOffset -
      • addCopy

        public AMatrix addCopy(AMatrix a)
        Description copied from interface: IMatrix
        Adds another matrix to this matrix, returning a new matrix
        Specified by:
        addCopy in interface IMatrix
        Returns:
      • addCopy

        public AMatrix addCopy(AVector v)
        Description copied from interface: IMatrix
        Adds a vector to every row of this matrix, returning a new matrix
        Specified by:
        addCopy in interface IMatrix
        Returns:
      • addCopy

        public Matrix addCopy(AStridedMatrix a)
        Adds a dense matrix to this matrix, returning a new dense Matrix
        Parameters:
        m - A matrix. Not modified.
        Returns:
        True if any element in the matrix is NaN of Infinite.
      • hasUncountable

        public boolean hasUncountable()
        Checks to see if any element in the matrix is NaN of Infinite.
        Specified by:
        hasUncountable in interface INDArray
        Overrides:
        hasUncountable in class AbstractArray<AVector>
        Parameters:
        m - A matrix. Not modified.
        Returns:
        True if any element in the matrix is NaN of Infinite.
      • checkSquare

        public int checkSquare()
        Checks if a matrix is square. Returns the size if true, throws an exception otherwise;
        Returns:
      • checkColumn

        public int checkColumn(int column)
        Checks if the given column index is valid for this matrix. Throws an exception if not.
        Returns:
        the number of columns in this matrix
      • checkRow

        public int checkRow(int row)
        Checks if the given rows index is valid for this matrix. Throws an exception if not.
        Returns:
        the number of rows in this matrix
      • add2

        public void add2(AMatrix a,
                         AMatrix b)
        Description copied from interface: IMatrix
        Adds two matrices to this matrix. May be better optimised than adding both matrices individually.
        Specified by:
        add2 in interface IMatrix

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.