|
||||||||||
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 static class |
AbstractMatrix.TransposeViewVector
|
Field Summary | |
---|---|
static int |
COL
|
protected Map<String,Integer> |
columnLabelBindings
|
protected int |
columns
|
static int |
ROW
|
protected Map<String,Integer> |
rowLabelBindings
|
protected int |
rows
|
Constructor Summary | |
---|---|
protected |
AbstractMatrix(int rows,
int columns)
|
Method Summary | |
---|---|
double |
aggregate(DoubleDoubleFunction combiner,
DoubleFunction mapper)
Collects the results of a function applied to each element of a matrix and then aggregated. |
Vector |
aggregateColumns(VectorFunction f)
Collects the results of a function applied to each column of a matrix. |
Vector |
aggregateRows(VectorFunction f)
Collects the results of a function applied to each row of a matrix. |
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(DoubleFunction function)
Apply the function to each element of the receiver |
Matrix |
assign(Matrix other)
Assign the other vector values to the receiver |
Matrix |
assign(Matrix other,
DoubleDoubleFunction function)
Apply the function to each element of the receiver and the corresponding element of the other argument |
Matrix |
clone()
Return a copy of the recipient |
int |
columnSize()
|
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(String rowLabel,
String columnLabel)
Return the value at the given labels |
Map<String,Integer> |
getColumnLabelBindings()
Return a map of the current column label bindings of the receiver |
int[] |
getNumNondefaultElements()
Return the number of values in the recipient |
Map<String,Integer> |
getRowLabelBindings()
Return a map of the current row label bindings of the receiver |
Iterator<MatrixSlice> |
iterateAll()
|
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 |
int |
rowSize()
|
void |
set(int row,
double[] data)
|
void |
set(int row,
int column,
double value)
Set the value at the given index |
void |
set(String rowLabel,
double[] rowData)
Sets the row values at the given row label |
void |
set(String rowLabel,
int row,
double[] rowData)
Sets the row values at the given row index and updates the row labels |
void |
set(String rowLabel,
String columnLabel,
double value)
Set the value at the given index |
void |
set(String rowLabel,
String columnLabel,
int row,
int column,
double value)
Set the value at the given index, updating the row and column label bindings |
void |
setColumnLabelBindings(Map<String,Integer> bindings)
Sets a map of column label bindings in the receiver |
void |
setRowLabelBindings(Map<String,Integer> bindings)
Sets a map of row label bindings in the receiver |
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) |
String |
toString()
|
Matrix |
transpose()
Return a new matrix that is the transpose of the receiver |
Vector |
viewColumn(int column)
Returns a view of a row. |
Vector |
viewDiagonal()
Provides a view of the diagonal of a matrix. |
Matrix |
viewPart(int[] offset,
int[] size)
Return a view into part of a matrix. |
Matrix |
viewPart(int rowOffset,
int rowsRequested,
int columnOffset,
int columnsRequested)
Return a view into part of a matrix. |
Vector |
viewRow(int row)
Returns a view of a row. |
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, wait, wait, wait |
Methods inherited from interface org.apache.mahout.math.Matrix |
---|
assignColumn, assignRow, getQuick, like, like, setQuick |
Field Detail |
---|
protected Map<String,Integer> columnLabelBindings
protected Map<String,Integer> rowLabelBindings
protected int rows
protected int columns
public static final int COL
public static final int ROW
Constructor Detail |
---|
protected AbstractMatrix(int rows, int columns)
Method Detail |
---|
public int columnSize()
columnSize
in interface Matrix
public int rowSize()
rowSize
in interface Matrix
public Iterator<MatrixSlice> iterator()
iterator
in interface Iterable<MatrixSlice>
public Iterator<MatrixSlice> iterateAll()
iterateAll
in interface VectorIterable
public int numSlices()
numSlices
in interface VectorIterable
public double get(String rowLabel, String columnLabel)
Matrix
get
in interface Matrix
rowLabel
- a String row labelcolumnLabel
- a String column label
public Map<String,Integer> getColumnLabelBindings()
Matrix
getColumnLabelBindings
in interface Matrix
public Map<String,Integer> getRowLabelBindings()
Matrix
getRowLabelBindings
in interface Matrix
public void set(String rowLabel, double[] rowData)
Matrix
set
in interface Matrix
rowLabel
- a String row labelrowData
- a double[] array of row datapublic void set(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(String rowLabel, String columnLabel, double value)
Matrix
set
in interface Matrix
rowLabel
- a String row labelcolumnLabel
- a String column labelvalue
- a double value to setpublic void set(String rowLabel, String columnLabel, int row, int column, double value)
Matrix
set
in interface Matrix
rowLabel
- a String row labelcolumnLabel
- a String column labelrow
- an int row indexcolumn
- an int column indexvalue
- a double valuepublic void setColumnLabelBindings(Map<String,Integer> bindings)
Matrix
setColumnLabelBindings
in interface Matrix
bindings
- a Mappublic void setRowLabelBindings(Map<String,Integer> bindings)
Matrix
setRowLabelBindings
in interface Matrix
bindings
- a Mappublic int numRows()
numRows
in interface VectorIterable
public int numCols()
numCols
in interface VectorIterable
public 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, DoubleDoubleFunction function)
Matrix
assign
in interface Matrix
other
- a Matrix containing the second arguments to the functionfunction
- a DoubleDoubleFunction to apply
public Matrix assign(Matrix other)
Matrix
assign
in interface Matrix
other
- a Matrix
public Matrix assign(DoubleFunction function)
Matrix
assign
in interface Matrix
function
- a DoubleFunction to apply
public Vector aggregateRows(VectorFunction f)
aggregateRows
in interface Matrix
f
- The function to be applied to each row.
public Vector viewRow(int row)
viewRow
in interface Matrix
row
- Which row to return.
public Vector viewColumn(int column)
viewColumn
in interface Matrix
column
- Which column to return.
public Vector viewDiagonal()
viewDiagonal
in interface Matrix
public double aggregate(DoubleDoubleFunction combiner, DoubleFunction mapper)
aggregate
in interface Matrix
combiner
- A function that combines the results of the mapper.mapper
- A function to apply to each element.
public Vector aggregateColumns(VectorFunction f)
aggregateColumns
in interface Matrix
f
- The function to be applied to each column.
public double determinant()
Matrix
determinant
in interface Matrix
public Matrix clone()
Matrix
clone
in interface Matrix
clone
in class 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 Matrix viewPart(int rowOffset, int rowsRequested, int columnOffset, int columnsRequested)
Matrix
viewPart
in interface Matrix
rowOffset
- The first row of the viewrowsRequested
- The number of rows in the viewcolumnOffset
- The first column in the viewcolumnsRequested
- The number of columns in the view
public Matrix viewPart(int[] offset, int[] size)
Matrix
viewPart
in interface Matrix
offset
- an int[2] offset into the receiversize
- the int[2] size of the desired result
public double zSum()
Matrix
zSum
in interface Matrix
public int[] getNumNondefaultElements()
Matrix
getNumNondefaultElements
in interface Matrix
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |