|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.core.Matrix
Class for performing operations on a matrix of floating-point values. Some of the code is adapted from Numerical Recipes in C.
Field Summary | |
protected double[][] |
m_Elements
The data in the matrix. |
Constructor Summary | |
Matrix(int nr,
int nc)
Constructs a matrix. |
|
Matrix(java.io.Reader r)
Reads a matrix from a reader. |
Method Summary | |
Matrix |
add(Matrix other)
Returns the sum of this matrix with another. |
void |
addElement(int rowIndex,
int columnIndex,
double value)
Add a value to an element. |
java.lang.Object |
clone()
Creates and returns a clone of this object. |
double |
getElement(int rowIndex,
int columnIndex)
Returns the value of a cell in the matrix. |
protected void |
initialize()
Resets the elements to default values (i.e. |
void |
lubksb(int[] indx,
double[] b)
Performs LU backward substitution. |
int[] |
ludcmp()
Performs LU decomposition. |
static void |
main(java.lang.String[] ops)
Main method for testing this class. |
Matrix |
multiply(Matrix b)
Reurns the multiplication of two matrices |
int |
numColumns()
Returns the number of columns in the matrix. |
int |
numRows()
Returns the number of rows in the matrix. |
double[] |
regression(Matrix y)
Performs a (ridged) linear regression. |
double[] |
regression(Matrix y,
double[] w)
Performs a weighted (ridged) linear regression. |
void |
setColumn(int index,
double[] newColumn)
Sets a column of the matrix to the given column. |
void |
setElement(int rowIndex,
int columnIndex,
double value)
Sets an element of the matrix to the given value. |
void |
setRow(int index,
double[] newRow)
Sets a row of the matrix to the given row. |
java.lang.String |
toString()
Converts a matrix to a string |
Matrix |
transpose()
Returns the transpose of a matrix. |
void |
write(java.io.Writer w)
Writes out a matrix |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected double[][] m_Elements
Constructor Detail |
public Matrix(int nr, int nc)
nr
- the number of rowsnc
- the number of columnspublic Matrix(java.io.Reader r) throws java.lang.Exception
r
- the reader containing the matrixjava.lang.Exception
- if an error occursMethod Detail |
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if an error occurspublic void write(java.io.Writer w) throws java.lang.Exception
w
- the output Writerjava.lang.Exception
- if an error occursprotected void initialize()
public final double getElement(int rowIndex, int columnIndex)
rowIndex
- the row's indexcolumnIndex
- the column's indexpublic final void addElement(int rowIndex, int columnIndex, double value)
rowIndex
- the row's index.columnIndex
- the column's index.value
- the value to add.public final int numRows()
public final int numColumns()
public final void setElement(int rowIndex, int columnIndex, double value)
rowIndex
- the row's indexcolumnIndex
- the column's indexvalue
- the valuepublic final void setRow(int index, double[] newRow)
index
- the row's indexnewRow
- an array of doublespublic final void setColumn(int index, double[] newColumn)
index
- the column's indexnewColumn
- an array of doublespublic java.lang.String toString()
toString
in class java.lang.Object
public final Matrix add(Matrix other)
public final Matrix transpose()
public final Matrix multiply(Matrix b)
b
- the multiplication matrixpublic final double[] regression(Matrix y)
y
- the dependent variable vectorjava.lang.IllegalArgumentException
- if not successfulpublic final double[] regression(Matrix y, double[] w)
y
- the dependent variable vectorw
- the array of data point weightsjava.lang.IllegalArgumentException
- if the wrong number of weights were
provided.public final void lubksb(int[] indx, double[] b)
indx
- the indices of the permutationb
- the double vector, storing constant terms in the equation set;
it later stores the computed coefficients' valuespublic final int[] ludcmp() throws java.lang.Exception
java.lang.Exception
- if the matrix is singularpublic static void main(java.lang.String[] ops)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |