org.genepattern.data.matrix
Class IntMatrix2D

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

public class IntMatrix2D
extends java.lang.Object

A dense 2-dimensional matrix holding int elements.


Constructor Summary
IntMatrix2D(int[][] matrix)
          Creates a new matrix
IntMatrix2D(int rows, int columns)
          Creates a new matrix
 
Method Summary
 int get(int row, int column)
          Gets a single element
 int[][] getArray()
          Gets the underlying int[][] array
 int getColumnCount()
          Gets the column dimension.
 int[] getRow(int row)
          Gets the underlying array at the given row
 int getRowCount()
          Gets the row dimension.
 void set(int rowIndex, int columnIndex, int value)
          Sets a single element.
 IntMatrix2D slice(int[] rowIndices, int[] columnIndices)
          Constructs and returns a new matrix that contains the indicated cells.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntMatrix2D

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

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

IntMatrix2D

public IntMatrix2D(int[][] matrix)
Creates a new matrix

Parameters:
matrix - the data
Method Detail

getArray

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

Returns:
the array

getRow

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

Parameters:
row - Row index
Returns:
the row array

slice

public IntMatrix2D 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

set

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

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

get

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

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

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.