Full matrix class. More...
#include <Matrix_Pointers.hxx>
Public Member Functions | |
Matrix_Pointers () | |
Default constructor. More... | |
Matrix_Pointers (int i, int j) | |
Main constructor. More... | |
Matrix_Pointers (const Matrix_Pointers< T, Prop, Storage, Allocator > &A) | |
Copy constructor. | |
~Matrix_Pointers () | |
Destructor. | |
void | Clear () |
Clears the matrix. More... | |
long | GetDataSize () const |
Returns the number of elements stored in memory. More... | |
size_t | GetMemorySize () const |
Returns size of A in bytes used to store the matrix. | |
pointer * | GetMe () const |
Returns the pointer 'me_'. More... | |
void | Reallocate (int i, int j) |
Reallocates memory to resize the matrix. More... | |
void | SetData (int i, int j, pointer data) |
Changes the size of the matrix and sets its data array (low level method). More... | |
void | Nullify () |
Clears the matrix without releasing memory. More... | |
void | Resize (int i, int j) |
Reallocates memory to resize the matrix and keeps previous entries. More... | |
pointer | GetDataPointer (int i, int j) const |
Returns a pointer to a data element. More... | |
reference | operator() (int i, int j) |
Access operator. More... | |
const_reference | operator() (int i, int j) const |
Access operator. More... | |
reference | Val (int i, int j) |
Access operator. More... | |
reference | Get (int i, int j) |
Access operator. More... | |
const_reference | Val (int i, int j) const |
Access operator. More... | |
const_reference | Get (int i, int j) const |
Access operator. More... | |
reference | operator[] (int i) |
Access to elements of the data array. More... | |
const_reference | operator[] (int i) const |
Access to elements of the data array. More... | |
Matrix_Pointers< T, Prop, Storage, Allocator > & | operator= (const Matrix_Pointers< T, Prop, Storage, Allocator > &A) |
Duplicates a matrix (assignment operator). More... | |
void | Set (int i, int j, const T &val) |
Sets an element of the matrix. More... | |
void | Copy (const Matrix_Pointers< T, Prop, Storage, Allocator > &A) |
Duplicates a matrix. More... | |
int | GetLD () const |
Returns the leading dimension. More... | |
void | Zero () |
Sets all elements to zero. More... | |
void | SetIdentity () |
Sets the current matrix to the identity. | |
void | Fill () |
Fills the matrix the matrix with 0, 1, 2, ... More... | |
template<class T0 > | |
void | Fill (const T0 &x) |
Fills the matrix with a given value. More... | |
template<class T0 > | |
Matrix_Pointers< T, Prop, Storage, Allocator > & | operator= (const T0 &x) |
Fills the matrix with a given value. More... | |
void | FillRand () |
Fills the matrix randomly. More... | |
void | Print () const |
Displays the matrix on the standard output. More... | |
void | Print (int a, int b, int m, int n) const |
Displays a sub-matrix on the standard output. More... | |
void | Print (int l) const |
Displays a square sub-matrix on the standard output. More... | |
void | Append (string FileName) const |
Appends the matrix in a file. More... | |
void | Write (string FileName, bool with_size=true) const |
Writes the matrix in a file. More... | |
void | Write (ostream &FileStream, bool with_size=true) const |
Writes the matrix to an output stream. More... | |
void | WriteText (string FileName) const |
Writes the matrix in a file. More... | |
void | WriteText (ostream &FileStream) const |
Writes the matrix to an output stream. More... | |
void | Read (string FileName, bool with_size=true) |
Reads the matrix from a file. More... | |
void | Read (istream &FileStream, bool with_size=true) |
Reads the matrix from an input stream. More... | |
void | ReadText (string FileName) |
Reads the matrix from a file. More... | |
void | ReadText (istream &FileStream) |
Reads the matrix from an input stream. More... | |
pointer | GetData () const |
Returns a pointer to the data array. More... | |
const_pointer | GetDataConst () const |
Returns a const pointer to the data array. More... | |
void * | GetDataVoid () const |
Returns a pointer of type "void*" to the data array. More... | |
const void * | GetDataConstVoid () const |
Returns a pointer of type "const void*" to the data array. More... | |
int | GetM () const |
Returns the number of rows. More... | |
int | GetM (const Seldon::SeldonTranspose &status) const |
Returns the number of rows of the matrix possibly transposed. More... | |
int | GetM (const CBLAS_TRANSPOSE &status) const |
Returns the number of rows of the matrix possibly transposed. More... | |
int | GetN () const |
Returns the number of columns. More... | |
int | GetN (const Seldon::SeldonTranspose &status) const |
Returns the number of columns of the matrix possibly transposed. More... | |
int | GetN (const CBLAS_TRANSPOSE &status) const |
Returns the number of columns of the matrix possibly transposed. More... | |
long | GetSize () const |
Returns the number of elements in the matrix. More... | |
Protected Attributes | |
pointer * | me_ |
pointer | data_ |
int | m_ |
int | n_ |
Full matrix class.
Definition at line 37 of file Matrix_Pointers.hxx.
|
inline |
Default constructor.
On exit, the matrix is an empty 0x0 matrix.
Definition at line 39 of file Matrix_PointersInline.cxx.
|
explicit |
Main constructor.
Builds a i x j full matrix.
i | number of rows. |
j | number of columns. |
Definition at line 36 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Append | ( | string | FileName | ) | const |
Appends the matrix in a file.
Appends the matrix in a file in binary format. The matrix elements are appended in the same order as in memory (e.g. row-major storage).
FileName | output file name. |
Definition at line 574 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Clear |
Clears the matrix.
Destructs the matrix.
Definition at line 122 of file Matrix_Pointers.cxx.
|
inline |
Duplicates a matrix.
A | matrix to be copied. |
Definition at line 327 of file Matrix_PointersInline.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Fill |
Fills the matrix the matrix with 0, 1, 2, ...
On exit, the matrix is filled with 0, 1, 2, 3, ... The order of those numbers depends on the storage.
Definition at line 434 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Fill | ( | const T0 & | x | ) |
Fills the matrix with a given value.
x | the value to fill the matrix with. |
Definition at line 447 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::FillRand |
Fills the matrix randomly.
Definition at line 474 of file Matrix_Pointers.cxx.
|
inline |
Access operator.
Returns the value of element (i, j).
i | row index. |
j | column index. |
Definition at line 206 of file Matrix_PointersInline.cxx.
|
inline |
Access operator.
Returns the value of element (i, j).
i | row index. |
j | column index. |
Definition at line 243 of file Matrix_PointersInline.cxx.
|
inlineinherited |
Returns a pointer to the data array.
Returns a pointer to data, i.e. the data array 'data_'.
Definition at line 241 of file Matrix_BaseInline.cxx.
|
inlineinherited |
Returns a const pointer to the data array.
Returns a const pointer to data, i.e. the data array 'data_'.
Definition at line 254 of file Matrix_BaseInline.cxx.
|
inlineinherited |
Returns a pointer of type "const void*" to the data array.
Returns a pointer of type "const void*" to data, i.e. the data array 'data_'.
Definition at line 280 of file Matrix_BaseInline.cxx.
|
inline |
Returns a pointer to a data element.
i | index along dimension #1. |
j | index along dimension #2. |
Definition at line 127 of file Matrix_PointersInline.cxx.
|
inline |
Returns the number of elements stored in memory.
Returns the number of elements stored in memory, i.e. the number of rows multiplied by the number of columns because the matrix is full.
Definition at line 72 of file Matrix_PointersInline.cxx.
|
inlineinherited |
Returns a pointer of type "void*" to the data array.
Returns a pointer of type "void*" to data, i.e. the data array 'data_'.
Definition at line 267 of file Matrix_BaseInline.cxx.
|
inline |
Returns the leading dimension.
Definition at line 108 of file Matrix_PointersInline.cxx.
|
inlineinherited |
Returns the number of rows.
Definition at line 69 of file Matrix_BaseInline.cxx.
|
inlineinherited |
Returns the number of rows of the matrix possibly transposed.
status | assumed status about the transposition of the matrix. |
Definition at line 122 of file Matrix_BaseInline.cxx.
|
inlineinherited |
Returns the number of rows of the matrix possibly transposed.
status | assumed status about the transposition of the matrix. |
Definition at line 92 of file Matrix_BaseInline.cxx.
|
inline |
Returns the pointer 'me_'.
Returns the pointer 'me_' that defines an array pointing to the first row or column elements, so that 'me_[1]' points to the first element of the second row or column.
Definition at line 97 of file Matrix_PointersInline.cxx.
|
inlineinherited |
Returns the number of columns.
Definition at line 80 of file Matrix_BaseInline.cxx.
|
inlineinherited |
Returns the number of columns of the matrix possibly transposed.
status | assumed status about the transposition of the matrix. |
Definition at line 137 of file Matrix_BaseInline.cxx.
|
inlineinherited |
Returns the number of columns of the matrix possibly transposed.
status | assumed status about the transposition of the matrix. |
Definition at line 107 of file Matrix_BaseInline.cxx.
|
inlineinherited |
Returns the number of elements in the matrix.
Returns the number of elements in the matrix, i.e. the number of rows multiplied by the number of columns.
Definition at line 153 of file Matrix_BaseInline.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Nullify |
Clears the matrix without releasing memory.
On exit, the matrix is empty and the memory has not been released. It is useful for low level manipulations on a Matrix instance.
Definition at line 329 of file Matrix_Pointers.cxx.
|
inline |
Access operator.
Returns the value of element (i, j).
i | row index. |
j | column index. |
Definition at line 145 of file Matrix_PointersInline.cxx.
|
inline |
Access operator.
Returns the value of element (i, j).
i | row index. |
j | column index. |
Definition at line 166 of file Matrix_PointersInline.cxx.
|
inline |
Duplicates a matrix (assignment operator).
A | matrix to be copied. |
Definition at line 311 of file Matrix_PointersInline.cxx.
Matrix_Pointers< T, Prop, Storage, Allocator > & Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::operator= | ( | const T0 & | x | ) |
Fills the matrix with a given value.
x | the value to fill the matrix with. |
Definition at line 461 of file Matrix_Pointers.cxx.
|
inline |
Access to elements of the data array.
Provides a direct access to the data array.
i | index. |
Definition at line 257 of file Matrix_PointersInline.cxx.
|
inline |
Access to elements of the data array.
Provides a direct access to the data array.
i | index. |
Definition at line 277 of file Matrix_PointersInline.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Print |
Displays the matrix on the standard output.
Displays elements on the standard output, in text format. Each row is displayed on a single line and elements of a row are delimited by tabulations.
Definition at line 491 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Print | ( | int | a, |
int | b, | ||
int | m, | ||
int | n | ||
) | const |
Displays a sub-matrix on the standard output.
The sub-matrix is defined by its upper-left corner (a, b) and its bottom-right corner (m, n). So, elements with indices in [a, m] x [b, n] are displayed on the standard output, in text format. Each row is displayed on a single line and elements of a row are delimited by tabulations.
a | row index of the upper-left corner. |
b | column index of the upper-left corner. |
m | row index of the bottom-right corner. |
n | column index of the bottom-right corner. |
Definition at line 515 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Print | ( | int | l | ) | const |
Displays a square sub-matrix on the standard output.
The sub-matrix is defined by its bottom-right corner (l, l). So, elements with indices in [0, 0] x [l, l] are displayed on the standard output, in text format. Each row is displayed on a single line and elements of a row are delimited by tabulations.
l | dimension of the square matrix to be displayed. |
Definition at line 537 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Read | ( | istream & | FileStream, |
bool | with_size = true |
||
) |
Reads the matrix from an input stream.
Reads a matrix in binary format from an input stream. The number of rows (integer) and the number of columns (integer) are read, and matrix elements are then read in the same order as it should be in memory (e.g. row-major storage).
FileStream | input stream. |
with_size | if set to 'false', the dimensions of the matrix are not available in the stream. In this case, the current dimensions (M, N) of the matrix are unchanged, and MxN elements are read in the stream. |
Definition at line 777 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Read | ( | string | FileName, |
bool | with_size = true |
||
) |
Reads the matrix from a file.
Reads a matrix stored in binary format in a file. The number of rows (integer) and the number of columns (integer) are read, and matrix elements are then read in the same order as it should be in memory (e.g. row-major storage).
FileName | input file name. |
with_size | if set to 'false', the dimensions of the matrix are not available in the file. In this case, the current dimensions (M, N) of the matrix are unchanged, and MxN elements are read in the file. |
Definition at line 746 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::ReadText | ( | istream & | FileStream | ) |
Reads the matrix from an input stream.
Reads a matrix in text format from an input stream.
FileStream | input stream. |
Definition at line 840 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::ReadText | ( | string | FileName | ) |
Reads the matrix from a file.
Reads a matrix from a file in text format.
FileName | input file name. |
Definition at line 815 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Reallocate | ( | int | i, |
int | j | ||
) |
Reallocates memory to resize the matrix.
On exit, the matrix is a i x j matrix.
i | new number of rows. |
j | new number of columns. |
Definition at line 183 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Resize | ( | int | i, |
int | j | ||
) |
Reallocates memory to resize the matrix and keeps previous entries.
On exit, the matrix is a i x j matrix.
i | new number of rows. |
j | new number of columns. |
Definition at line 369 of file Matrix_Pointers.cxx.
|
inline |
Sets an element of the matrix.
i | row index. |
j | column index. |
x | new value for the matrix element (i, j). |
Definition at line 296 of file Matrix_PointersInline.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::SetData | ( | int | i, |
int | j, | ||
pointer | data | ||
) |
Changes the size of the matrix and sets its data array (low level method).
The matrix is first cleared (memory is freed). The matrix is then resized to a i x j matrix, and the data array of the matrix is set to 'data'. 'data' elements are not duplicated: the new data array of the matrix is the 'data' array. It is useful to create a matrix from pre-existing data.
i | new number of rows. |
j | new number of columns. |
data | new array storing elements. |
Definition at line 277 of file Matrix_Pointers.cxx.
|
inline |
Access operator.
Returns the value of element (i, j).
i | row index. |
j | column index. |
Definition at line 186 of file Matrix_PointersInline.cxx.
|
inline |
Access operator.
Returns the value of element (i, j).
i | row index. |
j | column index. |
Definition at line 222 of file Matrix_PointersInline.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Write | ( | ostream & | FileStream, |
bool | with_size = true |
||
) | const |
Writes the matrix to an output stream.
Writes the matrix to an output stream in binary format. The number of rows (integer) and the number of columns (integer) are written, and matrix elements are then written in the same order as in memory (e.g. row-major storage).
FileStream | output stream. |
with_size | if set to 'false', the dimensions of the matrix are not saved. |
Definition at line 634 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Write | ( | string | FileName, |
bool | with_size = true |
||
) | const |
Writes the matrix in a file.
Stores the matrix in a file in binary format. The number of rows (integer) and the number of columns (integer) are written, and matrix elements are then written in the same order as in memory (e.g. row-major storage).
FileName | output file name. |
with_size | if set to 'false', the dimensions of the matrix are not saved. |
Definition at line 604 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::WriteText | ( | ostream & | FileStream | ) | const |
Writes the matrix to an output stream.
Writes the matrix to an output stream in text format. Only matrix elements are written (not dimensions). Each row is written on a single line and elements of a row are delimited by tabulations.
FileStream | output stream. |
Definition at line 705 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::WriteText | ( | string | FileName | ) | const |
Writes the matrix in a file.
Stores the matrix in a file in text format. Only matrix elements are written (not dimensions). Each row is written on a single line and elements of a row are delimited by tabulations.
FileName | output file name. |
Definition at line 675 of file Matrix_Pointers.cxx.
void Seldon::Matrix_Pointers< T, Prop, Storage, Allocator >::Zero |
Sets all elements to zero.
Definition at line 406 of file Matrix_Pointers.cxx.