|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mymedialite.datatype.Matrix<T>
T
- the type of the matrix entriespublic class Matrix<T>
Class for storing dense matrices. The data is stored in row-major mode. Indexes are zero-based.
Field Summary | |
---|---|
java.lang.Object[] |
data
Data array: data is stored in columns. |
int |
dim1
Dimension 1, the number of rows |
int |
dim2
Dimension 2, the number of columns |
Constructor Summary | |
---|---|
Matrix(int dim1,
int dim2)
Initializes a new instance of the Matrix class |
|
Matrix(int dim1,
int dim2,
T d)
Initializes a new instance of the Matrix class |
|
Matrix(java.util.List<java.util.List<T>> data)
Constructor that takes a list of lists to initialize the matrix. |
|
Matrix(Matrix<T> matrix)
Copy constructor. |
Method Summary | |
---|---|
void |
addRows(int num_rows)
Enlarges the matrix to num_rows rows Do nothing if num_rows is less than dim1. |
IMatrix<T> |
createMatrix(int num_rows,
int num_columns)
Create a matrix with a given number of rows and columns. |
T |
get(int i,
int j)
Get the value at (i,j) |
java.util.List<T> |
getColumn(int j)
Returns a copy of the j-th column of the matrix |
java.util.List<T> |
getRow(int i)
Returns a copy of the i-th row of the matrix |
void |
grow(int num_rows,
int num_cols)
Grows the matrix to the requested size, if necessary The new entries are filled with zeros. |
boolean |
isSymmetric()
True if the matrix is symmetric, false otherwise. |
int |
numberOfColumns()
Get the number of columns of the matrix. |
int |
numberOfRows()
Get the number of rows of the matrix. |
void |
set(int i,
int j,
T value)
Set the value at (i,j) |
void |
setColumn(int j,
java.util.List<T> column)
Sets the values of the j-th column to the values in a given array |
void |
setColumnToOneValue(int j,
T v)
Sets an entire column to a specified value |
void |
setRow(int i,
java.util.List<T> row)
Sets the values of the i-th row to the values in a given array |
void |
setRowToOneValue(int i,
T v)
Sets an entire row to a specified value |
IMatrix<T> |
transpose()
Get the transpose of the matrix, i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.lang.Object[] data
public int dim1
public int dim2
Constructor Detail |
---|
public Matrix(int dim1, int dim2)
dim1
- the number of rowsdim2
- the number of columnspublic Matrix(int dim1, int dim2, T d)
dim1
- the number of rowsdim2
- the number of columnsd
- the default value for the elementspublic Matrix(Matrix<T> matrix)
matrix
- the matrix to be copiedpublic Matrix(java.util.List<java.util.List<T>> data)
data
- a list of lists of TMethod Detail |
---|
public IMatrix<T> createMatrix(int num_rows, int num_columns)
IMatrix
createMatrix
in interface IMatrix<T>
num_rows
- the number of rowsnum_columns
- the number of columns
public IMatrix<T> transpose()
IMatrix
transpose
in interface IMatrix<T>
public int numberOfRows()
IMatrix
numberOfRows
in interface IMatrix<T>
public int numberOfColumns()
IMatrix
numberOfColumns
in interface IMatrix<T>
public T get(int i, int j)
IMatrix
get
in interface IMatrix<T>
i
- the row IDj
- the column ID
public void set(int i, int j, T value)
IMatrix
set
in interface IMatrix<T>
i
- the row IDj
- the column IDvalue
- the valuepublic boolean isSymmetric()
IMatrix
isSymmetric
in interface IMatrix<T>
public java.util.List<T> getRow(int i)
i
- the row ID
public java.util.List<T> getColumn(int j)
j
- the column ID
public void setRow(int i, java.util.List<T> row)
i
- the row IDrow
- A of length dim1public void setColumn(int j, java.util.List<T> column)
j
- the column IDcolumn
- A T[] of length dim2public void addRows(int num_rows)
num_rows
- the minimum number of rowspublic void grow(int num_rows, int num_cols)
grow
in interface IMatrix<T>
num_rows
- the minimum number of rowsnum_cols
- the minimum number of columnspublic void setRowToOneValue(int i, T v)
v
- the value to be usedi
- the row IDpublic void setColumnToOneValue(int j, T v)
v
- the value to be usedj
- the column ID
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |