org.apache.mahout.math
Class VectorList

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

public class VectorList
extends AbstractMatrix

Provides a very flexible matrix that is based on a simple list of vectors.


Nested Class Summary
protected static class VectorList.JsonVectorListAdapter
           
 
Nested classes/interfaces inherited from class org.apache.mahout.math.AbstractMatrix
AbstractMatrix.TransposeViewVector
 
Field Summary
 
Fields inherited from class org.apache.mahout.math.AbstractMatrix
cardinality, COL, columnLabelBindings, ROW, rowLabelBindings
 
Constructor Summary
VectorList(int columns)
           
VectorList(int rows, int columns)
           
 
Method Summary
 void adjoinRow(Matrix other)
           
 void adjoinRow(Vector vector)
           
 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
 int columnSize()
           
 Vector getColumn(int column)
          Return the column at the given index
 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
 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 rowSize()
           
 void setQuick(int row, int column, double value)
          Set the value at the given index, without checking bounds
 int[] size()
          Return the cardinality of the recipient (the maximum number of values)
 Matrix viewPart(int[] offset, int[] size)
          Return a new matrix containing the subset of the recipient
 
Methods inherited from class org.apache.mahout.math.AbstractMatrix
aggregate, aggregateColumns, aggregateRows, asFormatString, assign, assign, assign, assign, assign, clone, decodeMatrix, determinant, divide, get, get, getColumnLabelBindings, getRowLabelBindings, iterateAll, iterator, minus, numCols, numRows, numSlices, plus, plus, set, set, set, set, set, set, setColumnLabelBindings, setRowLabelBindings, slice, times, times, times, timesSquared, transpose, viewColumn, viewPart, viewRow, zSum
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorList

public VectorList(int columns)

VectorList

public VectorList(int rows,
                  int columns)
Method Detail

columnSize

public int columnSize()
Specified by:
columnSize in interface Matrix
Overrides:
columnSize in class AbstractMatrix
Returns:
The number of rows in the matrix.

rowSize

public int rowSize()
Specified by:
rowSize in interface Matrix
Overrides:
rowSize in class AbstractMatrix
Returns:
Returns the number of rows in the matrix.

size

public int[] size()
Description copied from interface: Matrix
Return the cardinality of the recipient (the maximum number of values)

Specified by:
size in interface Matrix
Overrides:
size in class AbstractMatrix
Returns:
an int[2]

assignColumn

public Matrix assignColumn(int column,
                           Vector other)
Description copied from interface: Matrix
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

assignRow

public Matrix assignRow(int row,
                        Vector other)
Description copied from interface: Matrix
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

getColumn

public Vector getColumn(int column)
Description copied from interface: Matrix
Return the column at the given index

Parameters:
column - an int column index
Returns:
a Vector at the index

getRow

public 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

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

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

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

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

adjoinRow

public void adjoinRow(Vector vector)

adjoinRow

public void adjoinRow(Matrix other)


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