public class RealMatrix
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
double[][] |
entries
The array of matrix entries.
|
Constructor and Description |
---|
RealMatrix()
Default constructor creates an empty matrix.
|
RealMatrix(double[][] e)
Creates a matrix using the supplied array as the entries.
|
RealMatrix(int rows,
int columns)
Creates a matrix full of zeros with the specified size.
|
Modifier and Type | Method and Description |
---|---|
RealMatrix |
add(RealMatrix m)
Adds matrices.
|
RealMatrix |
adjoint()
Computes the adjoint matrix.
|
boolean |
checkZeroRows()
Test function to check for all-zero rows in matrix.
|
java.lang.Object |
clone() |
int |
columns()
Returns the number of columns.
|
double |
det()
Computes the determinant.
|
double |
entry(int row,
int column)
Returns a single entry of the matrix.
|
static RealMatrix |
identity(int rows)
Returns a square identity matrix.
|
RealMatrix |
inverse()
Inverts a matrix inefficiently by computing the determinant and adjoint.
|
RealMatrix[] |
jacobi()
Does the jacobi transformation.
|
RealMatrix |
luinvert()
Does LU inversion.
|
RealMatrix |
negate()
Negates the matrix.
|
RealMatrix |
product(RealMatrix m)
Multiplies matrices.
|
RealMatrix |
pseudoInv() |
RealMatrix |
pseudoInv(double svThresh) |
int |
rows()
Returns the number of rows.
|
RealMatrix |
scalarMult(double scalar)
Multiplies the matrix by a scalar and returns the result leaving
the original unchanged.
|
void |
scale(double scalar)
Multiplies the matrix by a scalar.
|
void |
setEntry(int row,
int column,
double val)
Sets a matrix entry.
|
RealMatrix |
sub(RealMatrix m)
Subtracts matrices.
|
RealMatrix[] |
svd()
Computes the singular value decomposition U, S and V of the matrix A, so
that A = U S V^T.
|
void |
swapColumns(int a,
int b)
Switches two columns of the matrix.
|
void |
swapRows(int a,
int b)
Switches two rows of the matrix.
|
boolean |
symmetric()
Tests whether the matrix is symmetric.
|
java.lang.String |
toString() |
double |
trace()
Computes the trace of the matrix.
|
RealMatrix |
transpose()
Computes the transpose.
|
boolean |
triangular()
Tests whether a matrix is triangular.
|
public RealMatrix()
public RealMatrix(int rows, int columns)
rows
- Number of rows in the matrix.columns
- Number of columns in the matrix.public RealMatrix(double[][] e)
e
- the matrix in array form, where there are e.length
rows and
e[0].length
columns.public java.lang.Object clone()
clone
in class java.lang.Object
public static RealMatrix identity(int rows)
rows
- Size of the matrix.public double entry(int row, int column)
row
- The row of the entry.column
- The column of the entrypublic void setEntry(int row, int column, double val)
row
- The row of the entry.column
- The column of the entry.val
- The new value of the entry.public int rows()
public int columns()
public void swapColumns(int a, int b)
a
- Index of first column to swap.b
- Index of second column to swap.public void swapRows(int a, int b)
a
- Index of first row to swap.b
- Index of second row to swap.public RealMatrix product(RealMatrix m)
m
- The matrix to postmultiply by.public RealMatrix add(RealMatrix m)
m
- Matrix to add.public RealMatrix sub(RealMatrix m)
m
- Matrix to subtract from this one.public RealMatrix negate()
public void scale(double scalar)
scalar
- The scalar multiple.public RealMatrix scalarMult(double scalar)
scalar
- The scalar multiple.public RealMatrix inverse()
public RealMatrix adjoint()
public double det()
public double trace()
public RealMatrix transpose()
public RealMatrix[] jacobi()
public boolean symmetric()
public boolean triangular()
public RealMatrix luinvert()
public java.lang.String toString()
toString
in class java.lang.Object
public RealMatrix[] svd() throws SVD_Exception
SVD_Exception
public RealMatrix pseudoInv(double svThresh)
public RealMatrix pseudoInv()
public boolean checkZeroRows()