math.utils
Class Matrix

Package class diagram package Matrix
java.lang.Object
  extended by math.utils.Matrix

public class Matrix
extends Object

class Matrix


Constructor Summary
Matrix()
          Construct a new Matrix, with 1 row and 1 column, initialized to 1.
Matrix(double[][] coef)
          Construct a new Matrix, initialized with the given coefficients.
Matrix(int nbRows, int nbCols)
          init a new Matrix with nbRows rows, and nbCols columns.
 
Method Summary
 double getCoef(int row, int col)
          return the coef.
 int getColumns()
          return the number of columns.
 int getRows()
          return the number of rows.
 Matrix getTranspose()
          get the transposed matrix, without changing the inner coefficients of the original matrix.
 boolean isSquare()
          return true if the matrix is square, i.e.
 double[] multiplyWith(double[] coefs)
          return the result of the multiplication of the matrix with the given vector.
 double[] multiplyWith(double[] src, double[] res)
          return the result of the multiplication of the matrix with the given vector.
 Matrix multiplyWith(Matrix matrix)
          return the result of the multiplication of the matriux with another one.
 void setCoef(int row, int col, double coef)
          set the coef to the given value.
 void setToIdentity()
          Fill the matrix with zeros everywhere, except on the main diagonal, filled with ones.
 double[] solve(double[] vector)
          compute the solution of a linear system, using the Gauss-Jordan algorithm.
 String toString()
          return a String representation of the elements of the Matrix
 void transpose()
          transpose the matrix, changing the inner coefficients.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

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


Matrix

public Matrix(int nbRows,
              int nbCols)
init a new Matrix with nbRows rows, and nbCols columns.


Matrix

public Matrix(double[][] coef)
Construct a new Matrix, initialized with the given coefficients.

Method Detail

getCoef

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


getRows

public int getRows()
return the number of rows.


getColumns

public int getColumns()
return the number of columns.


isSquare

public boolean isSquare()
return 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)
set 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)
return the result of the multiplication of the matriux with another one. The content of the matrix is not modified.


multiplyWith

public double[] multiplyWith(double[] coefs)
return the result of the multiplication of the matrix with the given vector. The content of the matrix is not modified.


multiplyWith

public double[] multiplyWith(double[] src,
                             double[] res)
return the result of the multiplication of the matrix with the given vector. The content of the matrix is not modified.


transpose

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


getTranspose

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


solve

public double[] solve(double[] vector)
compute the solution of a linear system, using the Gauss-Jordan algorithm. The inner coefficients of the matrix are not modified.


setToIdentity

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


toString

public String toString()
return a String representation of the elements of the Matrix

Overrides:
toString in class Object


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.