|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvec_math.Matrix
public class Matrix
Class to provide basic matrix functions, like multiplication (matrix or scalar), addition, transposing... If a matrix is constructed only with rows and columns specified, a Null matrix of the specified range is created. Construction with an additional (double) array fills both, row and columns. Calls to routines like setRows(double[][]) only validates the row-like representation of the matrix (colVal = false). Routines like evalRows() updates the row-like representation of the matrix from the column representation.
| Nested Class Summary | |
|---|---|
static class |
Matrix.CloneTest
Testing cloning. |
| Field Summary | |
|---|---|
private VectorG[] |
col
|
protected boolean |
colValid
The flag indicating a valid column-representation of the matrix. |
private int |
mcol
The number of columns in the matrix. |
private int |
nrow
The number of rows in the matrix. |
private VectorG[] |
row
The vectors defining the rows of the matrix. |
protected boolean |
rowValid
The flag indicating a valid row-representation of the matrix. |
| Constructor Summary | |
|---|---|
protected |
Matrix()
Constructs an empty matrix. |
|
Matrix(int n,
int m)
Constructs an empty matrix with the number of rows and columns specified. |
|
Matrix(Matrix mat)
Constructs a new matrix and copies the row and col vectors into the new matrix. |
| Method Summary | |
|---|---|
Object |
clone()
Returns a clone of the actual matrix. |
int |
columns()
Return the number of columns. |
boolean |
equals(Object what)
Checks if two matrices are equal. |
boolean |
evalCol()
Twin function to evalRow(). |
boolean |
evalRow()
Derives the row-like representation of the matrix out of a valid column-like. |
protected void |
exchangeCol(int m1,
int m2,
boolean rowset)
Pendant to exchangeRow. |
protected void |
exchangeRow(int n1,
int n2,
boolean colset)
Exchanges rows n1 with n2. |
private static VectorG |
extract(VectorG[] vector,
int n)
Extracts a row/column from a column/row representation of a matrix. |
VectorG |
getColumn(int m)
Returns the specified column as an nvector. |
double |
getElement(int rw,
int cl)
Returns the element in question. |
protected VectorG |
getRawColumn(int m)
Always return the column, even if not valid. |
protected VectorG |
getRawRow(int n)
Always return the specified row, even if invalid. |
VectorG |
getRow(int n)
Returns the specified row as an nvector. |
Matrix |
mult(double scalar)
Returns the scalar product of the actual matrix with scalar. |
static Matrix |
mult(Matrix m,
Matrix n)
Returns the matrix product of this x that, provided that this.mcol equals that.nrow. |
protected void |
multOneCol(int m,
double fac)
Same as row operation. |
protected void |
multOneRow(int n,
double fac)
Multiplies row number n (0->nrow-1) with fac. |
int |
rows()
Return the number of rows. |
void |
setCols(VectorG[] newcol)
Same restrictions as in setRows. |
void |
setElement(int rw,
int cl,
double val)
Sets the element a_row,col. |
protected void |
setOneCol(int m,
VectorG newcol)
Same restrictions as in setOneRow. |
protected boolean |
setOneRow(int n,
VectorG newrow)
Changes only one row, specified by it's number n. |
void |
setRows(VectorG[] newrow)
Sets the matrix via its row-like representation. |
String |
toString()
Returns a string representation of the matrix. |
static Matrix |
transpose(Matrix m)
Returns the transposed of the argument Matrix. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private int nrow
private int mcol
protected boolean rowValid
private VectorG[] row
protected boolean colValid
private VectorG[] col
| Constructor Detail |
|---|
protected Matrix()
public Matrix(int n,
int m)
n - The number of rows.m - The number of columns.public Matrix(Matrix mat)
clone()| Method Detail |
|---|
public Object clone()
clone in class Object
public void setElement(int rw,
int cl,
double val)
public double getElement(int rw,
int cl)
public int rows()
public int columns()
public void setRows(VectorG[] newrow)
public VectorG getRow(int n)
evalRow().
protected VectorG getRawRow(int n)
protected boolean setOneRow(int n,
VectorG newrow)
public void setCols(VectorG[] newcol)
public VectorG getColumn(int m)
evalCol().
protected VectorG getRawColumn(int m)
protected void setOneCol(int m,
VectorG newcol)
protected void multOneRow(int n,
double fac)
protected void multOneCol(int m,
double fac)
protected void exchangeRow(int n1,
int n2,
boolean colset)
protected void exchangeCol(int m1,
int m2,
boolean rowset)
private static final VectorG extract(VectorG[] vector,
int n)
vector - A row or column representation of the matrix.n - The index to extract.public boolean evalRow()
public boolean evalCol()
public static Matrix transpose(Matrix m)
public Matrix mult(double scalar)
public static Matrix mult(Matrix m,
Matrix n)
public String toString()
toString in class Objectpublic boolean equals(Object what)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||