|
JIGL v1.6 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--jigl.math.Matrix
This class allows a programmer to create real matrices with an arbitrary number of rows and columns.
| Field Summary | |
double[][] |
mem
This member is the reference to the arrays where the entries of the matrix are stored. |
| Constructor Summary | |
Matrix()
This is the default constructor. |
|
Matrix(double[][] b)
This constructor builds a matrix from the double array b. |
|
Matrix(int m,
int n)
This constructor builds a zero matrix of size m-by-n. |
|
Matrix(Matrix A)
This constructor builds a matrix from the matrix A. |
|
| Method Summary | |
Matrix |
add(Matrix A)
This method creates a new matrix and stores the sum of this and A in it. |
Matrix |
assign(double[][] b)
This method replaces the contents of the mem array with the data contained in b. |
Matrix |
assign(Matrix A)
This method replaces the members of this with those of A. |
Object |
clone()
|
void |
eigsrt(double[] lambda)
Given the eigenvalues lambda[0..n-1] and eigenvectors contained in the matrix this as output from
jacobi, this routine sorts the eigenvalues into descending order, and rearranges the columns the columns of
this correspondingly. |
boolean |
equals(Matrix A)
This method compares if two matrices are equal. |
Matrix |
gaussj(Matrix B)
Linear equation solution by Gauss-Jordan elimination. |
double |
get(int i,
int j)
This method returns the (i, j) entry of the matrix. |
Vector |
getColumn(int j)
This method returns column j of the matrix. |
Vector |
getRow(int i)
This method returns row i of the matrix. |
int |
jacobi(double[] lambda,
Matrix S)
Computes all eigenvalues and eigenvectors of a real symmetric matrix this. |
Matrix |
mult(double a)
This method returns of new matrix with each entry multiplied by a. |
Matrix |
mult(Matrix A)
This method creates a new matrix and stores the product of this and A in it. |
Vector |
mult(Vector x)
This method returns a new vector that is the result of this multplied with x. |
int |
nColumns()
This method returns the number of columns in the matrix. |
int |
nRows()
This method returns the number of rows in the matrix. |
static double |
pythag(double a,
double b)
Computes (a² + b²)½ without destructive underflow or overflow. |
private void |
rotate(int i,
int j,
int k,
int l,
double s,
double tau)
The method performs a Jacobi rotation between entries (i, j) and (k, l). |
void |
set(int i,
int j,
double c)
This method sets element (i, j) to c. |
static double |
sign(double a,
double b)
|
Matrix |
sub(Matrix A)
This method creates a new matrix and stores the difference of this and A in it. |
static Vector |
svbksb(Matrix U,
double[] w,
Matrix V,
Vector b)
Solves A·X = B for a vector X, where is specified by the matrices U and V and the array of singular values w as returned by
svdcmp. |
void |
svdcmp(Matrix U,
double[] w,
Matrix V)
Given a matrix, this routine computes its singular value decomposition, UWVT. |
private void |
swap(int i,
int j,
int k,
int l)
This method exchanges entry (i, j) with entry (k, l). |
Matrix |
t()
This method returns a new matrix containing the transpose of this. |
String |
toString()
This method creates a string from the matrix. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public double[][] mem
| Constructor Detail |
public Matrix()
public Matrix(int m,
int n)
m-by-n.
public Matrix(double[][] b)
b.
public Matrix(Matrix A)
A.
| Method Detail |
public int nRows()
public int nColumns()
public double get(int i,
int j)
throws ArrayIndexOutOfBoundsException,
NullPointerException
(i, j) entry of the matrix.
ArrayIndexOutOfBoundsException
NullPointerException
public Vector getRow(int i)
throws ArrayIndexOutOfBoundsException,
NullPointerException
i of the matrix.
ArrayIndexOutOfBoundsException
NullPointerException
public Vector getColumn(int j)
throws ArrayIndexOutOfBoundsException,
NullPointerException
j of the matrix.
ArrayIndexOutOfBoundsException
NullPointerException
public void set(int i,
int j,
double c)
throws ArrayIndexOutOfBoundsException,
NullPointerException
(i, j) to c.
ArrayIndexOutOfBoundsException
NullPointerException
public Matrix assign(double[][] b)
throws ArrayStoreException
mem array with the data contained in b.
Each sub-array of b must be of the same length.
ArrayStoreExceptionpublic Matrix assign(Matrix A)
this with those of A.
public boolean equals(Matrix A)
throws ArithmeticException
this is equal to
evey element of A.
ArithmeticException
public Matrix add(Matrix A)
throws ArithmeticException
this and A in it. The matrices must be the same size.
ArithmeticException
public Matrix sub(Matrix A)
throws ArithmeticException
this and A in it. The matrices must be the same size.
ArithmeticException
public Matrix mult(Matrix A)
throws ArithmeticException
this and A in it.
The number of columns in this must equal the number of rows of A.
ArithmeticExceptionpublic Matrix mult(double a)
a.
public Vector mult(Vector x)
throws ArithmeticException
this multplied with x.
The number of columns of this must be equal to the dimension of x.
ArithmeticException
public Matrix t()
throws ArithmeticException
this. The matrix must be a square matrix.
ArithmeticException
private void swap(int i,
int j,
int k,
int l)
(i, j) with entry (k, l).
It is called by gaussj.
public Matrix gaussj(Matrix B)
throws ArithmeticException
this references the input matrix.
B is an n-by-m matrix containing the m right-hand side vectors. On output,
a matrix is returned that is the inverse of this, and the values of B are
replaced by the corresponding set of solution vectors.
ArithmeticException
private void rotate(int i,
int j,
int k,
int l,
double s,
double tau)
(i, j) and (k, l).
public void eigsrt(double[] lambda)
lambda[0..n-1] and eigenvectors contained in the matrix this as output from
jacobi, this routine sorts the eigenvalues into descending order, and rearranges the columns the columns of
this correspondingly. The method is straight insertion.
public int jacobi(double[] lambda,
Matrix S)
throws ArithmeticException,
ArrayStoreException
this.
lamdba contains the eigenvalues of this. S is
a matrix whose columns contain, on output, the normalized eigenvectors of this.
ArithmeticException
ArrayStoreException
public static double pythag(double a,
double b)
public static double sign(double a,
double b)
public static Vector svbksb(Matrix U,
double[] w,
Matrix V,
Vector b)
throws ArithmeticException
U and V and the array of singular values w as returned by
svdcmp. b is the input right-hand side. No input quantities are destroyed, so
the routine may be called sequentially with different b's.
ArithmeticException
public void svdcmp(Matrix U,
double[] w,
Matrix V)
throws ArithmeticException,
ArrayStoreException
w.
ArithmeticException
ArrayStoreExceptionpublic String toString()
toString in class Objectpublic Object clone()
clone in class Object
|
JIGL v1.6 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||