org.apache.mahout.math
Class DiagonalMatrix

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

public class DiagonalMatrix
extends AbstractMatrix
implements MatrixTimesOps


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
DiagonalMatrix(double[] values)
           
DiagonalMatrix(double value, int size)
           
DiagonalMatrix(Matrix values)
           
DiagonalMatrix(Vector values)
           
 
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
 int[] getNumNondefaultElements()
          Return the number of values in the recipient
 double getQuick(int row, int column)
          Return the value at the given location, without checking bounds
static DiagonalMatrix identity(int size)
           
 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.
 void setQuick(int row, int column, double value)
          Set the value at the given index, without checking bounds
 Matrix times(Matrix other)
          Return a new matrix containing the product of the recipient and the argument
 Matrix timesLeft(Matrix that)
          Computes matrix product of (that * this)
 Matrix timesRight(Matrix that)
          computes matrix product of (this * that)
 Vector viewDiagonal()
          Provides a view of the diagonal of a matrix.
 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, 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, timesSquared, toString, transpose, viewColumn, viewPart, viewRow, zSum
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiagonalMatrix

public DiagonalMatrix(Vector values)

DiagonalMatrix

public DiagonalMatrix(Matrix values)

DiagonalMatrix

public DiagonalMatrix(double value,
                      int size)

DiagonalMatrix

public DiagonalMatrix(double[] values)
Method Detail

identity

public static DiagonalMatrix identity(int size)

assignColumn

public Matrix assignColumn(int column,
                           Vector other)
Description copied from interface: Matrix
Assign the other vector values to the column of the receiver

Specified by:
assignColumn in interface Matrix
Parameters:
column - the int row to assign
other - a Vector
Returns:
the modified receiver

assignRow

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

Specified by:
assignRow in interface Matrix
Parameters:
row - the int row to assign
other - a Vector
Returns:
the modified receiver
Throws:
CardinalityException - if the cardinalities differ

viewDiagonal

public Vector viewDiagonal()
Provides a view of the diagonal of a matrix.

Specified by:
viewDiagonal in interface Matrix
Overrides:
viewDiagonal in class AbstractMatrix
Returns:
A vector that shares storage with the original matrix.

getQuick

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

Specified by:
getQuick in interface Matrix
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

Specified by:
like in interface Matrix
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.

Specified by:
like in interface Matrix
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

Specified by:
setQuick in interface Matrix
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

times

public Matrix times(Matrix other)
Description copied from interface: Matrix
Return a new matrix containing the product of the recipient and the argument

Specified by:
times in interface Matrix
Overrides:
times in class AbstractMatrix
Parameters:
other - a Matrix argument
Returns:
a new Matrix

timesRight

public Matrix timesRight(Matrix that)
Description copied from interface: MatrixTimesOps
computes matrix product of (this * that)

Specified by:
timesRight in interface MatrixTimesOps

timesLeft

public Matrix timesLeft(Matrix that)
Description copied from interface: MatrixTimesOps
Computes matrix product of (that * this)

Specified by:
timesLeft in interface MatrixTimesOps


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