|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.math.AbstractMatrix
public abstract class AbstractMatrix
A few universal implementations of convenience functions
Nested Class Summary | |
---|---|
protected class |
AbstractMatrix.TransposeViewVector
|
Field Summary | |
---|---|
static int |
COL
|
protected java.util.Map<java.lang.String,java.lang.Integer> |
columnLabelBindings
|
static int |
ROW
|
protected java.util.Map<java.lang.String,java.lang.Integer> |
rowLabelBindings
|
Constructor Summary | |
---|---|
AbstractMatrix()
|
Method Summary | |
---|---|
java.lang.String |
asFormatString()
|
Matrix |
assign(double value)
Assign the value to all elements of the receiver |
Matrix |
assign(double[][] values)
Assign the values to the receiver |
Matrix |
assign(Matrix other)
Assign the other vector values to the receiver |
Matrix |
assign(Matrix other,
BinaryFunction function)
Apply the function to each element of the receiver and the corresponding element of the other argument |
Matrix |
assign(UnaryFunction function)
Apply the function to each element of the receiver |
Matrix |
clone()
Return a copy of the recipient |
static Matrix |
decodeMatrix(java.lang.String formatString)
|
double |
determinant()
Returns matrix determinator using Laplace theorem |
Matrix |
divide(double x)
Return a new matrix containing the values of the recipient divided by the argument |
double |
get(int row,
int column)
Return the value at the given indexes |
double |
get(java.lang.String rowLabel,
java.lang.String columnLabel)
Return the value at the given labels |
java.util.Map<java.lang.String,java.lang.Integer> |
getColumnLabelBindings()
Return a map of the current column label bindings of the receiver |
java.util.Map<java.lang.String,java.lang.Integer> |
getRowLabelBindings()
Return a map of the current row label bindings of the receiver |
java.util.Iterator<MatrixSlice> |
iterateAll()
|
java.util.Iterator<MatrixSlice> |
iterator()
|
Matrix |
minus(Matrix other)
Return a new matrix containing the element by element difference of the recipient and the argument |
int |
numCols()
|
int |
numRows()
|
int |
numSlices()
Abstracted out for the iterator |
Matrix |
plus(double x)
Return a new matrix containing the sum of each value of the recipient and the argument |
Matrix |
plus(Matrix other)
Return a new matrix containing the element by element sum of the recipient and the argument |
void |
set(int row,
double[] data)
|
void |
set(int row,
int column,
double value)
Set the value at the given index |
void |
set(java.lang.String rowLabel,
double[] rowData)
Sets the row values at the given row label |
void |
set(java.lang.String rowLabel,
int row,
double[] rowData)
Sets the row values at the given row index and updates the row labels |
void |
set(java.lang.String rowLabel,
java.lang.String columnLabel,
double value)
Set the value at the given index |
void |
set(java.lang.String rowLabel,
java.lang.String columnLabel,
int row,
int column,
double value)
Set the value at the given index, updating the row and column label bindings |
void |
setColumnLabelBindings(java.util.Map<java.lang.String,java.lang.Integer> bindings)
Sets a map of column label bindings in the receiver |
void |
setRowLabelBindings(java.util.Map<java.lang.String,java.lang.Integer> bindings)
Sets a map of row label bindings in the receiver |
protected Vector |
slice(int index)
Abstracted out for iterating over either rows or columns (default is rows). |
Matrix |
times(double x)
Return a new matrix containing the product of each value of the recipient and the argument |
Matrix |
times(Matrix other)
Return a new matrix containing the product of the recipient and the argument |
Vector |
times(Vector v)
Return a new vector with cardinality equal to getNumRows() of this matrix which is the matrix product of the recipient and the argument |
Vector |
timesSquared(Vector v)
Convenience method for producing this.transpose().times(this.times(v)), which can be implemented with only one pass over the matrix, without making the transpose() call (which can be expensive if the matrix is sparse) |
Matrix |
transpose()
Return a new matrix that is the transpose of the receiver |
double |
zSum()
Return the sum of all the elements of the receiver |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.mahout.math.Matrix |
---|
assignColumn, assignRow, getColumn, getNumNondefaultElements, getQuick, getRow, like, like, setQuick, size, viewPart |
Field Detail |
---|
protected java.util.Map<java.lang.String,java.lang.Integer> columnLabelBindings
protected java.util.Map<java.lang.String,java.lang.Integer> rowLabelBindings
public static final int COL
public static final int ROW
Constructor Detail |
---|
public AbstractMatrix()
Method Detail |
---|
public java.util.Iterator<MatrixSlice> iterator()
iterator
in interface java.lang.Iterable<MatrixSlice>
public java.util.Iterator<MatrixSlice> iterateAll()
iterateAll
in interface VectorIterable
protected Vector slice(int index)
index
- the row or column number to grab as a vector (shallowly)
public int numSlices()
numSlices
in interface VectorIterable
public double get(java.lang.String rowLabel, java.lang.String columnLabel) throws IndexException, UnboundLabelException
Matrix
get
in interface Matrix
rowLabel
- a String row labelcolumnLabel
- a String column label
IndexException
- if the index is out of bounds
UnboundLabelException
public java.util.Map<java.lang.String,java.lang.Integer> getColumnLabelBindings()
Matrix
getColumnLabelBindings
in interface Matrix
public java.util.Map<java.lang.String,java.lang.Integer> getRowLabelBindings()
Matrix
getRowLabelBindings
in interface Matrix
public void set(java.lang.String rowLabel, double[] rowData)
Matrix
set
in interface Matrix
rowLabel
- a String row labelrowData
- a double[] array of row datapublic void set(java.lang.String rowLabel, int row, double[] rowData)
Matrix
set
in interface Matrix
rowLabel
- the String row labelrow
- an int the row indexrowData
- a double[] array of row datapublic void set(java.lang.String rowLabel, java.lang.String columnLabel, double value) throws IndexException, UnboundLabelException
Matrix
set
in interface Matrix
rowLabel
- a String row labelcolumnLabel
- a String column labelvalue
- a double value to set
IndexException
- if the index is out of bounds
UnboundLabelException
public void set(java.lang.String rowLabel, java.lang.String columnLabel, int row, int column, double value) throws IndexException, UnboundLabelException
Matrix
set
in interface Matrix
rowLabel
- a String row labelcolumnLabel
- a String column labelrow
- an int row indexcolumn
- an int column indexvalue
- a double value
IndexException
UnboundLabelException
public void setColumnLabelBindings(java.util.Map<java.lang.String,java.lang.Integer> bindings)
Matrix
setColumnLabelBindings
in interface Matrix
bindings
- a Mappublic void setRowLabelBindings(java.util.Map<java.lang.String,java.lang.Integer> bindings)
Matrix
setRowLabelBindings
in interface Matrix
bindings
- a Mappublic int numRows()
numRows
in interface VectorIterable
public int numCols()
numCols
in interface VectorIterable
public static Matrix decodeMatrix(java.lang.String formatString)
public java.lang.String asFormatString()
asFormatString
in interface Matrix
public Matrix assign(double value)
Matrix
assign
in interface Matrix
value
- a double value
public Matrix assign(double[][] values)
Matrix
assign
in interface Matrix
values
- a double[] of values
public Matrix assign(Matrix other, BinaryFunction function)
Matrix
assign
in interface Matrix
other
- a Matrix containing the second arguments to the functionfunction
- a BinaryFunction to apply
public Matrix assign(Matrix other)
Matrix
assign
in interface Matrix
other
- a Matrix
public Matrix assign(UnaryFunction function)
Matrix
assign
in interface Matrix
function
- a UnaryFunction to apply
public double determinant()
Matrix
determinant
in interface Matrix
public Matrix clone()
Matrix
clone
in interface Matrix
clone
in class java.lang.Object
public Matrix divide(double x)
Matrix
divide
in interface Matrix
x
- a double value
public double get(int row, int column)
Matrix
get
in interface Matrix
row
- an int row indexcolumn
- an int column index
public Matrix minus(Matrix other)
Matrix
minus
in interface Matrix
other
- a Matrix
public Matrix plus(double x)
Matrix
plus
in interface Matrix
x
- a double
public Matrix plus(Matrix other)
Matrix
plus
in interface Matrix
other
- a Matrix
public void set(int row, int column, double value)
Matrix
set
in interface Matrix
row
- an int row index into the receivercolumn
- an int column index into the receivervalue
- a double value to setpublic void set(int row, double[] data)
set
in interface Matrix
public Matrix times(double x)
Matrix
times
in interface Matrix
x
- a double argument
public Matrix times(Matrix other)
Matrix
times
in interface Matrix
other
- a Matrix argument
public Vector times(Vector v)
VectorIterable
times
in interface VectorIterable
v
- a vector with cardinality equal to getNumCols() of the recipient
public Vector timesSquared(Vector v)
VectorIterable
timesSquared
in interface VectorIterable
v
- a vector with cardinality equal to getNumCols() of the recipient
public Matrix transpose()
Matrix
transpose
in interface Matrix
public double zSum()
Matrix
zSum
in interface Matrix
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |