|
||||||||||
| 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 Matrixpublic int rowSize()
rowSize in interface Matrixpublic Iterator<MatrixSlice> iterator()
iterator in interface Iterable<MatrixSlice>public Iterator<MatrixSlice> iterateAll()
iterateAll in interface VectorIterablepublic int numSlices()
numSlices in interface VectorIterable
public double get(String rowLabel,
String columnLabel)
Matrix
get in interface MatrixrowLabel - a String row labelcolumnLabel - a String column label
public Map<String,Integer> getColumnLabelBindings()
Matrix
getColumnLabelBindings in interface Matrixpublic Map<String,Integer> getRowLabelBindings()
Matrix
getRowLabelBindings in interface Matrix
public void set(String rowLabel,
double[] rowData)
Matrix
set in interface MatrixrowLabel - a String row labelrowData - a double[] array of row data
public void set(String rowLabel,
int row,
double[] rowData)
Matrix
set in interface MatrixrowLabel - the String row labelrow - an int the row indexrowData - a double[] array of row data
public void set(String rowLabel,
String columnLabel,
double value)
Matrix
set in interface MatrixrowLabel - a String row labelcolumnLabel - a String column labelvalue - a double value to set
public void set(String rowLabel,
String columnLabel,
int row,
int column,
double value)
Matrix
set in interface MatrixrowLabel - 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 Matrixbindings - a Mappublic void setRowLabelBindings(Map<String,Integer> bindings)
Matrix
setRowLabelBindings in interface Matrixbindings - a Mappublic int numRows()
numRows in interface VectorIterablepublic int numCols()
numCols in interface VectorIterablepublic String asFormatString()
asFormatString in interface Matrixpublic Matrix assign(double value)
Matrix
assign in interface Matrixvalue - a double value
public Matrix assign(double[][] values)
Matrix
assign in interface Matrixvalues - a double[] of values
public Matrix assign(Matrix other,
DoubleDoubleFunction function)
Matrix
assign in interface Matrixother - a Matrix containing the second arguments to the functionfunction - a DoubleDoubleFunction to apply
public Matrix assign(Matrix other)
Matrix
assign in interface Matrixother - a Matrix
public Matrix assign(DoubleFunction function)
Matrix
assign in interface Matrixfunction - a DoubleFunction to apply
public Vector aggregateRows(VectorFunction f)
aggregateRows in interface Matrixf - The function to be applied to each row.
public Vector viewRow(int row)
viewRow in interface Matrixrow - Which row to return.
public Vector viewColumn(int column)
viewColumn in interface Matrixcolumn - Which column to return.
public Vector viewDiagonal()
viewDiagonal in interface Matrix
public double aggregate(DoubleDoubleFunction combiner,
DoubleFunction mapper)
aggregate in interface Matrixcombiner - 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 Matrixf - The function to be applied to each column.
public double determinant()
Matrix
determinant in interface Matrixpublic Matrix clone()
Matrix
clone in interface Matrixclone in class Objectpublic Matrix divide(double x)
Matrix
divide in interface Matrixx - a double value
public double get(int row,
int column)
Matrix
get in interface Matrixrow - an int row indexcolumn - an int column index
public Matrix minus(Matrix other)
Matrix
minus in interface Matrixother - a Matrix
public Matrix plus(double x)
Matrix
plus in interface Matrixx - a double
public Matrix plus(Matrix other)
Matrix
plus in interface Matrixother - a Matrix
public void set(int row,
int column,
double value)
Matrix
set in interface Matrixrow - an int row index into the receivercolumn - an int column index into the receivervalue - a double value to set
public void set(int row,
double[] data)
set in interface Matrixpublic Matrix times(double x)
Matrix
times in interface Matrixx - a double argument
public Matrix times(Matrix other)
Matrix
times in interface Matrixother - a Matrix argument
public Vector times(Vector v)
VectorIterable
times in interface VectorIterablev - a vector with cardinality equal to getNumCols() of the recipient
public Vector timesSquared(Vector v)
VectorIterable
timesSquared in interface VectorIterablev - 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 MatrixrowOffset - 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 Matrixoffset - an int[2] offset into the receiversize - the int[2] size of the desired result
public double zSum()
Matrix
zSum in interface Matrixpublic int[] getNumNondefaultElements()
Matrix
getNumNondefaultElements in interface Matrixpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||