|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Utils.Matrix
public class Matrix
Class implementing several operations on double matrices.
Constructor Summary | |
---|---|
Matrix(double[][] a)
Builds a matrix from a bi-dimensional array. |
|
Matrix(int n)
Builds a square matrix containing 0 values. |
|
Matrix(int n,
int m)
Builds a matrix containing 0 values. |
|
Matrix(Matrix matrix)
Copy constructor |
Method Summary | |
---|---|
Matrix |
clone()
Returns a copy of this matrix. |
double |
condition()
Computes the condition number of this matrix. |
double |
determinant()
Computes the determinant of this matrix. |
Matrix |
gauss()
Performs the Gauss algorithm (without switching rows) |
Matrix |
gaussPivot()
Performs the Gauss algorithm (using the maximum pivot technique) |
Matrix |
gaussSeidel()
Returns the Gauss-Seidel iteration matrix. |
double |
get(int i,
int j)
Returns the value of a matrix element. |
int |
getColumns()
Returns the width of the matrix. |
double |
getMinValue()
Returns the minimum value in this matrix. |
int |
getRows()
Returns the height of the matrix. |
static double[][] |
getSubMatrix(double[][] matrix,
boolean width,
boolean height)
Extracts a submatrix from a bi-dimensional double array. |
static Matrix |
identity(int n)
Creates an identity matrix. |
double |
infinityNorm()
Computes the infinity-norm of this matrix. |
Matrix |
invert()
Computes the inverse matrix. |
static double[][] |
invert(double[][] m)
Inverts a double bi-dimensional array. |
Matrix |
jacobi()
Returns the Jacobi iteration matrix. |
Matrix |
multiply(double value)
Multiplies all elements of this matrix to a given real value. |
Matrix |
multiply(Matrix matrix)
Multiplies the matrix to a given matrix. |
double |
oneNorm()
Computes the 1-norm of this matrix. |
void |
set(int i,
int j,
double v)
Modifies a matrix element. |
double[] |
solve(boolean pivot)
Solves a linear problem based on a complete matrix. |
double[] |
solve(double[] b,
boolean pivot)
Solves a linear problem based on this matrix and a given array using the Gauss algorithm. |
Matrix |
sum(Matrix matrix)
Sums this matrix to a given one. |
void |
switchRows(int i,
int j)
Switches two rows. |
double[][] |
toDouble()
Returns a copy of this matrix as a bi-dimensional double array. |
float[][] |
toFloat()
Returns a copy of this matrix as a bi-dimensional float array. |
java.lang.String |
toString()
Returns a string representation of this matrix. |
java.lang.String |
toString(int i,
int j)
Returns a string representation of a matrix element. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Matrix(int n)
n
- Number of rows/columns of the matrix.public Matrix(int n, int m)
n
- Number of rows of the matrix.m
- Number of columns of the matrix.public Matrix(double[][] a)
a
- The bi-dimensional array whose values are to be copied into the matrix.public Matrix(Matrix matrix)
matrix
- The matrix to be copied.Method Detail |
---|
public int getRows()
public int getColumns()
public double get(int i, int j)
i
- Row index.j
- Column index.
public void set(int i, int j, double v)
i
- Row index.j
- Column index.v
- Value to insert at the given position.public static Matrix identity(int n)
n
- Number of rows/columns of the matrix.
public Matrix sum(Matrix matrix)
matrix
- The matrix to be added.
null
if the two matrices have different sizes.public Matrix multiply(double value)
value
- The value matrix to be multiplied to matrix elements.
public Matrix multiply(Matrix matrix)
matrix
- The matrix to be added.
null
if the two matrices have incompatible sizes.public void switchRows(int i, int j)
i
- The first row.j
- The second row.public Matrix gauss()
public Matrix gaussPivot()
public double[] solve(double[] b, boolean pivot)
b
- The values array.pivot
- If true
uses the pivot-based Gauss algorithm.
public double[] solve(boolean pivot)
pivot
- If true
uses the pivot-based Gauss algorithm.
public Matrix invert()
public static double[][] invert(double[][] m)
m
- Bi-dimensional array to invert.
public double oneNorm()
public double infinityNorm()
public double condition()
public double determinant()
public Matrix jacobi()
public Matrix gaussSeidel()
public float[][] toFloat()
public double[][] toDouble()
public Matrix clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(int i, int j)
i
- Row index.j
- Column index.
public double getMinValue()
public static double[][] getSubMatrix(double[][] matrix, boolean width, boolean height)
matrix
- The bi-dimensional array where the submatrix is extracted from.width
- Selects either the left (true
) or the right (false
) part of the matrix.height
- Selects either the lower (true
) or the upper (false
) part of the matrix.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |