org.apache.mahout.math
Class PivotedMatrix

java.lang.Object
  extended by org.apache.mahout.math.AbstractMatrix
      extended by org.apache.mahout.math.PivotedMatrix
All Implemented Interfaces:
Cloneable, Iterable<MatrixSlice>, Matrix, VectorIterable

public class PivotedMatrix
extends AbstractMatrix

Matrix that allows transparent row and column permutation.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.mahout.math.AbstractMatrix
AbstractMatrix.TransposeViewVector
 
Field Summary
 
Fields inherited from class org.apache.mahout.math.AbstractMatrix
COL, columnLabelBindings, columns, ROW, rowLabelBindings, rows
 
Constructor Summary
PivotedMatrix(Matrix base)
           
PivotedMatrix(Matrix base, int[] pivot)
           
PivotedMatrix(Matrix base, int[] rowPivot, int[] columnPivot)
           
 
Method Summary
 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
 int columnUnpivot(int k)
           
 Matrix getBase()
           
 int[] getColumnPivot()
           
 int[] getInverseColumnPivot()
           
 int[] getInverseRowPivot()
           
 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
 int[] getRowPivot()
           
 Matrix like()
          Return an empty matrix of the same underlying class as the receiver
 Matrix like(int rows, int columns)
          Returns an empty matrix of the same underlying class as the receiver and of the specified size.
 int rowUnpivot(int k)
           
 void setQuick(int row, int column, double value)
          Set the value at the given index, without checking bounds
 void swap(int i, int j)
          Swaps indexes i and j.
 void swapColumns(int i, int j)
          Swaps indexes i and j.
 void swapRows(int i, int j)
          Swaps indexes i and j.
 Vector viewColumn(int column)
          Return the column at the given index
 Matrix viewPart(int[] offset, int[] size)
          Return a new matrix containing the subset of the recipient
 Vector viewRow(int row)
          Return the row at the given index
 
Methods inherited from class org.apache.mahout.math.AbstractMatrix
aggregate, aggregateColumns, aggregateRows, asFormatString, assign, assign, assign, assign, assign, columnSize, determinant, divide, get, get, getColumnLabelBindings, getRowLabelBindings, iterateAll, iterator, minus, numCols, numRows, numSlices, plus, plus, rowSize, set, set, set, set, set, set, setColumnLabelBindings, setRowLabelBindings, times, times, times, timesSquared, toString, transpose, viewDiagonal, viewPart, zSum
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PivotedMatrix

public PivotedMatrix(Matrix base,
                     int[] pivot)

PivotedMatrix

public PivotedMatrix(Matrix base,
                     int[] rowPivot,
                     int[] columnPivot)

PivotedMatrix

public PivotedMatrix(Matrix base)
Method Detail

swap

public void swap(int i,
                 int j)
Swaps indexes i and j. This does both row and column permutation.

Parameters:
i - First index to swap.
j - Second index to swap.

swapRows

public void swapRows(int i,
                     int j)
Swaps indexes i and j. This does just row permutation.

Parameters:
i - First index to swap.
j - Second index to swap.

swapColumns

public void swapColumns(int i,
                        int j)
Swaps indexes i and j. This does just row permutation.

Parameters:
i - First index to swap.
j - Second index to swap.

assignColumn

public 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

public 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

viewColumn

public Vector viewColumn(int column)
Return the column at the given index

Specified by:
viewColumn in interface Matrix
Overrides:
viewColumn in class AbstractMatrix
Parameters:
column - an int column index
Returns:
a Vector at the index
Throws:
IndexException - if the index is out of bounds

viewRow

public Vector viewRow(int row)
Return the row at the given index

Specified by:
viewRow in interface Matrix
Overrides:
viewRow in class AbstractMatrix
Parameters:
row - an int row index
Returns:
a Vector at the index
Throws:
IndexException - if the index is out of bounds

getQuick

public 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

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

Returns:
a Matrix

clone

public Matrix clone()
Description copied from interface: Matrix
Return a copy of the recipient

Specified by:
clone in interface Matrix
Overrides:
clone in class AbstractMatrix
Returns:
a new Matrix

like

public Matrix like(int rows,
                   int columns)
Returns an empty matrix of the same underlying class as the receiver and of the specified size.

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

setQuick

public 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

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

Specified by:
getNumNondefaultElements in interface Matrix
Overrides:
getNumNondefaultElements in class AbstractMatrix
Returns:
an int[2] containing [row, column] count

viewPart

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

Specified by:
viewPart in interface Matrix
Overrides:
viewPart in class AbstractMatrix
Parameters:
offset - an int[2] offset into the receiver
size - the int[2] size of the desired result
Returns:
a new Matrix that is a view of the original
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

rowUnpivot

public int rowUnpivot(int k)

columnUnpivot

public int columnUnpivot(int k)

getRowPivot

public int[] getRowPivot()

getInverseRowPivot

public int[] getInverseRowPivot()

getColumnPivot

public int[] getColumnPivot()

getInverseColumnPivot

public int[] getInverseColumnPivot()

getBase

public Matrix getBase()


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.