Documentation of 'math.utils.Matrix' Java class
Matrix
math.utils

Class Matrix



  • public class Matrix
    extends java.lang.Object
    class Matrix
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static double tolerance
      The tolerance used for solving linear equations.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Matrix()
      Constructs a new Matrix, with 1 row and 1 column, initialized to 1.
      Matrix(double[][] coef)
      Constructs a new Matrix, initialized with the given coefficients.
      Matrix(int nbRows, int nbCols)
      Initializes a new Matrix with the given number of rows and columns.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double getCoef(int row, int col)
      Returns the coef.
      int getColumns()
      Returns the number of columns.
      int getRows()
      Returns the number of rows.
      Matrix getTranspose()
      Returns the transposed matrix, without changing the inner coefficients of the original matrix.
      boolean isSquare()
      Returns true if the matrix is square, i.e.
      double[] multiplyWith(double[] coefs)
      Returns the result of the multiplication of the matrix with the given vector.
      double[] multiplyWith(double[] src, double[] res)
      Returns the result of the multiplication of the matrix with the given vector.
      Matrix multiplyWith(Matrix matrix)
      Returns the result of the multiplication of the matrix with another one.
      void setCoef(int row, int col, double coef)
      Sets the coef to the given value.
      void setToIdentity()
      Fills the matrix with zeros everywhere, except on the main diagonal, filled with ones.
      double[] solve(double[] vector)
      Computes the solution of a linear system, using the Gauss-Jordan algorithm.
      java.lang.String toString()
      Returns a String representation of the elements of the Matrix
      void transpose()
      Transposes the matrix, changing the inner coefficients.
      • Methods inherited from class java.lang.Object

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

      • tolerance

        public static double tolerance
        The tolerance used for solving linear equations. Equal to 1e-14 by default.
    • Constructor Detail

      • Matrix

        public Matrix()
        Constructs a new Matrix, with 1 row and 1 column, initialized to 1.
      • Matrix

        public Matrix(int nbRows,
                      int nbCols)
        Initializes a new Matrix with the given number of rows and columns.
      • Matrix

        public Matrix(double[][] coef)
        Constructs a new Matrix, initialized with the given coefficients.
    • Method Detail

      • getCoef

        public double getCoef(int row,
                              int col)
        Returns the coef. row and col are between 1 and the number of rows and columns.
      • getRows

        public int getRows()
        Returns the number of rows.
      • getColumns

        public int getColumns()
        Returns the number of columns.
      • isSquare

        public boolean isSquare()
        Returns true if the matrix is square, i.e. the number of rows equals the number of columns.
      • setCoef

        public void setCoef(int row,
                            int col,
                            double coef)
        Sets the coef to the given value. row and col are between 1 and the number of rows and columns.
      • multiplyWith

        public Matrix multiplyWith(Matrix matrix)
        Returns the result of the multiplication of the matrix with another one. The content of the matrix is not modified.
        Throws:
        java.lang.IllegalArgumentException - if the size of matrices do not match
      • multiplyWith

        public double[] multiplyWith(double[] coefs)
        Returns the result of the multiplication of the matrix with the given vector. The content of the matrix is not modified.
        Throws:
        java.lang.NullPointerException - if input array is null
        java.lang.IllegalArgumentException - if size of vector and of matrix do not match
      • multiplyWith

        public double[] multiplyWith(double[] src,
                                     double[] res)
        Returns the result of the multiplication of the matrix with the given vector. The content of the matrix is not modified.
        Throws:
        java.lang.NullPointerException - if input vector is null
        java.lang.IllegalArgumentException - if size of vector and of matrix do not match
      • transpose

        public void transpose()
        Transposes the matrix, changing the inner coefficients.
      • getTranspose

        public Matrix getTranspose()
        Returns the transposed matrix, without changing the inner coefficients of the original matrix.
      • solve

        public double[] solve(double[] vector)
        Computes the solution of a linear system, using the Gauss-Jordan algorithm. The inner coefficients of the matrix are not modified.
        Throws:
        java.lang.NullPointerException - if input vector is null
        java.lang.IllegalArgumentException - if size of vector and of matrix do not match
        java.lang.UnsupportedOperationException - if the matrix is not square
        java.lang.ArithmeticException - if the algorithm could not find pivot greater than tolerance
      • setToIdentity

        public void setToIdentity()
        Fills the matrix with zeros everywhere, except on the main diagonal, filled with ones.
      • toString

        public java.lang.String toString()
        Returns a String representation of the elements of the Matrix
        Overrides:
        toString in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.