|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--weka.core.Matrix
Class for performing operations on a matrix of floating-point values.
Constructor Summary | |
Matrix(double[][] array)
Constructs a matrix using a given array. |
|
Matrix(int nr,
int nc)
Constructs a matrix and initializes it with default values. |
|
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. |
void |
eigenvalueDecomposition(double[][] V,
double[] d)
Performs Eigenvalue Decomposition using Householder QR Factorization This function is adapted from the CERN Jet Java libraries, for it the following copyright applies (see also, text on top of file) Copyright (C) 1999 CERN - European Organization for Nuclear Research. |
double[] |
getColumn(int index)
Gets a column of the matrix and returns it as a double array. |
double |
getElement(int rowIndex,
int columnIndex)
Returns the value of a cell in the matrix. |
Matrix |
getL()
Returns the L part of the matrix. |
double[] |
getRow(int index)
Gets a row of the matrix and returns it as double array. |
Matrix |
getU()
Returns the U part of the matrix. |
boolean |
isSymmetric()
Returns true if the matrix is symmetric. |
int[] |
LUDecomposition()
Performs a LUDecomposition on the matrix. |
static void |
main(java.lang.String[] ops)
Main method for testing this class. |
Matrix |
multiply(Matrix b)
Returns 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,
double ridge)
Performs a (ridged) linear regression. |
double[] |
regression(Matrix y,
double[] w,
double ridge)
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. |
void |
solve(double[] bb)
Solve A*X = B using backward substitution. |
boolean |
testEigen(Matrix V,
double[] d,
boolean verbose)
Test eigenvectors and eigenvalues. |
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, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Matrix(int nr, int nc)
nr
- the number of rowsnc
- the number of columnspublic Matrix(double[][] array) throws java.lang.Exception
array
- the values of the matrixpublic Matrix(java.io.Reader r) throws java.lang.Exception
r
- the reader containing the matrix
java.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 Writer
java.lang.Exception
- if an error occurspublic final double getElement(int rowIndex, int columnIndex)
rowIndex
- the row's indexcolumnIndex
- the column's index
public 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 double[] getRow(int index)
index
- the row's index
public double[] getColumn(int index)
index
- the column's index
public 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 boolean isSymmetric()
public final Matrix multiply(Matrix b)
b
- the multiplication matrix
public final double[] regression(Matrix y, double ridge)
y
- the dependent variable vectorridge
- the ridge parameter
java.lang.IllegalArgumentException
- if not successfulpublic final double[] regression(Matrix y, double[] w, double ridge)
y
- the dependent variable vectorw
- the array of data point weightsridge
- the ridge parameter
java.lang.IllegalArgumentException
- if the wrong number of weights were
provided.public Matrix getL() throws java.lang.Exception
java.lang.Exception
public Matrix getU() throws java.lang.Exception
java.lang.Exception
public int[] LUDecomposition() throws java.lang.Exception
java.lang.Exception
- if the matrix is singularpublic void solve(double[] bb) throws java.lang.Exception
bb
- first vektor B in above equation then X in same equation.
matrix
- is singulaer
java.lang.Exception
public void eigenvalueDecomposition(double[][] V, double[] d) throws java.lang.Exception
V
- double array in which the eigenvectors are returnedd
- array in which the eigenvalues are returned
if
- matrix is not symmetric
java.lang.Exception
public boolean testEigen(Matrix V, double[] d, boolean verbose) throws java.lang.Exception
V
- matrix with eigenvectors of Ad
- array with eigenvalues of A
if
- new matrix cannot be made
java.lang.Exception
public static void main(java.lang.String[] ops)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London