org.genepattern.data.matrix
Class DoubleMatrix2D

java.lang.Object
  extended byorg.genepattern.data.matrix.DoubleMatrix2D

public class DoubleMatrix2D
extends java.lang.Object

A labelled dense 2-dimensional matrix holding double elements.


Constructor Summary
DoubleMatrix2D(double[][] data)
          Creates a new matrix
DoubleMatrix2D(double[][] data, java.lang.String[] rowNames, java.lang.String[] columnNames)
          Creates a new matrix
DoubleMatrix2D(int rows, int columns)
          Creates a new matrix
 
Method Summary
 DoubleMatrix2D copy()
          Make a deep copy of this matrix
 double det()
          Matrix determinant
 double get(int row, int column)
          Gets a single element
 double[][] getArray()
          Gets the underlying double[][] array
 int getColumnCount()
          Gets the column dimension.
 int getColumnIndex(java.lang.String columnName)
          Gets the column index for the column name .
 java.lang.String getColumnName(int columnIndex)
          Gets the column name at the specified index
 java.lang.String[] getColumnNames()
          Allocates a new array contains the column names
 double[] getRow(int row)
          Gets the underlying array at the given row
 int getRowCount()
          Gets the row dimension.
 int getRowIndex(java.lang.String rowName)
          Gets the row index for the row name .
 java.lang.String getRowName(int rowIndex)
          Gets the row name at the specified index
 java.lang.String[] getRowNames()
          Allocates a new array contains the row names
 DoubleMatrix2D minus(DoubleMatrix2D B)
          C = A - B
 DoubleMatrix2D plus(DoubleMatrix2D B)
          C = A + B
 void print(java.io.PrintStream ps, java.lang.String delimiter)
          Prints this matrix in delimitted format using the default number format.
 void print(java.io.PrintStream ps, java.lang.String delimiter, java.text.NumberFormat nf)
          Prints this matrix in delimitted format.
 int rank()
          Returns the effective numerical rank, obtained from Singular Value Decomposition.
 void set(int rowIndex, int columnIndex, double value)
          Sets a single element.
 void set(java.lang.String rowName, java.lang.String columnName, double value)
          Sets a single element.
 void setColumnName(int columnIndex, java.lang.String name)
          Sets the column name at the specified index
 void setRowName(int rowIndex, java.lang.String name)
          Sets the row name at the specified index
 DoubleMatrix2D slice(int[] rowIndices, int[] columnIndices)
          Constructs and returns a new matrix that contains the indicated cells.
 DoubleMatrix2D slice(java.lang.String[] rowNames, java.lang.String[] columnNames)
          Constructs and returns a new matrix that contains the indicated cells.
 DoubleMatrix2D times(double d)
          Multiply a matrix by a scalar, C = s*A
 DoubleMatrix2D times(DoubleMatrix2D B)
          Linear algebraic matrix multiplication, A * B
 double trace()
          Computes the sum of the diagonal elements of matrix A; Sum(A[i,i]).
 DoubleMatrix2D transpose()
          Matrix transpose.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleMatrix2D

public DoubleMatrix2D(double[][] data)
Creates a new matrix

Parameters:
data - The data.

DoubleMatrix2D

public DoubleMatrix2D(double[][] data,
                      java.lang.String[] rowNames,
                      java.lang.String[] columnNames)
Creates a new matrix

Parameters:
data - The data.
rowNames - the row names
columnNames - the column names

DoubleMatrix2D

public DoubleMatrix2D(int rows,
                      int columns)
Creates a new matrix

Parameters:
rows - The number of rows.
columns - The number of columns.
Method Detail

print

public void print(java.io.PrintStream ps,
                  java.lang.String delimiter)
Prints this matrix in delimitted format using the default number format.

Parameters:
ps - the print stream
delimiter - the delimiter between columns
See Also:
print(java.io.PrintStream, String, java.text.NumberFormat)

print

public void print(java.io.PrintStream ps,
                  java.lang.String delimiter,
                  java.text.NumberFormat nf)
Prints this matrix in delimitted format.

Parameters:
ps - the print stream
delimiter - the delimiter between columns
nf - the formatter

transpose

public DoubleMatrix2D transpose()
Matrix transpose.

Returns:
A'

slice

public DoubleMatrix2D slice(java.lang.String[] rowNames,
                            java.lang.String[] columnNames)
Constructs and returns a new matrix that contains the indicated cells. Names can be in arbitrary order.

Parameters:
rowNames - The row names of the cells in the new matrix. To indicate that the new matrix should contain all rows, set this parameter to null.
columnNames - The column names of the cells in the new matrix. To indicate that the new matrix should contain all columns, set this parameter to null.
Returns:
the new matrix
Throws:
java.lang.IllegalArgumentException - if an index occcurs more than once.
See Also:
slice(int[], int[])

slice

public DoubleMatrix2D slice(int[] rowIndices,
                            int[] columnIndices)
Constructs and returns a new matrix that contains the indicated cells. Indices can be in arbitrary order.

Parameters:
rowIndices - The rows of the cells in the new matrix. To indicate that the new matrix should contain all rows, set this parameter to null.
columnIndices - The columns of the cells in the new matrix. To indicate that the new matrix should contain all columns, set this parameter to null.
Returns:
the new matrix
Throws:
java.lang.IllegalArgumentException - if an index occcurs more than once.
See Also:
slice(String[], String[])

times

public DoubleMatrix2D times(DoubleMatrix2D B)
Linear algebraic matrix multiplication, A * B

Parameters:
B - another matrix
Returns:
Matrix product, A * B

times

public DoubleMatrix2D times(double d)
Multiply a matrix by a scalar, C = s*A

Parameters:
d - a scalar
Returns:
s*A

copy

public DoubleMatrix2D copy()
Make a deep copy of this matrix

Returns:
the copy.

plus

public DoubleMatrix2D plus(DoubleMatrix2D B)
C = A + B

Parameters:
B - another matrix
Returns:
A + B

minus

public DoubleMatrix2D minus(DoubleMatrix2D B)
C = A - B

Parameters:
B - another matrix
Returns:
A - B

det

public double det()
Matrix determinant

Returns:
The determinant.

rank

public int rank()
Returns the effective numerical rank, obtained from Singular Value Decomposition.

Returns:
The rank.

trace

public double trace()
Computes the sum of the diagonal elements of matrix A; Sum(A[i,i]).

Returns:
The trace.

set

public void set(int rowIndex,
                int columnIndex,
                double value)
Sets a single element.

Parameters:
value - A(row,column).
rowIndex - The row index.
columnIndex - The column index.

set

public void set(java.lang.String rowName,
                java.lang.String columnName,
                double value)
Sets a single element.

Parameters:
value - A(row,column).
rowName - The row name.
columnName - The column name.

setColumnName

public void setColumnName(int columnIndex,
                          java.lang.String name)
Sets the column name at the specified index

Parameters:
columnIndex - The column index.
name - The new columnName value

setRowName

public void setRowName(int rowIndex,
                       java.lang.String name)
Sets the row name at the specified index

Parameters:
rowIndex - The new rowName value
name - The new rowName value

getRowIndex

public int getRowIndex(java.lang.String rowName)
Gets the row index for the row name .

Parameters:
rowName - the row name.
Returns:
the row index, or -1 if the row name is not contained in this matrix

getColumnIndex

public int getColumnIndex(java.lang.String columnName)
Gets the column index for the column name .

Parameters:
columnName - the column name.
Returns:
the column index, or -1 if the column name is not contained in this matrix

get

public double get(int row,
                  int column)
Gets a single element

Parameters:
row - Row index.
column - Column index.
Returns:
The value at A[row,column]

getRow

public double[] getRow(int row)
Gets the underlying array at the given row

Parameters:
row - Row index
Returns:
the row array

getArray

public double[][] getArray()
Gets the underlying double[][] array

Returns:
the array

getRowName

public java.lang.String getRowName(int rowIndex)
Gets the row name at the specified index

Parameters:
rowIndex - The row index.
Returns:
The row name.

getColumnName

public java.lang.String getColumnName(int columnIndex)
Gets the column name at the specified index

Parameters:
columnIndex - The column index.
Returns:
The column name.

getColumnNames

public java.lang.String[] getColumnNames()
Allocates a new array contains the column names

Returns:
The column names.

getRowNames

public java.lang.String[] getRowNames()
Allocates a new array contains the row names

Returns:
The row names.

getRowCount

public int getRowCount()
Gets the row dimension.

Returns:
m, the number of rows.

getColumnCount

public int getColumnCount()
Gets the column dimension.

Returns:
n, the number of columns.


Hosted by docs.bugaco.com