org.apache.mahout.math
Class DenseMatrix

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

public class DenseMatrix
extends AbstractMatrix

Matrix of doubles implemented using a 2-d array


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.mahout.math.AbstractMatrix
AbstractMatrix.TransposeViewVector
 
Field Summary
protected  double[][] values
           
 
Fields inherited from class org.apache.mahout.math.AbstractMatrix
COL, columnLabelBindings, ROW, rowLabelBindings
 
Constructor Summary
DenseMatrix()
           
DenseMatrix(double[][] values)
          Construct a matrix from the given values
DenseMatrix(int rows, int columns)
          Construct an empty matrix of the given size
 
Method Summary
 Matrix assign(double value)
          Assign the value to all elements 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
protected  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)
          Return an empty matrix of the same underlying class as the receiver and of the given cardinality
protected  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
asFormatString, assign, assign, assign, assign, 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, zSum
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

protected double[][] values
Constructor Detail

DenseMatrix

public DenseMatrix()

DenseMatrix

public DenseMatrix(double[][] values)
Construct a matrix from the given values

Parameters:
values - a double[][]

DenseMatrix

public DenseMatrix(int rows,
                   int columns)
Construct an empty matrix of the given size

Method Detail

columnSize

protected int columnSize()

rowSize

protected int rowSize()

size

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

Returns:
an int[2]

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

getQuick

public double getQuick(int row,
                       int column)
Description copied from interface: Matrix
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()
Description copied from interface: Matrix
Return an empty matrix of the same underlying class as the receiver

Returns:
a Matrix

like

public Matrix like(int rows,
                   int columns)
Description copied from interface: Matrix
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

setQuick

public void setQuick(int row,
                     int column,
                     double value)
Description copied from interface: Matrix
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()
Description copied from interface: Matrix
Return the number of values in the recipient

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

viewPart

public Matrix viewPart(int[] offset,
                       int[] size)
Description copied from interface: Matrix
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

assign

public Matrix assign(double value)
Description copied from interface: Matrix
Assign the value to all elements of the receiver

Specified by:
assign in interface Matrix
Overrides:
assign in class AbstractMatrix
Parameters:
value - a double value
Returns:
the modified receiver

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)
Description copied from interface: Matrix
Return the row at the given index

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


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