Documentation of 'mikera.matrixx.impl.DiagonalMatrix' Java class
DiagonalMatrix
mikera.matrixx.impl

Class DiagonalMatrix

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, INDArray, ISparse, IMatrix, IFastBands


    public final class DiagonalMatrix
    extends ADiagonalMatrix
    Specialised diagonal matrix class, with dense double[] array storage for the leading diagonal only. Not fully mutable - only the diagonal values can be changed
    See Also:
    Serialized Form
    • Constructor Detail

      • DiagonalMatrix

        public DiagonalMatrix(int dimensions)
    • Method Detail

      • createDimensions

        public static DiagonalMatrix createDimensions(int dims)
      • setSparse

        public void setSparse(AMatrix a)
        Description copied from class: AMatrix
        Sets the non-sparse elements in this matrix to the corresponding values in the source matrix
        Overrides:
        setSparse in class AMatrix
      • 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
        Overrides:
        trace in class ADiagonalMatrix
        Returns:
      • get

        public double get(int row,
                          int column)
        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 AMatrix
      • unsafeGet

        public double unsafeGet(int row,
                                int column)
        Description copied from class: AMatrix
        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.
        Overrides:
        unsafeGet in class AMatrix
        Returns:
      • set

        public void set(int row,
                        int column,
                        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 ADiagonalMatrix
      • unsafeSet

        public void unsafeSet(int row,
                              int column,
                              double value)
        Description copied from class: AMatrix
        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.
        Overrides:
        unsafeSet in class AMatrix
      • isMutable

        public boolean isMutable()
        Description copied from interface: INDArray
        Returns true if the INDArray is mutable (at least partially)
        Specified by:
        isMutable in interface INDArray
        Specified by:
        isMutable in class ADiagonalMatrix
      • isFullyMutable

        public 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 ADiagonalMatrix
      • 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 ABandedMatrix
      • multiplyCopy

        public DiagonalMatrix 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 AMatrix
        Parameters:
        factor - A scalar factor
        Returns:
        A new array, with all element values scaled by the given factor
      • rowDotProduct

        public double rowDotProduct(int i,
                                    AVector v)
        Description copied from class: AMatrix
        Returns the dot product of a specific row with a vector. Unsafe operation: performs no bounds checking
        Overrides:
        rowDotProduct in class ADiagonalMatrix
        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
        Overrides:
        isIdentity in class ADiagonalMatrix
        Returns:
        true if this matrix is a square identity matrix, false otherwise.
      • isBoolean

        public boolean isBoolean()
        Description copied from interface: INDArray
        Returns true if the array is boolean (contains only 0.0 or 1.0 values)
        Specified by:
        isBoolean in interface INDArray
        Overrides:
        isBoolean in class ADiagonalMatrix
      • isZero

        public boolean isZero()
        Description copied from class: AMatrix
        Returns true if the matrix is the zero matrix (all components zero)
        Specified by:
        isZero in interface INDArray
        Overrides:
        isZero in class ADiagonalMatrix
      • 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 ADiagonalMatrix
      • determinant

        public double determinant()
        Description copied from class: AMatrix
        Calculates the determinant of the matrix.
        Overrides:
        determinant in class ADiagonalMatrix
      • inverse

        public DiagonalMatrix inverse()
        Description copied from class: AMatrix
        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
        Overrides:
        inverse in class AMatrix
        Returns:
        A matrix which is the inverse of this matrix, or null if the inverse does not exist.
      • getLeadingDiagonal

        public Vector getLeadingDiagonal()
        Description copied from class: AMatrix
        Returns a vector view of the leading diagonal values of the matrix
        Specified by:
        getLeadingDiagonal in class ADiagonalMatrix
        Returns:
      • exactClone

        public DiagonalMatrix 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
        Specified by:
        exactClone in class ADiagonalMatrix
        Returns:
        A clone of the original array
      • 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 ADiagonalMatrix

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.