MyMediaLite  3.10
Public Member Functions | Public Attributes | Properties | List of all members
Matrix< T > Class Template Reference

Class for storing dense matrices More...

Inheritance diagram for Matrix< T >:
IMatrix< T >

Public Member Functions

void AddRows (int num_rows)
 Enlarges the matrix to num_rows rows
IMatrix< T > CreateMatrix (int num_rows, int num_columns)
 Create a matrix with a given number of rows and columns
IList< T > GetColumn (int j)
 Returns a copy of the j-th column of the matrix
IList< T > GetRow (int i)
 Returns a copy of the i-th row of the matrix
void Init (T d)
 Init the matrix with a default value
 Matrix (int dim1, int dim2)
 Initializes a new instance of the Matrix class
 Matrix (int dim1, uint dim2)
 Initializes a new instance of the Matrix class
 Matrix (uint dim1, int dim2)
 Initializes a new instance of the Matrix class
 Matrix (uint dim1, uint dim2)
 Initializes a new instance of the Matrix class
 Matrix (Matrix< T > matrix)
 Copy constructor. Creates a deep copy of the given matrix.
 Matrix (IList< IList< T >> data)
 Constructor that takes a list of lists to initialize the matrix
void Resize (int num_rows, int num_cols)
 Grows or shrinks the matrix to the requested size, if necessary
void SetColumn (int j, IList< 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, IList< 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. a matrix where rows and columns are interchanged

Public Attributes

int dim1
 Dimension 1, the number of rows
int dim2
 Dimension 2, the number of columns

Properties

virtual bool IsSymmetric [get]
int NumberOfColumns [get]
int NumberOfRows [get]
virtual T this[int i, int j] [get, set]
this[int x, int y] [get, set]
 The value at (i,j)

Detailed Description

Class for storing dense matrices

The data is stored in row-major mode. Indexes are zero-based.

Template Parameters
Tthe type of the matrix entries

Member Function Documentation

void AddRows ( int  num_rows)
inline

Enlarges the matrix to num_rows rows

Do nothing if num_rows is less than dim1. The new entries are filled with zeros.

Parameters
num_rowsthe minimum number of rows
IMatrix<T> CreateMatrix ( int  num_rows,
int  num_columns 
)
inline

Create a matrix with a given number of rows and columns

Parameters
num_rowsthe number of rows
num_columnsthe number of columns
Returns
A matrix with num_rows rows and num_column columns

Implements IMatrix< T >.

IList<T> GetColumn ( int  j)
inline

Returns a copy of the j-th column of the matrix

Parameters
jthe column ID
Returns
a list of T containing the column data
IList<T> GetRow ( int  i)
inline

Returns a copy of the i-th row of the matrix

Parameters
ithe row ID
Returns
a list of T containing the row data
void Init ( d)
inline

Init the matrix with a default value

Parameters
dthe default value
Matrix ( int  dim1,
int  dim2 
)
inline

Initializes a new instance of the Matrix class

Parameters
dim1the number of rows
dim2the number of columns
Matrix ( int  dim1,
uint  dim2 
)
inline

Initializes a new instance of the Matrix class

Parameters
dim1the number of rows
dim2the number of columns
Matrix ( uint  dim1,
int  dim2 
)
inline

Initializes a new instance of the Matrix class

Parameters
dim1the number of rows
dim2the number of columns
Matrix ( uint  dim1,
uint  dim2 
)
inline

Initializes a new instance of the Matrix class

Parameters
dim1the number of rows
dim2the number of columns
Matrix ( Matrix< T >  matrix)
inline

Copy constructor. Creates a deep copy of the given matrix.

Parameters
matrixthe matrix to be copied
Matrix ( IList< IList< T >>  data)
inline

Constructor that takes a list of lists to initialize the matrix

Parameters
dataa list of lists of T
void Resize ( int  num_rows,
int  num_cols 
)
inline

Grows or shrinks the matrix to the requested size, if necessary

The new entries are filled with zeros. Obsolete entries are removed.

Parameters
num_rowsthe number of rows
num_colsthe number of columns

Implements IMatrix< T >.

void SetColumn ( int  j,
IList< T >  column 
)
inline

Sets the values of the j-th column to the values in a given array

Parameters
jthe column ID
columna list of T of length dim2
void SetColumnToOneValue ( int  j,
v 
)
inline

Sets an entire column to a specified value

Parameters
vthe value to be used
jthe column ID
void SetRow ( int  i,
IList< T >  row 
)
inline

Sets the values of the i-th row to the values in a given array

Parameters
ithe row ID
rowa list of T of length dim1
void SetRowToOneValue ( int  i,
v 
)
inline

Sets an entire row to a specified value

Parameters
vthe value to be used
ithe row ID
IMatrix<T> Transpose ( )
inline

Get the transpose of the matrix, i.e. a matrix where rows and columns are interchanged

Returns
the transpose of the matrix (copy)

Implements IMatrix< T >.

Member Data Documentation

int dim1

Dimension 1, the number of rows

int dim2

Dimension 2, the number of columns

Property Documentation

T this[int x, int y]
getsetinherited

The value at (i,j)

The value at (i,j)

Parameters
xthe row ID
ythe column ID

The documentation for this class was generated from the following file: