|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object math.utils.Matrix
public class Matrix
class Matrix
Field Summary | |
---|---|
static double |
tolerance
The tolerance used for solving linear equations. |
Constructor Summary | |
---|---|
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 | |
---|---|
double |
getCoef(int row,
int col)
Returns the coef. row and col are between 1 and the number of rows and columns. |
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. the number of rows equals the number of columns. |
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. row and col are between 1 and the number of rows and columns. |
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 |
---|
public static double tolerance
Constructor Detail |
---|
public Matrix()
public Matrix(int nbRows, int nbCols)
public Matrix(double[][] coef)
Method Detail |
---|
public double getCoef(int row, int col)
public int getRows()
public int getColumns()
public boolean isSquare()
public void setCoef(int row, int col, double coef)
public Matrix multiplyWith(Matrix matrix)
java.lang.IllegalArgumentException
- if the size of matrices do not matchpublic double[] multiplyWith(double[] coefs)
java.lang.NullPointerException
- if input array is null
java.lang.IllegalArgumentException
- if size of vector and of matrix do not matchpublic double[] multiplyWith(double[] src, double[] res)
java.lang.NullPointerException
- if input vector is null
java.lang.IllegalArgumentException
- if size of vector and of matrix do not matchpublic void transpose()
public Matrix getTranspose()
public double[] solve(double[] vector)
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 tolerancepublic void setToIdentity()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |