org.apache.mahout.math
Interface Matrix

All Superinterfaces:
java.lang.Cloneable, java.lang.Iterable<MatrixSlice>, VectorIterable
All Known Implementing Classes:
AbstractMatrix, DenseMatrix, MatrixView, SparseColumnMatrix, SparseMatrix, SparseRowMatrix

public interface Matrix
extends java.lang.Cloneable, VectorIterable

The basic interface including numerous convenience functions


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 assignColumn(int column, Vector other)
          Assign the other vector values to the column of the receiver
 Matrix assignRow(int row, Vector other)
          Assign the other vector values to the row of the receiver
 Matrix clone()
          Return a copy of the recipient
 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
 Vector getColumn(int column)
          Return the column at the given index
 java.util.Map<java.lang.String,java.lang.Integer> getColumnLabelBindings()
          Return a map of the current column label bindings of the receiver
 int[] getNumNondefaultElements()
          Return the number of values in the recipient
 double getQuick(int row, int column)
          Return the value at the given indexes, without checking bounds
 Vector getRow(int row)
          Return the row at the given index
 java.util.Map<java.lang.String,java.lang.Integer> getRowLabelBindings()
          Return a map of the current row label bindings of the receiver
 Matrix like()
          Return an empty matrix of the same underlying class as the receiver
 Matrix like(int rows, int columns)
          Return an empty matrix of the same underlying class as the receiver and of the given cardinality
 Matrix minus(Matrix x)
          Return a new matrix containing the element by element difference of the recipient and the argument
 Matrix plus(double x)
          Return a new matrix containing the sum of each value of the recipient and the argument
 Matrix plus(Matrix x)
          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 setQuick(int row, int column, double value)
          Set the value at the given index, without checking bounds
 void setRowLabelBindings(java.util.Map<java.lang.String,java.lang.Integer> bindings)
          Sets a map of row label bindings in the receiver
 int[] size()
          Return the cardinality of the recipient (the maximum number of values)
 Matrix times(double x)
          Return a new matrix containing the product of each value of the recipient and the argument
 Matrix times(Matrix x)
          Return a new matrix containing the product of the recipient and the argument
 Matrix transpose()
          Return a new matrix that is the transpose of the receiver
 Matrix viewPart(int[] offset, int[] size)
          Return a new matrix containing the subset of the recipient
 double zSum()
          Return the sum of all the elements of the receiver
 
Methods inherited from interface org.apache.mahout.math.VectorIterable
iterateAll, numCols, numRows, numSlices, times, timesSquared
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

asFormatString

java.lang.String asFormatString()
Returns:
a formatted String suitable for output

assign

Matrix assign(double value)
Assign the value to all elements of the receiver

Parameters:
value - a double value
Returns:
the modified receiver

assign

Matrix assign(double[][] values)
Assign the values to the receiver

Parameters:
values - a double[] of values
Returns:
the modified receiver
Throws:
CardinalityException - if the cardinalities differ

assign

Matrix assign(Matrix other)
Assign the other vector values to the receiver

Parameters:
other - a Matrix
Returns:
the modified receiver
Throws:
CardinalityException - if the cardinalities differ

assign

Matrix assign(UnaryFunction function)
Apply the function to each element of the receiver

Parameters:
function - a UnaryFunction to apply
Returns:
the modified receiver

assign

Matrix assign(Matrix other,
              BinaryFunction function)
Apply the function to each element of the receiver and the corresponding element of the other argument

Parameters:
other - a Matrix containing the second arguments to the function
function - a BinaryFunction to apply
Returns:
the modified receiver
Throws:
CardinalityException - if the cardinalities differ

assignColumn

Matrix assignColumn(int column,
                    Vector other)
Assign the other vector values to the column of the receiver

Parameters:
column - the int row to assign
other - a Vector
Returns:
the modified receiver
Throws:
CardinalityException - if the cardinalities differ

assignRow

Matrix assignRow(int row,
                 Vector other)
Assign the other vector values to the row of the receiver

Parameters:
row - the int row to assign
other - a Vector
Returns:
the modified receiver
Throws:
CardinalityException - if the cardinalities differ

size

int[] size()
Return the cardinality of the recipient (the maximum number of values)

Returns:
an int[2]

clone

Matrix clone()
Return a copy of the recipient

Returns:
a new Matrix

determinant

double determinant()
Returns matrix determinator using Laplace theorem

Returns:
a matrix determinator

divide

Matrix divide(double x)
Return a new matrix containing the values of the recipient divided by the argument

Parameters:
x - a double value
Returns:
a new Matrix

get

double get(int row,
           int column)
Return the value at the given indexes

Parameters:
row - an int row index
column - an int column index
Returns:
the double at the index
Throws:
IndexException - if the index is out of bounds

getColumn

Vector getColumn(int column)
Return the column at the given index

Parameters:
column - an int column index
Returns:
a Vector at the index
Throws:
IndexException - if the index is out of bounds

getRow

Vector getRow(int row)
Return the row at the given index

Parameters:
row - an int row index
Returns:
a Vector at the index
Throws:
IndexException - if the index is out of bounds

getQuick

double getQuick(int row,
                int column)
Return the value at the given indexes, without checking bounds

Parameters:
row - an int row index
column - an int column index
Returns:
the double at the index

like

Matrix like()
Return an empty matrix of the same underlying class as the receiver

Returns:
a Matrix

like

Matrix like(int rows,
            int columns)
Return an empty matrix of the same underlying class as the receiver and of the given cardinality

Parameters:
rows - the int number of rows
columns - the int number of columns

minus

Matrix minus(Matrix x)
Return a new matrix containing the element by element difference of the recipient and the argument

Parameters:
x - a Matrix
Returns:
a new Matrix
Throws:
CardinalityException - if the cardinalities differ

plus

Matrix plus(double x)
Return a new matrix containing the sum of each value of the recipient and the argument

Parameters:
x - a double
Returns:
a new Matrix

plus

Matrix plus(Matrix x)
Return a new matrix containing the element by element sum of the recipient and the argument

Parameters:
x - a Matrix
Returns:
a new Matrix
Throws:
CardinalityException - if the cardinalities differ

set

void set(int row,
         int column,
         double value)
Set the value at the given index

Parameters:
row - an int row index into the receiver
column - an int column index into the receiver
value - a double value to set
Throws:
IndexException - if the index is out of bounds

set

void set(int row,
         double[] data)

setQuick

void setQuick(int row,
              int column,
              double value)
Set the value at the given index, without checking bounds

Parameters:
row - an int row index into the receiver
column - an int column index into the receiver
value - a double value to set

getNumNondefaultElements

int[] getNumNondefaultElements()
Return the number of values in the recipient

Returns:
an int[2] containing [row, column] count

times

Matrix times(double x)
Return a new matrix containing the product of each value of the recipient and the argument

Parameters:
x - a double argument
Returns:
a new Matrix

times

Matrix times(Matrix x)
Return a new matrix containing the product of the recipient and the argument

Parameters:
x - a Matrix argument
Returns:
a new Matrix
Throws:
CardinalityException - if the cardinalities are incompatible

transpose

Matrix transpose()
Return a new matrix that is the transpose of the receiver

Returns:
the transpose

viewPart

Matrix viewPart(int[] offset,
                int[] size)
Return a new matrix containing the subset of the recipient

Parameters:
offset - an int[2] offset into the receiver
size - the int[2] size of the desired result
Returns:
a new Matrix
Throws:
CardinalityException - if the length is greater than the cardinality of the receiver
IndexException - if the offset is negative or the offset+length is outside of the receiver

zSum

double zSum()
Return the sum of all the elements of the receiver

Returns:
a double

getColumnLabelBindings

java.util.Map<java.lang.String,java.lang.Integer> getColumnLabelBindings()
Return a map of the current column label bindings of the receiver

Returns:
a Map

getRowLabelBindings

java.util.Map<java.lang.String,java.lang.Integer> getRowLabelBindings()
Return a map of the current row label bindings of the receiver

Returns:
a Map

setColumnLabelBindings

void setColumnLabelBindings(java.util.Map<java.lang.String,java.lang.Integer> bindings)
Sets a map of column label bindings in the receiver

Parameters:
bindings - a Map of label bindings

setRowLabelBindings

void setRowLabelBindings(java.util.Map<java.lang.String,java.lang.Integer> bindings)
Sets a map of row label bindings in the receiver

Parameters:
bindings - a Map of label bindings

get

double get(java.lang.String rowLabel,
           java.lang.String columnLabel)
           throws IndexException,
                  UnboundLabelException
Return the value at the given labels

Parameters:
rowLabel - a String row label
columnLabel - a String column label
Returns:
the double at the index
Throws:
IndexException - if the index is out of bounds
UnboundLabelException

set

void set(java.lang.String rowLabel,
         java.lang.String columnLabel,
         double value)
         throws IndexException,
                UnboundLabelException
Set the value at the given index

Parameters:
rowLabel - a String row label
columnLabel - a String column label
value - a double value to set
Throws:
IndexException - if the index is out of bounds
UnboundLabelException

set

void set(java.lang.String rowLabel,
         java.lang.String columnLabel,
         int row,
         int column,
         double value)
         throws IndexException,
                UnboundLabelException
Set the value at the given index, updating the row and column label bindings

Parameters:
rowLabel - a String row label
columnLabel - a String column label
row - an int row index
column - an int column index
value - a double value
Throws:
IndexException
UnboundLabelException

set

void set(java.lang.String rowLabel,
         double[] rowData)
Sets the row values at the given row label

Parameters:
rowLabel - a String row label
rowData - a double[] array of row data

set

void set(java.lang.String rowLabel,
         int row,
         double[] rowData)
Sets the row values at the given row index and updates the row labels

Parameters:
rowLabel - the String row label
row - an int the row index
rowData - a double[] array of row data


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.