GPUMLib  0.2.2
GPU Machine Learning Library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HostMatrix< Type > Class Template Reference

Create a matrix of any type, on the host, that automatically manages the memory used to hold its elements. More...

#include <HostMatrix.h>

Inheritance diagram for HostMatrix< Type >:
BaseMatrix< Type >

Public Member Functions

void Dispose ()
 Disposes the matrix.
 
 HostMatrix (StoringOrder storingOrder=RowMajor)
 
 HostMatrix (int rows, int columns, StoringOrder storingOrder=RowMajor)
 
 HostMatrix (const HostMatrix< Type > &other)
 
 HostMatrix (const DeviceMatrix< Type > &other)
 
 HostMatrix (HostMatrix< Type > &&temporaryMatrix)
 
 ~HostMatrix ()
 Destructor.
 
HostMatrix< Type > & operator= (const HostMatrix< Type > &other)
 
HostMatrix< Type > & operator= (const DeviceMatrix< Type > &other)
 
HostMatrix< Type > & operator= (HostMatrix< Type > &&temporaryMatrix)
 
void TransferOwnerShipFrom (HostMatrix< Type > &other)
 
HostMatrix< Type > Transpose ()
 
Type & operator() (int row, int column)
 
Type operator() (int row, int column) const
 
int Rows () const
 
int Columns () const
 
Type * Pointer () const
 
int Elements () const
 
bool IsRowMajor () const
 
void ReplaceByTranspose ()
 
int ResizeWithoutPreservingData (int rows, int columns)
 

Protected Member Functions

void Init ()
 
void MoveFrom (BaseMatrix< Type > &other)
 

Protected Attributes

Type * matrixData
 
int rows
 
int columns
 
StoringOrder storingOrder
 

Detailed Description

template<class Type>
class GPUMLib::HostMatrix< Type >

Create a matrix of any type, on the host, that automatically manages the memory used to hold its elements.

Definition at line 41 of file HostMatrix.h.

Constructor & Destructor Documentation

HostMatrix ( StoringOrder  storingOrder = RowMajor)
inline

Constructs an empty matrix

Parameters
storingOrderdefines if the matrix uses the row-major or column-major order to store the information

Definition at line 76 of file HostMatrix.h.

HostMatrix ( int  rows,
int  columns,
StoringOrder  storingOrder = RowMajor 
)
inline

Constructs a matrix with a given number of rows and columns

Parameters
rowsthe number of rows
columnsthe number of columns
storingOrderdefines if the matrix uses the row-major or column-major order to store the information

Definition at line 82 of file HostMatrix.h.

HostMatrix ( const HostMatrix< Type > &  other)
inline

Constructs a matrix identical to the other

Parameters
otheranother matrix

Definition at line 89 of file HostMatrix.h.

HostMatrix ( const DeviceMatrix< Type > &  other)
inline

Constructs a matrix identical to a device matrix

Parameters
otherdevice matrix

Definition at line 95 of file HostMatrix.h.

HostMatrix ( HostMatrix< Type > &&  temporaryMatrix)
inline

Constructs a matrix using the elements of a temporary matrix (rvalue)

Parameters
temporaryMatrixtemporary matrix containing the elements

Definition at line 101 of file HostMatrix.h.

Member Function Documentation

int Columns ( ) const
inlineinherited

Gets the number of columns of the matrix

Returns
the number of columns of the matrix

Definition at line 80 of file BaseMatrix.h.

int Elements ( ) const
inlineinherited

Gets the number of elements contained in the matrix

Returns
the number of elements contained in the matrix

Definition at line 94 of file BaseMatrix.h.

bool IsRowMajor ( ) const
inlineinherited

Indicates if the information in the matrix is stored in row-major order.

Returns
True if the matrix information is stored in row-major order. False if the information is stored in column-major format.

Definition at line 100 of file BaseMatrix.h.

Type& operator() ( int  row,
int  column 
)
inline

Gets a reference to an element of the matrix

Parameters
rowrow of the desired element
columncolumn of the desired element
Returns
a reference to an element desired, based on the row and column specified

Definition at line 173 of file HostMatrix.h.

Type operator() ( int  row,
int  column 
) const
inline

Gets an element of the matrix

Parameters
rowrow of the desired element
columncolumn of the desired element
Returns
the element desired, based on the row and column specified

Definition at line 185 of file HostMatrix.h.

HostMatrix<Type>& operator= ( const HostMatrix< Type > &  other)
inline

Transforms this matrix into an matrix identical to the other

Parameters
otherother matrix
Returns
a reference to this matrix
Attention
The storing order (major-row or major-column) becames the same of the other matrix.
See also
IsRowMajor

Definition at line 115 of file HostMatrix.h.

HostMatrix<Type>& operator= ( const DeviceMatrix< Type > &  other)
inline

Transforms this matrix into an matrix identical a device matrix

Parameters
otherdevice matrix
Returns
a reference to this matrix
Attention
The storing order (major-row or major-column) becames the same of the other matrix.
See also
IsRowMajor

Definition at line 125 of file HostMatrix.h.

HostMatrix<Type>& operator= ( HostMatrix< Type > &&  temporaryMatrix)
inline

Replaces this matrix using a temporary matrix (rvalue)

Parameters
temporaryMatrixtemporary matrix
Returns
a reference to this matrix

Definition at line 133 of file HostMatrix.h.

Type* Pointer ( ) const
inlineinherited

Gets a pointer to the matrix data

Attention
Use with caution. Special attention should be given to how the matrix information is stored (row-major or column-major).
Returns
a pointer to the matrix data
See also
IsRowMajor

Definition at line 88 of file BaseMatrix.h.

void ReplaceByTranspose ( )
inlineinherited

Replaces this matrix by its transpose

Attention
This method is very fast, however it changes the method for storing information in the matrix (row-major or column-major).
See also
IsRowMajor

Definition at line 107 of file BaseMatrix.h.

int ResizeWithoutPreservingData ( int  rows,
int  columns 
)
inlineinherited

Resizes the matrix without preserving its data

Parameters
rowsthe new number of rows
columnsthe new number of columns
Returns
the number of elements of the matrix after being resized.

Definition at line 119 of file BaseMatrix.h.

int Rows ( ) const
inlineinherited

Gets the number of rows of the matrix

Returns
the number of rows of the matrix

Definition at line 74 of file BaseMatrix.h.

void TransferOwnerShipFrom ( HostMatrix< Type > &  other)
inline

Releases its own resources (elements) and obtains ownership of another matrix resources. The other matrix will no longer have any elements. In other words, it moves the elements from one matrix to another.

Parameters
othermatrix containing the elements to be moved.

Definition at line 146 of file HostMatrix.h.

HostMatrix<Type> Transpose ( )
inline

Gets the transposed of the matrix

Returns
the transposed of the matrix
Attention
The returned matrix does not use the same method (row-major or column-major) for storing information as this matrix.
See also
ReplaceByTranspose, IsRowMajor

Definition at line 162 of file HostMatrix.h.


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