Package linalg

Class Vector


public class Vector extends Matrix
This class supports the creation, manipulations, and operations of Vectors.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
     
    static int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty column vector.
    Vector​(double[] entries)
    Creates a column vector from the entries array.
    Vector​(double[] entries, int type)
    Creates a row/column vector depending on the value passed to type.
    Vector​(int size)
    Creates a column vector of specified size filled with zeros.
    Vector​(int[] entries)
    Creates a column vector from the entries array.
    Vector​(int[] entries, int type)
    Creates a row/column vector depending on the value passed to type.
    Vector​(int size, int type)
    Creates a row/column vector of specified size filled with zeros.
    Vector​(CNumber[] entries)
    Creates a column vector from the entries array.
    Vector​(CNumber[] entries, int type)
    Creates a row/column vector depending on the value passed to type.
    Vector​(Vector a)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default Matrix
    abs()
    Computes absolute value, element-wise, of a matrix.
    default Matrix
    add​(double a)
    Adds the value of a to all entries of matrix.
    default Matrix
    add​(Matrix B)
    Performs matrix addition on two matrices of the same dimensions.
    add​(Vector b)
    Adds two vectors element-wise and stores in a new vector.
    default Matrix
    Augments two matrices.
    default Matrix
    Finds an orthonormal basis for the column space of this matrix.
    default Matrix
    Computes the conjugate transpose of this matrix.
    default Matrix
    Conjugates a matrix element-wise.
    default CNumber
    det()
    Computes determinant of matrix.
    default Matrix
    Extracts diagonal elements from matrix.
    default Vector
    Extracts diagonal elements form matrix and stores in vector.
    default Matrix
    directSum​(Matrix... matrixList)
    Computes the matrix direct sum.
    default Matrix
    divRow​(int rowIndex, double divisor)
    Divides a specified row by a constant value.
    default Matrix
    divRow​(int rowIndex, CNumber divisor)
    Divides a specified row by a constant value.
    default Matrix[]
    eig()
    Computes the eigenvalues and associated eigenvectors for a square matrix.
    default Matrix
    Computes the eigenvalues of a matrix.
    default Matrix
    Computes the right eigenvectors of a matrix.
    default Matrix
    Performs element-wise division on two matrices of the same dimensions.
    default Matrix
    Performs element-wise multiplication of two matrices.
    default boolean
    equals​(Matrix B)
    Checks if two matrices are element-wise equivalent.
    default Matrix
    Computes reduced extended row-echelon form of matrix.
    default Matrix
    extend​(int n)
    Extends a row or column vector to form a matrix.
    default CNumber
    fip​(Matrix B)
    Computes the Frobenius inner product of two matrices A and B, <A, B>F.
    default Matrix
    Flattens an MxN matrix to a 1x(m*n) matrix.
    default Matrix
    flatten​(int axis)
    Flattens an MxN matrix to a 1x(m*n) or (m*n)x1 matrix depending on axis.
     
    default Matrix
    H()
    Computes the Hermation adjoint of a matrix.
    default Matrix
    Computes the Hermation adjoint of a matrix.
    default Matrix
    Converts a matrix similar to this matrix that is in upper Hessenburg form.
    default Matrix[]
    Converts a matrix similar to this matrix that is in upper Hessenburg form.
    Computes the infinity or maximum norm.
    Computs inner prodcut of two vectors.
    default Matrix
    inv()
    Computes the matrix inverse if it exists.
    default Matrix
    Computes the matrix inverse if it exists.
    default boolean
    Checks if matrix has at least one complex entry.
    default boolean
    Checks if this matrix is diagonal.
    default boolean
    Checks if a matrix is diagonalizable.
    default boolean
    Checks if the matrix is empty.
    default boolean
    Checks to see if a matrices rank is the same as its number of rows.
    default boolean
    Checks if matrix is hermation.
    default boolean
    isI()
    Checks if a matrix is an identity matrix.
    default boolean
    isInv​(Matrix B)
    Checks if B is the inverse of this matrix.
    default boolean
     
    default boolean
    Checks if this matrix is orthogonal.
    default boolean
     
    default boolean
    Checks if matrix is positive-definite.
    default boolean
    Checks if matrix is positive-semidefinite.
    default boolean
    Checks if matrix is real.
    default boolean
    Checks if matrix is self-adjoint.
    default boolean
     
    default boolean
    Checks if a matrix is skew-symmetric.
    default boolean
    Checks if the matrix is square.
    default boolean
    Checks if a matrix is symmetric.
    default boolean
    isSymmetric​(String skewOption)
    Checks if a matrix is symmetric or skew-symmetric depending on the skewOption.
    default int
    Checks if a matrix is Triangular.
    A triangular matrix has all zeros above and/or below the principle diagonal.

    - Diagonal: A square matrix is diagonal if every element above and below the principle diagonal is zero.
    - Lower Triangular: A square matrix is lower triangular if every element above the principle diagonal is zero.
    - Upper Triangular: A square matrix is upper triangular if every element below the principle diagonal is zero

    See
    - isTriU()
    - isTriL()
    - isDiagonal()
    default boolean
    Checks if matrix is lower triangular.
    default boolean
    Checks if matrix is upper triangular.
    default boolean
    Checks if this matrix is unitary.
    default boolean
    Checks if a given matrix is a column or row vector.
    default boolean
    Checks if this matrix has only zero entries.
    default Matrix
    Computes an orthonormal basis of the left null space of this matrix.
    default CNumber
    max()
    Finds the maximum value in the matrix.
    default CNumber
    Finds value with maximum magnitude.
    default double
    Finds the maximum real value in the matrix.
    default CNumber
    min()
    Finds the minimum value in the matrix.
    default CNumber
    Finds value with minimum magnitude.
    default double
    Finds the minimum real value in the matrix.
    default Matrix
    mult​(Matrix B)
    Performs matrix multiplication on two matrices.
    default Matrix
    multRow​(int rowIndex, double factor)
    Multiplies a specified row by a constant value.
    default Matrix
    multRow​(int rowIndex, CNumber factor)
    Multiplies a specified row by a constant value.
    Computes 2-norm (Euclidian norm) of vector.

    Also see
    - norm(double p)
    - infNorm()
    norm​(double p)
    Computes the p-norm of a vector.
    default CNumber
    norm​(double p, double q)
    Computes the Lp, q norm of this matrix.
    default int
    The rank of a matrix A is the dimension of the vector space spanned by the nullspace of this matrix.
    default Matrix
    Computes a orthonormal basis for the null space of this matrix.
    default int
    Number of columns in this matrix
    default int
    Number of rows in this matrix.
    Computes outer product of two vectors.
    default int
    The rank of a matrix A is the dimension of the vector space generated (or spanned) by its columns.
    default Matrix
    Creates a new matrix that contains the reciprocals of this matrix
    default Matrix
    ref()
    Computes row-echelon form of matrix.
    default Matrix
    removeCol​(int colIndex)
    Removes specified single column from matrix.
    default Matrix
    removeCols​(int... colIndices)
    Removes specified columns from matrix.
    default Matrix
    removeRow​(int rowIndex)
    Removes specified single row from matrix.
    default Matrix
    removeRows​(int... rowIndices)
    Removes specified rows from matrix.
    default Matrix
    reshape​(int newM, int newN)
     
    default Matrix
    reshape​(String newShape)
     
    default Matrix
    round​(int decimals)
    Rounds all entries of a matrix.
    default void
    roundToZero​(int decimals)
    Rounds values in this matrix within a specified number of decimals of zero to zero.
    default Matrix
    Finds an orthonormal basis for the row space of this matrix.
    default Matrix
    Computes reduced row-echelon form of matrix.
    default Matrix
    rref​(boolean partialPivoting)
    Computes reduced row-echelon form of matrix.
    default Matrix
    Computes reduced row-echelon form of matrix.
    default boolean
    Compares the dimensions, rows and columns, of two matrices.
    default boolean
    sameShape​(Matrix B, int code)
    Compares the dimensions of two matrices.
    scalDiv​(double value)
     
    scalDiv​(CNumber value)
     
    default Matrix
    scalMult​(double factor)
    Performs scalar multiplication of a matrix.
    default Matrix
    scalMult​(CNumber factor)
    Performs scalar multiplication of a matrix.
    default void
    set​(double value, int row, int col)
    Sets specified element in matrix to value.
    default void
    set​(CNumber value, int row, int col)
    Sets specified element in matrix to value.
    default void
    setCol​(double[] col, int colIndex)
    Sets specified column of this matrix to the values stored within the passed array.
    default void
    setCol​(CNumber[] col, int colIndex)
    Sets specified column of this matrix to the values stored within the passed array.
    default void
    setCol​(Vector col, int colIndex)
    Sets specified column of this matrix to the values stored within the passed column vector.
    default void
    setRow​(double[] row, int rowIndex)
    Sets specified row of this matrix to the values stored within the passed array.
    default void
    setRow​(CNumber[] row, int rowIndex)
    Sets specified row of this matrix to the values stored within the passed array.
    default void
    setRow​(Vector row, int rowIndex)
    Sets specified row of this matrix to the values stored within the passed row vector.
    default void
    setSlice​(int rowStart, int colStart, Matrix values)
    Sets a specified slice of this matrix to the values stored in the values matrix.
    default Matrix
    setSliceCopy​(int rowStart, int colStart, Matrix values)
    Creates a copy of this matrix and sets a specified slice of the copy to the values stored in the values matrix.
    default void
    setValues​(double[][] values)
    Copies values from array into matrix.
    default void
    setValues​(CNumber[][] values)
    Copies values from array into matrix.
    default String
    Shape of this matrix i.e.
    default Matrix
    Computes element wise square root of the matrix.
    default Matrix
    stack​(Matrix B)
    Stacks matrices along rows.
    default Matrix
    stack​(Matrix B, int axis)
    Stacks matrices along specified axis.
    default Matrix
    sub​(double a)
    Subtracts the value of a from all entries of matrix.
    default Matrix
    sub​(Matrix B)
    Performs matrix subtraction on two matrices of the same dimensions.
    sub​(Vector b)
    subtracts two vectors element-wise and stores in a new vector.
    default Matrix
    swapCols​(int colIndex1, int colIndex2)
    Swaps two columns in a matrix.
    default Matrix
    swapRows​(int rowIndex1, int rowIndex2)
    Swaps two rows in a matrix.
    default Matrix
    T()
    Transposes Matrix.
    Converts Vector to a column vector.
    Converts a vector to a like matrix object
    static Matrix
    Converts a vector to a matrix.
    Converts Vector to a row vector.
    Formats vector as a string.
    default Vector
    If possible, converts matrix to a Vector object.

    A matrix will be converted to a row vector if it contains only a single row.
    default CNumber
    tr()
    Computes the trace of a square matrix.
    default CNumber
    Computes the trace of square matrix.
    default Matrix
    Transposes Matrix.
    default Matrix
    Generates lower triangle of Matrix.
    default Matrix
    tril​(int k)
    Generates lower triangle of Matrix.
    default Matrix
    Generates upper triangle of Matrix.
    default Matrix
    triu​(int k)
    Generates upper triangle of Matrix.
    int
    Get the type of this vector

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Vector

      public Vector()
      Creates an empty column vector.
    • Vector

      public Vector(int size)
      Creates a column vector of specified size filled with zeros.
      Parameters:
      size - - size of the column vector
    • Vector

      public Vector(int size, int type)
      Creates a row/column vector of specified size filled with zeros.
      Parameters:
      size - - Size of the vector.
      type - - Specifies the type of vector. Pass a 0 for a column vector or a 1 for a row vector.
    • Vector

      public Vector(int[] entries)
      Creates a column vector from the entries array.
      Parameters:
      entries - - entries of the column vector.
    • Vector

      public Vector(int[] entries, int type)
      Creates a row/column vector depending on the value passed to type.
      Parameters:
      entries - - entries of the vector.
      type - - Specifies the type of vector. Pass a 0 for a column vector or a 1 for a row vector.
    • Vector

      public Vector(double[] entries)
      Creates a column vector from the entries array.
      Parameters:
      entries - - entries of the column vector.
    • Vector

      public Vector(double[] entries, int type)
      Creates a row/column vector depending on the value passed to type.
      Parameters:
      entries - - entries of the vector.
      type - - Specifies the type of vector. Pass a 0 for a column vector or a 1 for a row vector.
    • Vector

      public Vector(CNumber[] entries)
      Creates a column vector from the entries array.
      Parameters:
      entries - - entries of the column vector.
    • Vector

      public Vector(CNumber[] entries, int type)
      Creates a row/column vector depending on the value passed to type.
      Parameters:
      entries - - entries of the vector.
      type - - Specifies the type of vector. Pass a 0 for a column vector or a 1 for a row vector.
    • Vector

      public Vector(Vector a)
  • Method Details

    • toMatrix

      public static Matrix toMatrix(Vector v)
      Converts a vector to a matrix.
      Parameters:
      v - - vector to convert to matrix
      Returns:
      Matrix of vector. If the vector is a row vector the matrix will have one row and the same number of columns as entries in the vector. If the vector is a column vector the matrix will have one column and the same number of rows as entries in the vector.
    • toRowVector

      public Vector toRowVector()
      Converts Vector to a row vector.
      Returns:
      If the vector is already a row vector, then the same vector is returned. If the vector is a column vecctor, then a new row vector with identical entires to the column vector is returned.
    • toColVector

      public Vector toColVector()
      Converts Vector to a column vector.
      Returns:
      If the vector is already a column vector, then the same vector is returned. If the vector is a row vecctor, then a new column vector with identical entires to the row vector is returned.
    • vectorType

      public int vectorType()
      Get the type of this vector
      Returns:
      Returns 0 for a column vector, 1 for a row vector.
    • innerProduct

      public CNumber innerProduct(Vector b)
      Computs inner prodcut of two vectors. Note, vectors do not have to be the same type. That is, any mixture of row and column vectors is fine as long as they have the same number of entries.
      Parameters:
      b - - Vector to compute inner product with.
      Returns:
      Inner product of this vector with b.
    • outerProduct

      public Matrix outerProduct(Vector b)
      Computes outer product of two vectors. The result of vector outer products is a matrix.

      Vectors must be of oposite types. That is, exactly one of the two vectors must be a row vector and exactly one of the two vectors must be a column vector.

      In this method, vectors are treated as matrices with 1 row or 1 column depending on the vector type. Then, Matrix.mult(Matrix B) is used.
      Parameters:
      b - - Vector to compute outer product with.
      Returns:
      Outer product of this vector with b.
    • norm

      public CNumber norm()
      Computes 2-norm (Euclidian norm) of vector.

      Also see
      - norm(double p)
      - infNorm()
      Returns:
      2-norm of this vector. This will be a real value.
    • norm

      public CNumber norm(double p)
      Computes the p-norm of a vector. If p=1, this is called the Taxicab norm or Manhattan norm.

      If p=2, this is equivalent to norm()
      which is the euclidian norm. If p is Double.POSITIVE_INFINITY this is equivalent to
      Parameters:
      p - - norm value. Must satisfy p >= 1 and can be Double.POSITIVE_INFINITY.
      Returns:
    • infNorm

      public CNumber infNorm()
      Computes the infinity or maximum norm. That is, the value with the maximum magnitude. If the vector is real this is equivalent to the maximum absolute value.

      Also see
      - norm(double p)
      - norm(double)
      Returns:
      The infinity or maximum norm of this vector.
    • getEntries

      public CNumber[] getEntries()
      Returns:
    • add

      public Vector add(Vector b)
      Adds two vectors element-wise and stores in a new vector. Vectors must be of the same type.
      Parameters:
      b - - Vector to add to this vector
      Returns:
      Result of vector addition.
    • sub

      public Vector sub(Vector b)
      subtracts two vectors element-wise and stores in a new vector. Vectors must be of the same type.
      Parameters:
      b - - Vector to subtract
      Returns:
      Result of vector subtraction.
    • scalDiv

      public Vector scalDiv(CNumber value)
    • scalDiv

      public Vector scalDiv(double value)
    • toMatrix

      public Matrix toMatrix()
      Converts a vector to a like matrix object
      Returns:
    • toString

      public String toString()
      Formats vector as a string.
      Overrides:
      toString in class Matrix
      Returns:
      This vector formated as a string
    • add

      default Matrix add(Matrix B)
      Performs matrix addition on two matrices of the same dimensions.
      Parameters:
      B - - matrix to add to the instance matrix
      Returns:
      result of matrix addition
    • add

      default Matrix add(double a)
      Adds the value of a to all entries of matrix.
      Parameters:
      a - Value to add to matrix.
      Returns:
      A new matrix with the value of a added to this matrix.
    • sub

      default Matrix sub(Matrix B)
      Performs matrix subtraction on two matrices of the same dimensions.
      Parameters:
      B - - matrix to subtract to the instance matrix
      Returns:
      result of matrix subtraction
    • sub

      default Matrix sub(double a)
      Subtracts the value of a from all entries of matrix.
      Parameters:
      a - Value to subtract from matrix.
      Returns:
      A new matrix with the value of a added to this matrix.
    • mult

      default Matrix mult(Matrix B)
      Performs matrix multiplication on two matrices. The instance matrix must have the same number of columns as the rows of B. If the instance matrix is a kxm matrix and B is a m x n matrix then the result will be a k x n matrix.
      Parameters:
      B - - matrix to multiply to the instance matrix
      Returns:
      result of matrix multiplication
    • elemMult

      default Matrix elemMult(Matrix B)
      Performs element-wise multiplication of two matrices.
      Parameters:
      B - - matrix to multiply element-wise to this matrix.
      Returns:
      result of element-wise matrix multiplication.
      Throws:
      IllegalArgumentException - If matrices do not have the same dimension.
    • scalMult

      default Matrix scalMult(double factor)
      Performs scalar multiplication of a matrix.
      Parameters:
      factor - - value to multiply this matrix by.
      Returns:
      The scalar multiplication of the matrix and the factor.
    • scalMult

      default Matrix scalMult(CNumber factor)
      Performs scalar multiplication of a matrix.
      Parameters:
      factor - - value to multiply matrix by.
      Returns:
      The scalar multiplication of the matrix and the factor.
    • elemDiv

      default Matrix elemDiv(Matrix B)
      Performs element-wise division on two matrices of the same dimensions.
      Parameters:
      B - - matrix to divide element-wise the instance matrix with.
      Returns:
      result of element-wise matrix multiplication.
    • fip

      default CNumber fip(Matrix B)
      Computes the Frobenius inner product of two matrices A and B, <A, B>F.
      Parameters:
      B - - Second matrix for the Frobenius inner product.
      Returns:
      the Frobenius inner product.
    • directSum

      default Matrix directSum(Matrix... matrixList)
      Computes the matrix direct sum. That is, a block diagonal matrix containing all matrices from a set of matrices.
      Parameters:
      matrixList - - List of matrices from which to compute the matrix direct sum.
      Returns:
      The result of direct summing the matrices in matrixList to this matrix.
    • sqrt

      default Matrix sqrt()
      Computes element wise square root of the matrix. All square roots are the positive root or, in the case of complex entries, the root with positive real part.
      Returns:
      The element-wise square root of this matrix.
    • abs

      default Matrix abs()
      Computes absolute value, element-wise, of a matrix. If any of the matrix cells are complex, this will result in the magnitude of that value.
      Returns:
      - element-wise absolute value of matrix.
    • transpose

      default Matrix transpose()
      Transposes Matrix. Same as Matrix.T()
      Returns:
      transpose of matrix
    • T

      default Matrix T()
      Transposes Matrix. Same as Matrix.transpose()
      Returns:
      transpose of matrix
    • conjugate

      default Matrix conjugate()
      Conjugates a matrix element-wise.
      Returns:
      Conjugate of matrix
    • conjT

      default Matrix conjT()
      Computes the conjugate transpose of this matrix.

      This method is the same as hermAdjoint() and H().
      Returns:
      The conjugate transpose of this matrix.
    • hermAdjoint

      default Matrix hermAdjoint()
      Computes the Hermation adjoint of a matrix. This is the transpose of the conjugate matrix.

      This method is the same as conjT() and H().
      Returns:
      adjoint of matrix.
    • H

      default Matrix H()
      Computes the Hermation adjoint of a matrix. This is the transpose of the conjugate matrix.

      This method is the same as conjT() and hermAdjpint().
      Returns:
      adjoint of matrix.
    • det

      default CNumber det()
      Computes determinant of matrix. If the matrix has any complex entries, this may be a complex value. Note: Currently this method only works for real matirces.
      Returns:
      determinant of matrix.
    • stack

      default Matrix stack(Matrix B)
      Stacks matrices along rows. Both matrices must have the same number of columns Also see stack(Matrix B, int axis)
      Parameters:
      B -
      Returns:
    • stack

      default Matrix stack(Matrix B, int axis)
      Stacks matrices along specified axis. Axis 0 will stack matrices along the rows. Axis 1 will stack matrices along columns. Note: To stack matrices along axis 0 they must have the same number of columns. To stack matrices along axis 1 they must have the same number of rows.
      Parameters:
      B - - Matrix to stack
      axis - - Axis along which to stack matrices.
      Returns:
      Returns A and B stacked along specified axis.
    • augment

      default Matrix augment(Matrix B)
      Augments two matrices. This is the same as stack(B, 1)
      Parameters:
      B - - Matrix to augment to this matrix.
      Returns:
      The matrix B augmented to this matrix.
    • ref

      default Matrix ref()
      Computes row-echelon form of matrix. This will be an upper-triangular matrix.
       A matrix is in row-echelon form if:
        - The first non-zero element in each row, called the leading entry (also called the pivot), is 1.
        - The pivot of a nonzero row is always strictly to 
          the right of the leading coefficient of the row above it.
        - Rows with all zero elements, if any, are below rows having a non-zero element.
       
      A matrix can be transformed into a row equivalent matrix in row-echelon form using row operations. This is done using Gaussian (Gauss-Jordan) elimination.

      Also see rref() for reduced row-echelon form.
      Returns:
      Row-echelon form of matrix
    • rref

      default Matrix rref(boolean partialPivoting)
      Computes reduced row-echelon form of matrix.
       A matrix is in reduced row-echelon form if:
      - It is in row-echelon form. This is, ~ The first non-zero element in each row, called the leading entry (also called the pivot), is 1. ~ The pivot of a nonzero row is always strictly to the right of the leading coefficient of the row above it. ~ Rows with all zero elements, if any, are below rows having a non-zero element.
      - The pivot in each row is the only non-zero entry in its column.
      A matrix can be transformed into a row eqivalent matrix in reduced row-echelon form using row operations. This is done using Gaussian (Gauss-Jordan) elimination.

      Parameters:
      partialPivoting - - Falg for use of partial pivoting.
        - If true then the rref will be computed using partial pivoting.
                  ~ This is equivalent to the method rref().
        - If false then the rref will be computed WITHOUT using partial pivoting.
       
      Returns:
    • rref

      default Matrix rref()
      Computes reduced row-echelon form of matrix. This is done using partial pivoting.
       A matrix is in reduced row-echelon form if:
      - It is in row-echelon form. This is, ~ The first non-zero element in each row, called the leading entry (also called the pivot), is 1. ~ The pivot of a nonzero row is always strictly to the right of the leading coefficient of the row above it. ~ Rows with all zero elements, if any, are below rows having a non-zero element.
      - The pivot in each row is the only non-zero entry in its column.
      A matrix can be transformed into a row eqivalent matrix in reduced row-echelon form using row operations. This is done using Gaussian (Gauss-Jordan) elimination.

      Also see ref() for row-echelon form.
      Returns:
      Row-echelon form of matrix.
    • rrefNoPivot

      default Matrix rrefNoPivot()
      Computes reduced row-echelon form of matrix. This is done WITHOUT using partial pivoting.
       A matrix is in reduced row-echelon form if:
      - It is in row-echelon form. This is, ~ The first non-zero element in each row, called the leading entry (also called the pivot), is 1. ~ The pivot of a nonzero row is always strictly to the right of the leading coefficient of the row above it. ~ Rows with all zero elements, if any, are below rows having a non-zero element.
      - The pivot in each row is the only non-zero entry in its column.
      A matrix can be transformed into a row eqivalent matrix in reduced row-echelon form using row operations. This is done using Gaussian (Gauss-Jordan) elimination.

      Also see ref() for row-echelon form.
      Returns:
      Row-echelon form of matrix.
    • erref

      default Matrix erref()
      Computes reduced extended row-echelon form of matrix. That is, a Matrix with the same number of rows is augmented with this matrix and then this augmented matrix is put into reduced row-echelon form.
      Returns:
      Returns extended row-echelon form of this matrix.
    • trace

      default CNumber trace()
      Computes the trace of square matrix. That is, the sum of the entries along the principle diagonal.

      This method is the same as tr().
      Returns:
      trace of this matrix.
    • tr

      default CNumber tr()
      Computes the trace of a square matrix. That is, the sum of the entries along the principle diagonal.

      This method is the same as trace().
      Returns:
      trace of this matrix.
    • rank

      default int rank()
      The rank of a matrix A is the dimension of the vector space generated (or spanned) by its columns. This is always an integer. This corresponds to the maximal number of linearly independent columns of A. This, in turn, is identical to the dimension of the vector space spanned by its rows
      Returns:
      Returns the rank of this matrix.
    • nullity

      default int nullity()
      The rank of a matrix A is the dimension of the vector space spanned by the nullspace of this matrix. The nullify is always an integer.
      Returns:
      Returns the rank of this matrix.
    • inverse

      default Matrix inverse()
      Computes the matrix inverse if it exists. This is done by first computing the QR decomposition The inverse of a Matrix A is A-1 satisfying AA-1=I where I is the appropriately sized Identity matrix.
      Returns:
      The inverse of this matrix.
    • inv

      default Matrix inv()
      Computes the matrix inverse if it exists. This is done by first computing the QR decomposition The inverse of a Matrix A is A-1 satisfying AA-1=I where I is the appropriately sized Identity matrix.
      Returns:
      The inverse of this matrix.
    • recep

      default Matrix recep()
      Creates a new matrix that contains the reciprocals of this matrix
      Returns:
      new matrix that contains the reciprocals of this matrix
    • reshape

      default Matrix reshape(String newShape)
    • reshape

      default Matrix reshape(int newM, int newN)
    • flatten

      default Matrix flatten()
      Flattens an MxN matrix to a 1x(m*n) matrix. Each row of the Matrix is appended to the end of the first row of the Matrix in order.
      Returns:
    • flatten

      default Matrix flatten(int axis)
      Flattens an MxN matrix to a 1x(m*n) or (m*n)x1 matrix depending on axis.
      Parameters:
      axis - - axis along which to flatten
      Returns:
    • extend

      default Matrix extend(int n)
      Extends a row or column vector to form a matrix. That is, for a row vector,
      Parameters:
      n - Number of times to make the extension. That is, for a row vector with m entries, a matrix of shape n-by-m will be formed. For a column vector with m entries, a matrix of shape m-by-n will be formed.
      Returns:
      The extended matrix formed from the vector.
      Throws:
      IllegalCallerException - if the caller is not a Vector
    • setValues

      default void setValues(CNumber[][] values)
      Copies values from array into matrix. The given array must have the same dimensions as the matrix object. This will replace any current values in the matrix.
      Parameters:
      values - - Values to copy into array
    • setValues

      default void setValues(double[][] values)
      Copies values from array into matrix. The given array must have the same dimensions as the matrix object. A will replace any current values in the matrix.
      Parameters:
      values - - Values to copy into array
    • set

      default void set(CNumber value, int row, int col)
      Sets specified element in matrix to value. A will replace the current value at that index.
      Parameters:
      value - - value to insert into matrix
      row - - row to insert value
      col - - column to insert value
    • set

      default void set(double value, int row, int col)
      Sets specified element in matrix to value. A will replace the current value at that index.
      Parameters:
      value - - value to insert into matrix
      row - - row index to insert value
      col - - column index to insert value
    • setCol

      default void setCol(Vector col, int colIndex)
      Sets specified column of this matrix to the values stored within the passed column vector.

      Also see
      setCol(CNumber[] col, int colIndex)
      setCol(double[] col, int colIndex)
      Parameters:
      col - - Column vector containing the new entries for the specified column.
      colIndex - - Index of new column to set.
      Throws:
      IllegalArgumentException - if the vector is not a column vector or if the vector and matrix do not have the same number of rows.
    • setCol

      default void setCol(CNumber[] col, int colIndex)
      Sets specified column of this matrix to the values stored within the passed array.

      Also see
      setCol(Vector col, int colIndex)
      setCol(double[] col, int colIndex)
      Parameters:
      col - - array containing the new entries for the specified column.
      colIndex - - Index of new column to set.
      Throws:
      IllegalArgumentException - if the array of values has a different length then the number of rows in the matrix.
    • setCol

      default void setCol(double[] col, int colIndex)
      Sets specified column of this matrix to the values stored within the passed array. Also see
      setCol(Vector col, int colIndex)
      setCol(CNumber[] col, int colIndex)
      Parameters:
      col - - array containing the new entries for the specified column.
      colIndex - - Index of new column to set.
      Throws:
      IllegalArgumentException - if the array of values has a different length then the number of rows in the matrix.
    • setRow

      default void setRow(Vector row, int rowIndex)
      Sets specified row of this matrix to the values stored within the passed row vector.

      Also see
      setRow(CNumber[] col, int colIndex)
      setRow(double[] col, int colIndex)
      Parameters:
      row - - row vector containing the new entries for the specified column.
      rowIndex - - Index of new row to set.
      Throws:
      IllegalArgumentException - if the vector is not a row vector or if the vector and matrix do not have the same number of columns.
    • setRow

      default void setRow(CNumber[] row, int rowIndex)
      Sets specified row of this matrix to the values stored within the passed array.

      Also see
      setRow(Vector col, int colIndex)
      setRow(double[] col, int colIndex)
      Parameters:
      row - - array containing the new entries for the specified column.
      rowIndex - - Index of new column to set.
      Throws:
      IllegalArgumentException - if the array of values has a different length then the number of columns in the matrix.
    • setRow

      default void setRow(double[] row, int rowIndex)
      Sets specified row of this matrix to the values stored within the passed array.

      Also see
      setRow(Vector col, int colIndex)
      setRow(CNumber[] col, int colIndex)
      Parameters:
      row - - array containing the new entries for the specified column.
      rowIndex - - Index of new column to set.
      Throws:
      IllegalArgumentException - if the array of values has a different length then the number of columns in the matrix.
    • setSliceCopy

      default Matrix setSliceCopy(int rowStart, int colStart, Matrix values)
      Creates a copy of this matrix and sets a specified slice of the copy to the values stored in the values matrix. Together the parameters rowStart and colStart define the upper left corner of the slice to set.

      If the values matrix does not fit within this matrix, an error will be thrown.

      If want to adjust this matrix instance directly see setSlice(Matrix values, int rowStart, int colStart)
      Returns:
    • setSlice

      default void setSlice(int rowStart, int colStart, Matrix values)
      Sets a specified slice of this matrix to the values stored in the values matrix. Together the parameters rowStart and colStart define the upper left corner of the slice to set.

      If the values matrix does not fit within this matrix, an error will be thrown.

      If you do not want to adjust this matrix instance see setSliceCopy(Matrix values, int rowStart, int colStart)
      Parameters:
      rowStart - - Row on original matrix to place top row of values matrix
      colStart - - Column on original matrix to place left-most column of values matrix
      values - - New values to set within specified slice.
    • removeRow

      default Matrix removeRow(int rowIndex)
      Removes specified single row from matrix. To remove more than one row at a time see removeRows(int... rowIndices).
      Parameters:
      rowIndex - - Index of row to remove.
      Returns:
      Matrix with the specified row removed.
    • removeRows

      default Matrix removeRows(int... rowIndices)
      Removes specified rows from matrix. If k row indices are specified for a mxn matrix, the resulting matrix will have shape (m-k)xn. Also see removeRow(int rowIndex).
      Parameters:
      rowIndices - - list of row indices to remove from matrix.
      Returns:
      Matrix with specified rows removed
    • removeCol

      default Matrix removeCol(int colIndex)
      Removes specified single column from matrix. To remove more than one column at a time see removeCols(int... colIndices).
      Parameters:
      colIndex - - Index of column to remove.
      Returns:
      Matrix with the specified column removed.
    • removeCols

      default Matrix removeCols(int... colIndices)
      Removes specified columns from matrix. If k column indices are specified for a mxn matrix, the resulting matrix will have shape m-by-(n-k). Also see removeCol(int colIndex)
      Parameters:
      colIndices - - list of column indices to remove from matrix.
      Returns:
      Matrix with specified columns removed
    • tril

      default Matrix tril()
      Generates lower triangle of Matrix. That is, all values above the middle diagonal will be zeroed. Also see tril(int k)
      Returns:
      Lower triangle of Matrix.
    • tril

      default Matrix tril(int k)
      Generates lower triangle of Matrix. That is, all values above the kth diagonal will be zeroed. Also see tril()
      Parameters:
      k - - diagonal above which to zero. k=0 whould be middile diagonal, k=-1 would be the diagonal to the left of the middle diagonal, and k=1 would be the diagonal to the right of the middle diagonal.
      Returns:
      Lower triangle of Matrix.
    • triu

      default Matrix triu()
      Generates upper triangle of Matrix. That is, all values above the middle diagonal will be zeroed. Also see triu(int k)
      Returns:
      upper triangle of Matrix.
    • triu

      default Matrix triu(int k)
      Generates upper triangle of Matrix. That is, all values below the kth diagonal will be zeroed. Also see triu()
      Parameters:
      k - - diagonal above which to zero. k=0 would be middle diagonal, k=-1 would be the diagonal to the left of the middle diagonal, and k=1 would be the diagonal to the right of the middle diagonal.
      Returns:
      upper triangle of Matrix.
    • diag

      default Matrix diag()
      Extracts diagonal elements from matrix.
      Returns:
      Returns an equivalently sized matrix containing only the diagonal elements of this matrix.
    • diagAsVector

      default Vector diagAsVector()
      Extracts diagonal elements form matrix and stores in vector.
      Returns:
      Column vector containing diagonal elements of this matrix.
    • hessu

      default Matrix hessu()
      Converts a matrix similar to this matrix that is in upper Hessenburg form. A matrix is in upper Hessenburg form if all entries below the first subdiagonal are zero. Two n-by-n matrices A and B are similar if there exists an invertible n-by-n matrix P, such that B=P-1AP. Similar matrices share many properties including the same eigenvalues.
      Returns:
      A matrix similar to this matrix which is in upper Hessenburg form.
    • hessuV

      default Matrix[] hessuV()
      Converts a matrix similar to this matrix that is in upper Hessenburg form. A matrix is in upper Hessenburg form if all entries below the first subdiagonal are zero. Two n-by-n matrices A and B are similar if there exists an invertible n-by-n matrix P, such that B=P-1AP. Similar matrices share many properties including the same eigenvalues.
      Returns:
      A matrix similar to this matrix which is in upper Hessenburg form.
    • swapRows

      default Matrix swapRows(int rowIndex1, int rowIndex2)
      Swaps two rows in a matrix.
      Parameters:
      rowIndex1 - - Index of first row to be swapped.
      rowIndex2 - - Index of second row to be swapped.
      Returns:
      Matrix with specified rows swapped.
    • swapCols

      default Matrix swapCols(int colIndex1, int colIndex2)
      Swaps two columns in a matrix.
      Parameters:
      colIndex1 - - Index of first column to be swapped.
      colIndex2 - - Index of second column to be swapped.
      Returns:
      Matrix with specified columns swapped.
    • multRow

      default Matrix multRow(int rowIndex, CNumber factor)
      Multiplies a specified row by a constant value.
      Parameters:
      factor - - number to multiply row by.
      Returns:
      Matrix with specified row multiplied by the factor.
    • multRow

      default Matrix multRow(int rowIndex, double factor)
      Multiplies a specified row by a constant value.
      Parameters:
      factor - - number to multiply row by.
      Returns:
      Matrix with specified row multiplied by the factor
    • divRow

      default Matrix divRow(int rowIndex, CNumber divisor)
      Divides a specified row by a constant value.
      Parameters:
      divisor - - number to divide row by.
      Returns:
      Matrix with specified row divided by the divisor.
    • divRow

      default Matrix divRow(int rowIndex, double divisor)
      Divides a specified row by a constant value.
      Parameters:
      divisor - - number to divide row by.
      Returns:
      Matrix with specified row divided by the divisor.
    • toVector

      default Vector toVector()
      If possible, converts matrix to a Vector object.

      A matrix will be converted to a row vector if it contains only a single row.
      A matrix will be converted to a column vector if it contains only a single column.
      If a matrix contains only one row and one column or is empty, then it will be converted to a column vector by default.
      Returns:
      Vector equivalent of matrix.
    • round

      default Matrix round(int decimals)
      Rounds all entries of a matrix. If entry is complex, both the real and imaginary part will be rounded.
      Parameters:
      decimals - - Number of decimals to round number to.
      Returns:
      Returns copy of Matrix A with entries rounded to Specified number of decimal places.
    • roundToZero

      default void roundToZero(int decimals)
      Rounds values in this matrix within a specified number of decimals of zero to zero.
      Parameters:
      decimals - - Number of decimals
    • numCols

      default int numCols()
      Number of columns in this matrix
      Returns:
      Number of rows in matrix.
    • numRows

      default int numRows()
      Number of rows in this matrix.
      Returns:
      Number of columns in matrix.
    • shape

      default String shape()
      Shape of this matrix i.e. number of rows and columns.
      Returns:
      Returns shape of this matrix shape as String e.g. "m x n".
    • isSquare

      default boolean isSquare()
      Checks if the matrix is square. That is, does the matrix have the same number of rows and columns?
      Returns:
      True if the matrix is square, false otherwise.
    • isEmpty

      default boolean isEmpty()
      Checks if the matrix is empty. That is, does the matrix have exactly zero entries?
      Returns:
      True if the matrix is empty, false otherwise.
    • min

      default CNumber min()
      Finds the minimum value in the matrix. If the matrix is complex, the value with the smallest magnitude will be returned. If the matrix is real, the smallest real number will be returned.
      Also see minReal() and minComplex()
      Returns:
      minimum value of this matrix
    • minReal

      default double minReal()
      Finds the minimum real value in the matrix. If the matrix contains non-real values, the imaginary component will be ignored.
      Also see min() and minComplex()
      Returns:
      Returns minimum real value of this matrix.
    • max

      default CNumber max()
      Finds the maximum value in the matrix. If the matrix is complex, the value with the largest magnitude will be returned. If the matrix is real, the largest real number will be returned.
      Also see maxReal() and maxComplex()
      Returns:
      Returns maximum value of this matrix.
    • maxReal

      default double maxReal()
      Finds the maximum real value in the matrix. If the matrix contains any non-real entries, the imaginary component will be ignored.
      Also see max() and maxComplex()
      Returns:
      Returns maximum real value of this matrix.
    • minComplex

      default CNumber minComplex()
      Finds value with minimum magnitude. Also see min() and minReal()
      Returns:
      Returns value with minimum magnitude in this matrix.
    • maxComplex

      default CNumber maxComplex()
      Finds value with maximum magnitude. Also see max() and maxReal()
      Returns:
      Returns value with maximum magnitude in this matrix.
    • isReal

      default boolean isReal()
      Checks if matrix is real. That is, the matrix only has real entries.
      Returns:
      True if matrix has no complex entries. Otherwise, false.
    • isComplex

      default boolean isComplex()
      Checks if matrix has at least one complex entry.
      Returns:
      True if matrix has at least one non-real entry. Otherwise, false.
    • isVector

      default boolean isVector()
      Checks if a given matrix is a column or row vector. A column vector will be a a matrix of shape mx1 and a row vector will be a matrix of shape 1xn
      Returns:
      True if matrix is a column or row vector, otherwise returns false.
    • isSelfAdjoint

      default boolean isSelfAdjoint()
      Checks if matrix is self-adjoint. That is, if the matrix is equal to its own conjugate transpose.

      Same as isHermation().
      Returns:
      True if the matrix is self-adjoint. Otherwise, returns false.
    • isHermation

      default boolean isHermation()
      Checks if matrix is hermation. That is, if the matrix is equal to its own conjugate transpose.

      Same as isSelfAdjoint().
      Returns:
      True if the matrix is hermation. Otherwise, returns false.
    • isSymmetric

      default boolean isSymmetric()
      Checks if a matrix is symmetric.

      For an square matrix A, A is symmetric if and only if A[i][j] = A[j][i] for all i, j. That is, if A is equal its own transpose, then it is symmetric.

      Also see isSkewSymmetric() and isSymmetric(String skewOption)
      Returns:
      True if this matrix is symmetric, false otherwise.
    • isSkewSymmetric

      default boolean isSkewSymmetric()
      Checks if a matrix is skew-symmetric.

      For an square matrix A, A is skew-symmetric if and only if A[i][j] = -A[j][i] for all i, j. That is, if A is equal to the negative of its own transpose, then it is skew-symmetric.

      Also see isSymmetric() and isSymmetric(String skewOption)
      Returns:
      True if this matrix is symmetric, false otherwise.
    • isSymmetric

      default boolean isSymmetric(String skewOption)
      Checks if a matrix is symmetric or skew-symmetric depending on the skewOption.

      - If skewOption is passed "skew", this method is identical to isSkewSymmetric().
      - If skewOption is passed "no-skew", this method is identical to isSymmetric().

      For an square matrix A, A is symmetric if and only if A[i][j] = A[j][i] for all i, j. That is, if A is equal to A transpose.

      A is skew-symmetric if and only if A[i][j] = -A[j][i] for all i, j. That is, if A is equal to -A transpose.
      Parameters:
      skewOption - - String to indicate whether to check for symmetry or skew-symmetry. Specify skewOption as "skew" to check for skew-symmetry or "no-skew" to check for regular symmetry.
      Returns:
      True if the matrix is symmetric/skew-symmetric. Otherwise, returns false.
    • isOrthogonal

      default boolean isOrthogonal()
      Checks if this matrix is orthogonal. A square matrix Q is orthogonal if and only if QQ^T = I where I is the appropriately sized identity matrix.

      Please note, this method only checks if QQ^T = I. If the matrix is complex you may be looking for isUnitary() which checks if a matrix is unitary or QQ^* = I where Q^* is the conjugate transpose of Q. The isUnitary() method will behave the same as this method for real matrices.
      Returns:
      True if the matrix is orthogonal. Otherwise, returns false.
    • isUnitary

      default boolean isUnitary()
      Checks if this matrix is unitary. A square matrix Q is unitary if and only if QQ^* = I where I is the appropriately sized identity matrix and Q^* is the conjugate transpose.

      For real matrices, this method is the same as isOrthogonal().
      Returns:
      True if the matrix is unitary. Otherwise, returns false.
    • isTri

      default int isTri()
      Checks if a matrix is Triangular.
      A triangular matrix has all zeros above and/or below the principle diagonal.

      - Diagonal: A square matrix is diagonal if every element above and below the principle diagonal is zero.
      - Lower Triangular: A square matrix is lower triangular if every element above the principle diagonal is zero.
      - Upper Triangular: A square matrix is upper triangular if every element below the principle diagonal is zero

      See
      - isTriU()
      - isTriL()
      - isDiagonal()
      Returns:
      - 1 if matrix is not triangular.
      - 0 if Matrix is diagonal.
      - 1 if Matrix is lower triangular.
      - 2 if Matrix is upper triangular.
    • isTriU

      default boolean isTriU()
      Checks if matrix is upper triangular. A square matrix is upper triangular if every element below the principle diagonal is zero.
      Returns:
      True if this matrix is upper triangular. Otherwise, returns false.
    • isTriL

      default boolean isTriL()
      Checks if matrix is lower triangular. A square matrix is lower triangular if every element above the principle diagonal is zero.
      Returns:
      True if this matrix is lower triangular. Otherwise, returns false.
    • isDiagonal

      default boolean isDiagonal()
      Checks if this matrix is diagonal. A matrix is diagonal if every element above and below the principle diagonal is zero.
      Returns:
      True if this matrix is diagonal. Otherwise, returns false.
    • isFullRank

      default boolean isFullRank()
      Checks to see if a matrices rank is the same as its number of rows.
      Returns:
      Returns true if matrix is full rank. Otherwise, returns false.
    • isSingular

      default boolean isSingular()
    • norm

      default CNumber norm(double p, double q)
      Computes the Lp, q norm of this matrix.
      Parameters:
      p - - norm parameter 1
      q - - norm parameter 2
      Returns:
      Returns Lp, q norm of this matrix
    • rowSpace

      default Matrix rowSpace()
      Finds an orthonormal basis for the row space of this matrix.

      The row space of a matrix is the span of all column vectors. A orthonormal row space basis is a linearly independent set of unit vectors which also spans the row space.
      Returns:
      A matrix whose rows are row vectors forming an orthonormal basis for the row space of this matrix.
    • colSpace

      default Matrix colSpace()
      Finds an orthonormal basis for the column space of this matrix.

      The column space of a matrix is the span of all column vectors. A orthonormal column space basis is a linearly independent set of unit vectors which also spans the column space.
      Returns:
      A matrix whose columns are column vectors forming an orthonormal basis for the columns space of this matrix.
    • nullSpace

      default Matrix nullSpace()
      Computes a orthonormal basis for the null space of this matrix. The null space of a matrix A is all vectors x that satisfy Ax = 0.
      Returns:
      A matrix whose column vectors from an orthonormal basis for the null space of this matrix.
    • leftNullSpace

      default Matrix leftNullSpace()
      Computes an orthonormal basis of the left null space of this matrix. The left null space of a matrix A is all column vectors x which satisfy xTA=0T. This is equivalent to the the null space of AT.
      Returns:
    • isPos

      default boolean isPos()
      Returns:
      True if matrix only contains positive real entries.
    • isNeg

      default boolean isNeg()
      Returns:
      True if matrix only contains negative entries.
    • isPosDef

      default boolean isPosDef()
      Checks if matrix is positive-definite. An m-by-m hermation (or symmetric if real) matrix M is positive-definite if for all non-zero column vectors z, zHMz is positive where zH is the conjugate transpose of z.

      Also see positive-semidefinite.
      Returns:
      True if the matrix is positive-definite. Otherwise, returns false.
    • isPosSemidef

      default boolean isPosSemidef()
      Checks if matrix is positive-semidefinite. An m-by-m hermation (or symmetric if real) matrix M is positive-definite if for all non-zero \ column vector z, z*Mz is non-negative where z* is the conjugate transpose of z.

      Also see positive-definite.
      Returns:
      True if the matrix is positive-semidefinite. Otherwise, returns false.
    • eig

      default Matrix[] eig()
      Computes the eigenvalues and associated eigenvectors for a square matrix.

      Also see
      - eigVecs() to compute just the eigenvectors.
      - eigVals() to compute just the eigenvalues. This is recommended if the eigenvectors are not needed as it will be faster.
      Returns:
      Returns an array of two matrices. The first matrix is a row vector which contains the eigenvalues of A (no necessarily ordered but grouped by equality), repeated per there multiplicity. The columns of the second matrix are the eigenvectors of A associated with each eigenvalue in the first matrix. For repeated eigenvalues, each associated eigenvector in the second matrix is an associated eigenvector.
    • eigVecs

      default Matrix eigVecs()
      Computes the right eigenvectors of a matrix. This is done by first computing the Schur decomposition.

      Also see
      - eig() to compute both eigenvalues and eigenvectors.
      - eigVals() to compute just the eigenvalues.
      Returns:
      Returns a matrix containing the eigenvectors of this matrix as its column vectors.
    • eigVals

      default Matrix eigVals()
      Computes the eigenvalues of a matrix. This is done by first computing the Schur decomposition.

      Also see
      - eig() to compute both eigenvalues and eigenvectors.
      - eigVecs() to compute just the eigenvectors.
      Returns:
      Returns a column vector containing the eigenvalues of this matrix.
    • isDiagonalizable

      default boolean isDiagonalizable()
      Checks if a matrix is diagonalizable. A matrix B is diagonalizable if and only if the multiplicity for each eigenvalue is equivalent to the eigenspace for that eigenvalue.
      Returns:
      True if the matrix is diagonalizable. Otherwise, returns false.
    • equals

      default boolean equals(Matrix B)
      Checks if two matrices are element-wise equivalent. If the two matrices are different shapes, this method will return false.
      Parameters:
      B - - Matrix to compare equality with
      Returns:
      True if both matrices are element-wise equivalent. Otherwise, false.
    • sameShape

      default boolean sameShape(Matrix B, int code)
      Compares the dimensions of two matrices. If code is passed zero then this method will check if both matrices have the same number of rows and columns. If code is passed one then this method will check if both matrices have the same number of rows only. If code is passed two then this method will check if both matrices have the same number of columns only. To check rows against columns use matMultCheck(Matrix A, Matrix B)
      Parameters:
      B - - Another matrix
      code - - Choice for dimension(s) along which to check equivalence
      Returns:
      - true if the dimensions specified by code are equvalent. Otherwise. returns false
    • sameShape

      default boolean sameShape(Matrix B)
      Compares the dimensions, rows and columns, of two matrices.
      Parameters:
      B - - Another matrix
      Returns:
      - True if the number of rows and number of column of the two matrices are both equal. Otherwise, returns false.
    • isZero

      default boolean isZero()
      Checks if this matrix has only zero entries. If so, then the matrix is the so called zero matrix and is the additive identity for matrices of the same size.
      Returns:
      Returns true if matrix has all zero elements. Otherwise, returns false.
    • isI

      default boolean isI()
      Checks if a matrix is an identity matrix.
      Returns:
      Returns true if the matrix in question is an identity matrix. Otherwise, returns false.
    • isInv

      default boolean isInv(Matrix B)
      Checks if B is the inverse of this matrix.

      See matrix inverse
      Returns:
      True if B is the inverse of this matrix. Otherwise, returns false.