Class BidiagonalMatrix

    • Constructor Detail

      • BidiagonalMatrix

        public BidiagonalMatrix​(double[][] data)
        Constructs a bi-diagonal matrix from a 2D double[][] array. There are always two rows. The longer row is the main diagonal and has one more element. If the first row is shorter, it is an upper bi-diagonal matrix. If the second row is shorter, it is a lower bi-diagonal matrix. For example,
        
                 new double[][]{
                      {2, 5, 8, 11},
                      {1, 4, 7, 10, 13}
                  }
         
        gives \[ \begin{bmatrix} 1 & 2 & 0 & 0 & 0\\ 0 & 4 & 5 & 0 & 0\\ 0 & 0 & 7 & 8 & 0\\ 0 & 0 & 0 & 10 & 11\\ 0 & 0 & 0 & 0 & 13 \end{bmatrix} \] We allow null input when a diagonal is 0s, except for the main diagonal. For example,
        
                 new double[][]{
                      {1, 4, 7, 10, 13},
                      null
                  }
         
        gives \[ \begin{bmatrix} 1 & 0 & 0 & 0 & 0\\ 0 & 4 & 0 & 0 & 0\\ 0 & 0 & 7 & 0 & 0\\ 0 & 0 & 0 & 10 & 0\\ 0 & 0 & 0 & 0 & 13 \end{bmatrix} \] The following is not allowed because the dimension cannot be determined.
        
                 new double[][]{
                      null,
                      null
                  }
         
        This implementation treats a diagonal matrix as an upper bi-diagonal matrix.
        Parameters:
        data - the 2D array input
      • BidiagonalMatrix

        public BidiagonalMatrix​(int dim,
                                BidiagonalMatrix.BidiagonalMatrixType type)
        Constructs a 0 bi-diagonal matrix of dimension dim * dim.
        Parameters:
        dim - the dimension of the matrix
        type - the type of bi-diagonal matrix to create
      • BidiagonalMatrix

        public BidiagonalMatrix​(BidiagonalMatrix that)
        Copy constructor.
        Parameters:
        that - a bi-diagonal matrix
    • Method Detail

      • deepCopy

        public BidiagonalMatrix deepCopy()
        Description copied from interface: DeepCopyable
        The implementation returns an instance created from this by the copy constructor of the class, or just this if the instance itself is immutable.
        Returns:
        an independent (deep) copy of the instance
      • isUnreduced

        public boolean isUnreduced​(double epsilon)
        A bi-diagonal matrix is unreduced if it has no 0 on both the super and main diagonals.
        Parameters:
        epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0
        Returns:
        true if this is unreduced
      • scaled

        public BidiagonalMatrix scaled​(double c)
        Description copied from interface: Matrix
        Scale this matrix, A, by a constant.
        Parameters:
        c - a double
        Returns:
        cA
      • t

        public BidiagonalMatrix t()
        Description copied from interface: MatrixRing
        Get the transpose of this matrix. This is the involution on the matrix ring.
        Returns:
        the transpose of this matrix
      • ZERO

        public BidiagonalMatrix ZERO()
        Description copied from interface: MatrixRing
        Get a zero matrix that has the same dimension as this matrix.
        Returns:
        the 0 matrix
      • ONE

        public BidiagonalMatrix ONE()
        Description copied from interface: MatrixRing
        Get an identity matrix that has the same dimension as this matrix. For a non-square matrix, it zeros out the rows (columns) with index > nCols (nRows).
        Returns:
        an identity matrix
      • getDiagonal

        public DenseVector getDiagonal()
        Gets the main diagonal of the matrix.
        Returns:
        the main diagonal
      • getSuperDiagonal

        public DenseVector getSuperDiagonal()
        Gets the super-diagonal of the matrix.
        Returns:
        the super-diagonal
      • getSubDiagonal

        public DenseVector getSubDiagonal()
        Gets the sub-diagonal of the matrix.
        Returns:
        the sub-diagonal
      • nRows

        public int nRows()
        Description copied from interface: Table
        Gets the number of rows. Rows count from 1.
        Specified by:
        nRows in interface Table
        Returns:
        the number of rows
      • nCols

        public int nCols()
        Description copied from interface: Table
        Gets the number of columns. Columns count from 1.
        Specified by:
        nCols in interface Table
        Returns:
        the number of columns
      • set

        public void set​(int i,
                        int j,
                        double value)
                 throws MatrixAccessException
        Description copied from interface: MatrixAccess
        Set the matrix entry at [i,j] to a value. This is the only method that may change a matrix.
        Specified by:
        set in interface MatrixAccess
        Parameters:
        i - the row index
        j - the column index
        value - the value to set A[i,j] to
        Throws:
        MatrixAccessException - if i or j is out of range
      • getRow

        public Vector getRow​(int i)
        Description copied from interface: Matrix
        Get the specified row in the matrix as a vector.
        Specified by:
        getRow in interface Matrix
        Parameters:
        i - the row index
        Returns:
        the vector A[i, ]
      • getColumn

        public Vector getColumn​(int j)
        Description copied from interface: Matrix
        Get the specified column in the matrix as a vector.
        Specified by:
        getColumn in interface Matrix
        Parameters:
        j - the column index
        Returns:
        a vector A[, j]
      • multiply

        public Vector multiply​(Vector v)
        Description copied from interface: Matrix
        Right multiply this matrix, A, by a vector.
        Specified by:
        multiply in interface Matrix
        Parameters:
        v - a vector
        Returns:
        Av, a vector
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object