Class Matrix1

    • Field Detail

      • m00

        public double m00
        The only element in this matrix.
    • Constructor Detail

      • Matrix1

        public Matrix1()
        Creates a new identity matrix.
      • Matrix1

        public Matrix1​(double m00)
        Creates a new matrix initialized to the specified value.
        Parameters:
        m00 - The element in this matrix.
    • Method Detail

      • castOrCopy

        public static Matrix1 castOrCopy​(Matrix matrix)
                                  throws MismatchedMatrixSizeException
        Casts or copies the given matrix to a Matrix1 implementation. If the given matrix is already an instance of Matrix1, then it is returned unchanged. Otherwise this method verifies the matrix size, then copies the element in a new Matrix1 object.
        Parameters:
        matrix - the matrix to cast or copy, or null.
        Returns:
        the matrix argument if it can be safely casted (including null argument), or a copy of the given matrix otherwise.
        Throws:
        Mismatched­Matrix­Size­Exception - if the size of the given matrix is not 1×1.
      • getNumRow

        public final int getNumRow()
        Returns the number of rows in this matrix, which is always 1 in this implementation.
        Returns:
        always 1.
      • getNumCol

        public final int getNumCol()
        Returns the number of columns in this matrix, which is always 1 in this implementation.
        Returns:
        always 1.
      • getElement

        public final double getElement​(int row,
                                       int column)
        Retrieves the value at the specified row and column of this matrix. This method can be invoked when the matrix size or type is unknown. If the matrix is known to be an instance of Matrix1, then the m00 field can be read directly for efficiency.
        Specified by:
        get­Element in interface Matrix
        Specified by:
        get­Element in class Matrix­SIS
        Parameters:
        row - the row index, which can only be 0.
        column - the column index, which can only be 0.
        Returns:
        the current value.
      • setElement

        public final void setElement​(int row,
                                     int column,
                                     double value)
        Modifies the value at the specified row and column of this matrix. This method can be invoked when the matrix size or type is unknown. If the matrix is known to be an instance of Matrix1, then the m00 field can be set directly for efficiency.
        Parameters:
        row - the row index, which can only be 0.
        column - the column index, which can only be 0.
        value - the new value to set.
      • getElements

        public final double[] getElements()
        Returns all matrix elements in a flat, row-major (column indices vary fastest) array. The array length is 1.
        Overrides:
        get­Elements in class Matrix­SIS
        Returns:
        a copy of all current matrix elements in a row-major array.
      • setElements

        public final void setElements​(double[] elements)
        Sets all matrix elements from a flat, row-major (column indices vary fastest) array. The array length shall be 1.
        Specified by:
        set­Elements in class Matrix­SIS
        Parameters:
        elements - The new matrix elements in a row-major array.
        See Also:
        Matrices​.create(int, int, double[])
      • transpose

        public void transpose()
        For a 1×1 matrix, this method does nothing.
        Specified by:
        transpose in class Matrix­SIS
      • normalizeColumns

        public void normalizeColumns()
        Normalizes all columns in-place. For a 1×1 matrix, this method just sets unconditionally the m00 value to 1.
        Overrides:
        normalize­Columns in class Matrix­SIS
      • equals

        public boolean equals​(Object object)
        Returns true if the specified object is of type Matrix1 and all of the data members are equal to the corresponding data members in this matrix.
        Specified by:
        equals in interface Lenient­Comparable
        Overrides:
        equals in class Matrix­SIS
        Parameters:
        object - the object to compare with this matrix for equality.
        Returns:
        true if the given object is equal to this matrix.
        See Also:
        Comparison­Mode​.STRICT
      • hashCode

        public int hashCode()
        Returns a hash code value based on the data values in this object.
        Overrides:
        hash­Code in class Matrix­SIS
        Returns:
        a hash code value for this matrix.