Public Types | Public Member Functions | Protected Attributes | List of all members
Seldon::Matrix< T, Prop, ColHerm, Allocator > Class Template Reference

Column-major hermitian full-matrix class. More...

#include <Matrix_Hermitian.hxx>

Inheritance diagram for Seldon::Matrix< T, Prop, ColHerm, Allocator >:
Seldon::Matrix_Hermitian< T, Prop, ColHerm, Allocator > Seldon::Matrix_Base< T, Allocator > Seldon::VirtualMatrix< T >

Public Types

typedef Allocator::value_type value_type
 
typedef Prop property
 
typedef ColHerm storage
 
typedef Allocator allocator
 
typedef Allocator::pointer pointer
 
typedef Allocator::const_pointer const_pointer
 
typedef Allocator::reference reference
 
typedef Allocator::const_reference const_reference
 
typedef Allocator::value_type entry_type
 
typedef Allocator::value_type access_type
 
typedef Allocator::value_type const_access_type
 

Public Member Functions

 Matrix ()
 Default constructor. More...
 
 Matrix (int i, int j=0)
 Main constructor. More...
 
template<class T0 >
Matrix< T, Prop, ColHerm, Allocator > & operator= (const T0 &x)
 Fills a matrix with a given value. More...
 
Matrix< T, Prop, ColHerm, Allocator > & operator= (const Matrix< T, Prop, ColHerm, Allocator > &A)
 Duplicates a matrix (assignment operator). More...
 
template<class T0 >
Matrix< T, Prop, ColHerm, Allocator > & operator*= (const T0 &x)
 Multiplies the matrix by a given value. More...
 
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.
 
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...
 
const value_type operator() (int i, int j) const
 Access operator. More...
 
const_reference Val (int i, int j) const
 Access operator. More...
 
reference Val (int i, int j)
 Access operator. More...
 
const_reference Get (int i, int j) const
 Returns access to an element (i, j) More...
 
reference Get (int i, int j)
 Returns the element (i, j). 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...
 
void Set (int i, int j, const T &x)
 Sets an element of the matrix. More...
 
void Copy (const Matrix_Hermitian< T, Prop, ColHerm, Allocator > &A)
 Duplicates a matrix. More...
 
void Zero ()
 Sets all elements to zero. More...
 
void SetIdentity ()
 Sets the matrix to the identity. More...
 
void Fill ()
 Fills the matrix with 0, 1, 2, ... More...
 
void Fill (const T0 &x)
 Fills a 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 Write (string FileName) const
 Writes the matrix in a file. More...
 
void Write (ostream &FileStream) 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)
 Reads the matrix from a file. More...
 
void Read (istream &FileStream)
 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_
 

Detailed Description

template<class T, class Prop, class Allocator>
class Seldon::Matrix< T, Prop, ColHerm, Allocator >

Column-major hermitian full-matrix class.

Definition at line 167 of file Matrix_Hermitian.hxx.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

template<class T , class Prop , class Allocator >
Seldon::Matrix< T, Prop, ColHerm, Allocator >::Matrix
inline

Default constructor.

Builds an empty 0x0 matrix.

Definition at line 453 of file Matrix_HermitianInline.cxx.

◆ Matrix() [2/2]

template<class T , class Prop , class Allocator >
Seldon::Matrix< T, Prop, ColHerm, Allocator >::Matrix ( int  i,
int  j = 0 
)
inlineexplicit

Main constructor.

Builds a i x j full column-major matrix.

Parameters
inumber of rows.
jnumber of columns.

Definition at line 465 of file Matrix_HermitianInline.cxx.

Member Function Documentation

◆ Clear()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Clear
inherited

Clears the matrix.

Destructs the matrix.

Warning
On exit, the matrix is an empty 0x0 matrix.

Definition at line 173 of file Matrix_Hermitian.cxx.

◆ Copy()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Copy ( const Matrix_Hermitian< T, Prop, ColHerm , Allocator > &  A)
inlineinherited

Duplicates a matrix.

Parameters
Amatrix to be copied.
Note
Memory is duplicated: 'A' is therefore independent from the current instance after the copy.

Definition at line 282 of file Matrix_HermitianInline.cxx.

◆ Fill() [1/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Fill
inherited

Fills 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 458 of file Matrix_Hermitian.cxx.

◆ Fill() [2/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Fill ( const T0 &  x)
inherited

Fills a matrix with a given value.

Parameters
xthe value to fill the matrix with.
Note
If the imaginary part of x is non-null, the upper part will contain x, whereas lower part will contain conj(x).

Definition at line 473 of file Matrix_Hermitian.cxx.

◆ FillRand()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::FillRand
inherited

Fills the matrix randomly.

Note
The random generator is very basic.

Definition at line 504 of file Matrix_Hermitian.cxx.

◆ Get() [1/2]

Matrix_Hermitian< T, Prop, ColHerm , Allocator >::reference Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Get ( int  i,
int  j 
)
inlineinherited

Returns the element (i, j).

Returns the value of element (i, j).

Parameters
irow index.
jcolumn index.
Returns
Element (i, j) of the matrix.

Definition at line 190 of file Matrix_HermitianInline.cxx.

◆ Get() [2/2]

Matrix_Hermitian< T, Prop, ColHerm , Allocator >::const_reference Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Get ( int  i,
int  j 
) const
inlineinherited

Returns access to an element (i, j)

Returns the value of element (i, j).

Parameters
irow index.
jcolumn index.
Returns
Element (i, j) of the matrix.

Definition at line 170 of file Matrix_HermitianInline.cxx.

◆ GetData()

template<class T , class Allocator >
Matrix_Base< T, Allocator >::pointer Seldon::Matrix_Base< T, Allocator >::GetData
inlineinherited

Returns a pointer to the data array.

Returns a pointer to data, i.e. the data array 'data_'.

Returns
A pointer to the data array.

Definition at line 241 of file Matrix_BaseInline.cxx.

◆ GetDataConst()

template<class T , class Allocator >
Matrix_Base< T, Allocator >::const_pointer Seldon::Matrix_Base< T, Allocator >::GetDataConst
inlineinherited

Returns a const pointer to the data array.

Returns a const pointer to data, i.e. the data array 'data_'.

Returns
A const pointer to the data array.

Definition at line 254 of file Matrix_BaseInline.cxx.

◆ GetDataConstVoid()

template<class T , class Allocator >
const void * Seldon::Matrix_Base< T, Allocator >::GetDataConstVoid
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_'.

Returns
A const pointer of type "void*" to the data array.

Definition at line 280 of file Matrix_BaseInline.cxx.

◆ GetDataSize()

long Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::GetDataSize
inlineinherited

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.

Returns
The number of elements stored in memory.

Definition at line 72 of file Matrix_HermitianInline.cxx.

◆ GetDataVoid()

template<class T , class Allocator >
void * Seldon::Matrix_Base< T, Allocator >::GetDataVoid
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_'.

Returns
A pointer of type "void*" to the data array.

Definition at line 267 of file Matrix_BaseInline.cxx.

◆ GetM() [1/3]

template<class T >
int Seldon::VirtualMatrix< T >::GetM
inlineinherited

Returns the number of rows.

Returns
The number of rows.

Definition at line 69 of file Matrix_BaseInline.cxx.

◆ GetM() [2/3]

template<class T >
int Seldon::VirtualMatrix< T >::GetM ( const CBLAS_TRANSPOSE &  status) const
inlineinherited

Returns the number of rows of the matrix possibly transposed.

Parameters
statusassumed status about the transposition of the matrix.
Returns
The number of rows of the possibly-transposed matrix.

Definition at line 122 of file Matrix_BaseInline.cxx.

◆ GetM() [3/3]

template<class T >
int Seldon::VirtualMatrix< T >::GetM ( const Seldon::SeldonTranspose status) const
inlineinherited

Returns the number of rows of the matrix possibly transposed.

Parameters
statusassumed status about the transposition of the matrix.
Returns
The number of rows of the possibly-transposed matrix.

Definition at line 92 of file Matrix_BaseInline.cxx.

◆ GetN() [1/3]

template<class T >
int Seldon::VirtualMatrix< T >::GetN
inlineinherited

Returns the number of columns.

Returns
The number of columns.

Definition at line 80 of file Matrix_BaseInline.cxx.

◆ GetN() [2/3]

template<class T >
int Seldon::VirtualMatrix< T >::GetN ( const CBLAS_TRANSPOSE &  status) const
inlineinherited

Returns the number of columns of the matrix possibly transposed.

Parameters
statusassumed status about the transposition of the matrix.
Returns
The number of columns of the possibly-transposed matrix.

Definition at line 137 of file Matrix_BaseInline.cxx.

◆ GetN() [3/3]

template<class T >
int Seldon::VirtualMatrix< T >::GetN ( const Seldon::SeldonTranspose status) const
inlineinherited

Returns the number of columns of the matrix possibly transposed.

Parameters
statusassumed status about the transposition of the matrix.
Returns
The number of columns of the possibly-transposed matrix.

Definition at line 107 of file Matrix_BaseInline.cxx.

◆ GetSize()

template<class T >
long Seldon::VirtualMatrix< T >::GetSize
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.

Returns
The number of elements in the matrix.

Definition at line 153 of file Matrix_BaseInline.cxx.

◆ Nullify()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Nullify
inherited

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.

Warning
Memory is not released except for me_.

Definition at line 385 of file Matrix_Hermitian.cxx.

◆ operator()()

const Matrix_Hermitian< T, Prop, ColHerm , Allocator >::value_type Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::operator() ( int  i,
int  j 
) const
inlineinherited

Access operator.

Returns the value of element (i, j).

Parameters
irow index.
jcolumn index.
Returns
Element (i, j) of the matrix.

Definition at line 104 of file Matrix_HermitianInline.cxx.

◆ operator*=()

template<class T , class Prop , class Allocator >
template<class T0 >
Matrix< T, Prop, ColHerm, Allocator > & Seldon::Matrix< T, Prop, ColHerm, Allocator >::operator*= ( const T0 &  x)
inline

Multiplies the matrix by a given value.

Parameters
xmultiplication coefficient
Warning
The imaginary part of x should be null to keep an Hermitian matrix.

Definition at line 516 of file Matrix_HermitianInline.cxx.

◆ operator=() [1/2]

template<class T , class Prop , class Allocator >
Matrix< T, Prop, ColHerm, Allocator > & Seldon::Matrix< T, Prop, ColHerm, Allocator >::operator= ( const Matrix< T, Prop, ColHerm, Allocator > &  A)
inline

Duplicates a matrix (assignment operator).

Parameters
Amatrix to be copied.
Note
Memory is duplicated: A is therefore independent from the current instance after the copy.

Definition at line 498 of file Matrix_HermitianInline.cxx.

◆ operator=() [2/2]

template<class T , class Prop , class Allocator >
template<class T0 >
Matrix< T, Prop, ColHerm, Allocator > & Seldon::Matrix< T, Prop, ColHerm, Allocator >::operator= ( const T0 &  x)
inline

Fills a matrix with a given value.

Parameters
xthe value to fill the matrix with.

Definition at line 483 of file Matrix_HermitianInline.cxx.

◆ operator[]() [1/2]

Matrix_Hermitian< T, Prop, ColHerm , Allocator >::reference Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::operator[] ( int  i)
inlineinherited

Access to elements of the data array.

Provides a direct access to the data array.

Parameters
iindex.
Returns
i-th element of the data array.

Definition at line 209 of file Matrix_HermitianInline.cxx.

◆ operator[]() [2/2]

Matrix_Hermitian< T, Prop, ColHerm , Allocator >::const_reference Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::operator[] ( int  i) const
inlineinherited

Access to elements of the data array.

Provides a direct access to the data array.

Parameters
iindex.
Returns
i-th element of the data array.

Definition at line 229 of file Matrix_HermitianInline.cxx.

◆ Print() [1/3]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Print
inherited

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 521 of file Matrix_Hermitian.cxx.

◆ Print() [2/3]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Print ( int  a,
int  b,
int  m,
int  n 
) const
inherited

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.

Parameters
arow index of the upper-left corner.
bcolumn index of the upper-left corner.
mrow index of the bottom-right corner.
ncolumn index of the bottom-right corner.

Definition at line 546 of file Matrix_Hermitian.cxx.

◆ Print() [3/3]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Print ( int  l) const
inherited

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.

Parameters
ldimension of the square matrix to be displayed.

Definition at line 567 of file Matrix_Hermitian.cxx.

◆ Read() [1/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Read ( istream &  FileStream)
inherited

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).

Parameters
FileStreaminput stream.

Definition at line 753 of file Matrix_Hermitian.cxx.

◆ Read() [2/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Read ( string  FileName)
inherited

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).

Parameters
FileNameinput file name.

Definition at line 725 of file Matrix_Hermitian.cxx.

◆ ReadText() [1/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::ReadText ( istream &  FileStream)
inherited

Reads the matrix from an input stream.

Reads a matrix in text format from an input stream.

Parameters
FileStreaminput stream.

Definition at line 814 of file Matrix_Hermitian.cxx.

◆ ReadText() [2/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::ReadText ( string  FileName)
inherited

Reads the matrix from a file.

Reads a matrix stored in text format in a file.

Parameters
FileNameinput file name.

Definition at line 789 of file Matrix_Hermitian.cxx.

◆ Reallocate()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Reallocate ( int  i,
int  j 
)
inherited

Reallocates memory to resize the matrix.

On exit, the matrix is a i x i matrix.

Parameters
inumber of rows.
jnumber of columns.
Warning
Depending on your allocator, data may be lost.

Definition at line 229 of file Matrix_Hermitian.cxx.

◆ Resize()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Resize ( int  i,
int  j 
)
inherited

Reallocates memory to resize the matrix and keeps previous entries.

On exit, the matrix is a i x j matrix.

Parameters
inew number of rows.
jnew number of columns.
Warning
The previous entries are kept, extra-entries may not be initialized (depending of the allocator).

Definition at line 144 of file Matrix_Hermitian.cxx.

◆ Set()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Set ( int  i,
int  j,
const T &  x 
)
inlineinherited

Sets an element of the matrix.

Parameters
irow index
jcolumn index
xsets a(i, j) = x

Definition at line 248 of file Matrix_HermitianInline.cxx.

◆ SetData()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::SetData ( int  i,
int  j,
pointer  data 
)
inherited

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.

Parameters
inew number of rows.
jnew number of columns.
datanew array storing elements.
Warning
'data' has to be used carefully outside the object. Unless you use 'Nullify', 'data' will be freed by the destructor, which means that 'data' must have been allocated carefully. The matrix allocator should be compatible.
Note
This method should only be used by advanced users.

Definition at line 334 of file Matrix_Hermitian.cxx.

◆ SetIdentity()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::SetIdentity
inherited

Sets the matrix to the identity.

Warning
It fills the memory with zeros. If the matrix stores complex structures, discard this method.

Definition at line 439 of file Matrix_Hermitian.cxx.

◆ Val() [1/2]

Matrix_Hermitian< T, Prop, ColHerm , Allocator >::reference Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Val ( int  i,
int  j 
)
inlineinherited

Access operator.

Returns the value of element (i, j).

Parameters
irow index.
jcolumn index.
Returns
Element (i, j) of the matrix.

Definition at line 149 of file Matrix_HermitianInline.cxx.

◆ Val() [2/2]

Matrix_Hermitian< T, Prop, ColHerm , Allocator >::const_reference Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Val ( int  i,
int  j 
) const
inlineinherited

Access operator.

Returns the value of element (i, j).

Parameters
irow index.
jcolumn index.
Returns
Element (i, j) of the matrix.

Definition at line 129 of file Matrix_HermitianInline.cxx.

◆ Write() [1/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Write ( ostream &  FileStream) const
inherited

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).

Parameters
FileStreamoutput stream.

Definition at line 616 of file Matrix_Hermitian.cxx.

◆ Write() [2/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Write ( string  FileName) const
inherited

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).

Parameters
FileNameoutput file name.

Definition at line 588 of file Matrix_Hermitian.cxx.

◆ WriteText() [1/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::WriteText ( ostream &  FileStream) const
inherited

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.

Parameters
FileStreamoutput stream.

Definition at line 686 of file Matrix_Hermitian.cxx.

◆ WriteText() [2/2]

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::WriteText ( string  FileName) const
inherited

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.

Parameters
FileNameoutput file name.

Definition at line 656 of file Matrix_Hermitian.cxx.

◆ Zero()

void Seldon::Matrix_Hermitian< T, Prop, ColHerm , Allocator >::Zero
inherited

Sets all elements to zero.

Warning
It fills the memory with zeros. If the matrix stores complex structures, use 'Fill' instead.

Definition at line 426 of file Matrix_Hermitian.cxx.


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