Class SquareMatrix

  • Direct Known Subclasses:
    IdentityMatrix, LinearSystem

    public class SquareMatrix
    extends Matrix
    From: Java Number Cruncher The Java Programmer's Guide to Numerical Computation by Ronald Mak A square matrix.
    • Constructor Detail

      • SquareMatrix

        public SquareMatrix​(int n)
        Constructor.
        Parameters:
        n - the number of rows == the number of columns
      • SquareMatrix

        public SquareMatrix​(double[][] values)
        Constructor.
        Parameters:
        values - the array of values
    • Method Detail

      • set

        protected void set​(double[][] values)
        Set this square matrix from a 2-d array of values. If the values are not square, only the upper left square is used.
        Overrides:
        set in class Matrix
        Parameters:
        values - the 2-d array of values
      • subtract

        public SquareMatrix subtract​(SquareMatrix sm)
                              throws MatrixException
        Subtract another square matrix from this matrix.
        Parameters:
        sm - the square matrix subrrahend
        Returns:
        the difference matrix
        Throws:
        numbercruncher.MatrixException - for invalid size
        MatrixException
      • multiply

        public SquareMatrix multiply​(SquareMatrix sm)
                              throws MatrixException
        Multiply this square matrix by another square matrix.
        Parameters:
        sm - the square matrix multiplier
        Returns:
        the product matrix
        Throws:
        numbercruncher.MatrixException - for invalid size
        MatrixException