Package weka.core
Class Matrix
java.lang.Object
weka.core.Matrix
- All Implemented Interfaces:
- Serializable,- Cloneable,- RevisionHandler
Deprecated.
Class for performing operations on a matrix of floating-point values.
 
 Deprecated: Uses internally the code of the sub-package
 
weka.core.matrix - only for backwards compatibility.- Version:
- $Revision: 10203 $
- Author:
- Gabi Schmidberger (gabi@cs.waikato.ac.nz), Yong Wang (yongwang@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz), Len Trigg (eibe@cs.waikato.ac.nz), Fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal MatrixDeprecated.Returns the sum of this matrix with another.final voidaddElement(int rowIndex, int columnIndex, double value) Deprecated.Add a value to an element.clone()Deprecated.Creates and returns a clone of this object.voideigenvalueDecomposition(double[][] V, double[] d) Deprecated.Performs Eigenvalue Decomposition using Householder QR Factorization Matrix must be symmetrical.double[]getColumn(int index) Deprecated.Gets a column of the matrix and returns it as a double array.final doublegetElement(int rowIndex, int columnIndex) Deprecated.Returns the value of a cell in the matrix.getL()Deprecated.Returns the L part of the matrix.Deprecated.Returns the revision string.double[]getRow(int index) Deprecated.Gets a row of the matrix and returns it as double array.getU()Deprecated.Returns the U part of the matrix.booleanDeprecated.Returns true if the matrix is symmetric.int[]Deprecated.Performs a LUDecomposition on the matrix.static voidDeprecated.Main method for testing this class.final MatrixDeprecated.Returns the multiplication of two matricesfinal intDeprecated.Returns the number of columns in the matrix.final intnumRows()Deprecated.Returns the number of rows in the matrix.static MatrixparseMatlab(String matlab) Deprecated.creates a matrix from the given Matlab string.final double[]regression(Matrix y, double ridge) Deprecated.Performs a (ridged) linear regression.final double[]regression(Matrix y, double[] w, double ridge) Deprecated.Performs a weighted (ridged) linear regression.final voidsetColumn(int index, double[] newColumn) Deprecated.Sets a column of the matrix to the given column.final voidsetElement(int rowIndex, int columnIndex, double value) Deprecated.Sets an element of the matrix to the given value.final voidsetRow(int index, double[] newRow) Deprecated.Sets a row of the matrix to the given row.voidsolve(double[] bb) Deprecated.Solve A*X = B using backward substitution.toMatlab()Deprecated.converts the Matrix into a single line Matlab string: matrix is enclosed by parentheses, rows are separated by semicolon and single cells by blanks, e.g., [1 2; 3 4].toString()Deprecated.Converts a matrix to a stringfinal MatrixDeprecated.Returns the transpose of a matrix.voidDeprecated.Writes out a matrix.
- 
Constructor Details- 
Matrixpublic Matrix(int nr, int nc) Deprecated.Constructs a matrix and initializes it with default values.- Parameters:
- nr- the number of rows
- nc- the number of columns
 
- 
MatrixDeprecated.Constructs a matrix using a given array.- Parameters:
- array- the values of the matrix
- Throws:
- Exception
 
- 
MatrixDeprecated.Reads a matrix from a reader. The first line in the file should contain the number of rows and columns. Subsequent lines contain elements of the matrix.- Parameters:
- r- the reader containing the matrix
- Throws:
- Exception- if an error occurs
 
 
- 
- 
Method Details- 
cloneDeprecated.Creates and returns a clone of this object.- Returns:
- a clone of this instance.
- Throws:
- Exception- if an error occurs
 
- 
writeDeprecated.Writes out a matrix.- Parameters:
- w- the output Writer
- Throws:
- Exception- if an error occurs
 
- 
getElementpublic final double getElement(int rowIndex, int columnIndex) Deprecated.Returns the value of a cell in the matrix.- Parameters:
- rowIndex- the row's index
- columnIndex- the column's index
- Returns:
- the value of the cell of the matrix
 
- 
addElementpublic final void addElement(int rowIndex, int columnIndex, double value) Deprecated.Add a value to an element.- Parameters:
- rowIndex- the row's index.
- columnIndex- the column's index.
- value- the value to add.
 
- 
numRowspublic final int numRows()Deprecated.Returns the number of rows in the matrix.- Returns:
- the number of rows
 
- 
numColumnspublic final int numColumns()Deprecated.Returns the number of columns in the matrix.- Returns:
- the number of columns
 
- 
setElementpublic final void setElement(int rowIndex, int columnIndex, double value) Deprecated.Sets an element of the matrix to the given value.- Parameters:
- rowIndex- the row's index
- columnIndex- the column's index
- value- the value
 
- 
setRowpublic final void setRow(int index, double[] newRow) Deprecated.Sets a row of the matrix to the given row. Performs a deep copy.- Parameters:
- index- the row's index
- newRow- an array of doubles
 
- 
getRowpublic double[] getRow(int index) Deprecated.Gets a row of the matrix and returns it as double array.- Parameters:
- index- the row's index
- Returns:
- an array of doubles
 
- 
getColumnpublic double[] getColumn(int index) Deprecated.Gets a column of the matrix and returns it as a double array.- Parameters:
- index- the column's index
- Returns:
- an array of doubles
 
- 
setColumnpublic final void setColumn(int index, double[] newColumn) Deprecated.Sets a column of the matrix to the given column. Performs a deep copy.- Parameters:
- index- the column's index
- newColumn- an array of doubles
 
- 
toStringDeprecated.Converts a matrix to a string
- 
addDeprecated.Returns the sum of this matrix with another.- Returns:
- a matrix containing the sum.
 
- 
transposeDeprecated.Returns the transpose of a matrix.- Returns:
- the transposition of this instance.
 
- 
isSymmetricpublic boolean isSymmetric()Deprecated.Returns true if the matrix is symmetric.- Returns:
- boolean true if matrix is symmetric.
 
- 
multiplyDeprecated.Returns the multiplication of two matrices- Parameters:
- b- the multiplication matrix
- Returns:
- the product matrix
 
- 
regressionDeprecated.Performs a (ridged) linear regression.- Parameters:
- y- the dependent variable vector
- ridge- the ridge parameter
- Returns:
- the coefficients
- Throws:
- IllegalArgumentException- if not successful
 
- 
regressionDeprecated.Performs a weighted (ridged) linear regression.- Parameters:
- y- the dependent variable vector
- w- the array of data point weights
- ridge- the ridge parameter
- Returns:
- the coefficients
- Throws:
- IllegalArgumentException- if the wrong number of weights were provided.
 
- 
getLDeprecated.Returns the L part of the matrix. This does only make sense after LU decomposition.- Returns:
- matrix with the L part of the matrix;
- Throws:
- Exception
- See Also:
 
- 
getUDeprecated.Returns the U part of the matrix. This does only make sense after LU decomposition.- Returns:
- matrix with the U part of a matrix;
- Throws:
- Exception
- See Also:
 
- 
LUDecompositionDeprecated.Performs a LUDecomposition on the matrix. It changes the matrix into its LU decomposition.- Returns:
- the indices of the row permutation
- Throws:
- Exception
 
- 
solveDeprecated.Solve A*X = B using backward substitution. A is current object (this). Note that this matrix will be changed! B parameter bb. X returned in parameter bb.- Parameters:
- bb- first vector B in above equation then X in same equation.
- Throws:
- Exception
 
- 
eigenvalueDecompositionDeprecated.Performs Eigenvalue Decomposition using Householder QR Factorization Matrix must be symmetrical. Eigenvectors are return in parameter V, as columns of the 2D array. (Real parts of) Eigenvalues are returned in parameter d.- Parameters:
- V- double array in which the eigenvectors are returned
- d- array in which the eigenvalues are returned
- Throws:
- Exception- if matrix is not symmetric
 
- 
toMatlabDeprecated.converts the Matrix into a single line Matlab string: matrix is enclosed by parentheses, rows are separated by semicolon and single cells by blanks, e.g., [1 2; 3 4].- Returns:
- the matrix in Matlab single line format
 
- 
parseMatlabDeprecated.creates a matrix from the given Matlab string.- Parameters:
- matlab- the matrix in matlab format
- Returns:
- the matrix represented by the given string
- Throws:
- Exception
- See Also:
 
- 
getRevisionDeprecated.Returns the revision string.- Specified by:
- getRevisionin interface- RevisionHandler
- Returns:
- the revision
 
- 
mainDeprecated.Main method for testing this class.
 
- 
weka.core.matrix.Matrixinstead - only for backwards compatibility.