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

Matrix class made of a collection of matrices. More...

#include <MatrixCollection.hxx>

Inheritance diagram for Seldon::MatrixCollection< T, Prop, Storage, Allocator >:
Seldon::Matrix_Base< T, NewAlloc< T > > Seldon::VirtualMatrix< T >

Public Types

typedef T::value_type value_type
 
typedef T::pointer pointer
 
typedef T::const_pointer const_pointer
 
typedef T::reference reference
 
typedef T::const_reference const_reference
 
typedef T matrix_type
 
typedef matrix_type * matrix_pointer
 
typedef matrix_type & matrix_reference
 
typedef Matrix< matrix_type, Prop, Storage, NewAlloc< T > > collection_type
 
typedef collection_typecollection_reference
 

Public Member Functions

 MatrixCollection ()
 Default constructor. More...
 
 MatrixCollection (int i, int j)
 Main constructor. More...
 
 MatrixCollection (const MatrixCollection< T, Prop, Storage, Allocator > &A)
 Copy constructor.
 
 ~MatrixCollection ()
 Destructor.
 
void Clear ()
 Clears the matrix. More...
 
void Nullify ()
 Clears the matrix. More...
 
void Nullify (int i, int j)
 Clears a given underlying matrix. More...
 
void Deallocate ()
 Deallocates underlying the matrices.
 
int GetM () const
 Returns the number of rows. More...
 
int GetMmatrix () const
 Returns the number of rows. More...
 
int GetM (int i) const
 Returns the number of rows in an underlying matrix. More...
 
int GetN () const
 Returns the number of columns. More...
 
int GetNmatrix () const
 Returns the number of columns. More...
 
int GetN (int j) const
 Returns the number of columns in an underlying matrix. More...
 
int GetSize () const
 Returns the number of elements stored in memory. More...
 
int 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 collection. More...
 
template<class T0 , class Prop0 , class Storage0 , class Allocator0 >
void SetMatrix (int m, int n, const Matrix< T0, Prop0, Storage0, Allocator0 > &)
 Sets an underlying matrix in the matrix collection. More...
 
template<class T0 , class Prop0 , class Allocator0 >
void SetMatrix (int m, int n, const Matrix< T0, Prop0, RowSparse, Allocator0 > &)
 Sets an underlying matrix in the matrix collection. More...
 
matrix_reference GetMatrix (int i, int j)
 Access to an underlying matrix. More...
 
const_matrix_reference GetMatrix (int i, int j) const
 Access to an underlying matrix. More...
 
value_type operator() (int i, int j) const
 Access operator. More...
 
MatrixCollection< T, Prop, Storage, Allocator > & operator= (const MatrixCollection< T, Prop, Storage, Allocator > &A)
 Duplicates a matrix collection (assignment operator). More...
 
void Copy (const MatrixCollection< T, Prop, Storage, Allocator > &A)
 Duplicates a matrix collection. More...
 
void Print () const
 Displays the matrix collection on the standard output. More...
 
void Print (int m, int n) const
 Displays an underlying matrix on the standard output. More...
 
void Write (string FileName, bool with_size) const
 Writes the matrix collection in a file. More...
 
void Write (ostream &FileStream, bool with_size) const
 Writes the matrix collection to an output stream. More...
 
void WriteText (string FileName) const
 Writes the matrix collection in a file. More...
 
void WriteText (ostream &FileStream) const
 Writes the matrix collection to an output stream. More...
 
void Read (string FileName)
 Reads the matrix collection from a file. More...
 
void Read (istream &FileStream)
 Reads the matrix collection 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 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 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...
 

Public Attributes

const typedef matrix_type * const_matrix_pointer
 
const typedef matrix_type & const_matrix_reference
 
const typedef collection_type const_collection_type
 
const typedef collection_typeconst_collection_reference
 

Protected Attributes

int nz_
 Number of non-zero elements.
 
int Mmatrix_
 Number of rows of matrices.
 
int Nmatrix_
 Number of columns of matrices.
 
Vector< int, VectFull, CallocAlloc< int > > Mlocal_
 Number of rows in the underlying matrices.
 
Vector< int, VectFull, CallocAlloc< int > > Mlocal_sum_
 Cumulative number of rows in the underlying matrices.
 
Vector< int, VectFull, CallocAlloc< int > > Nlocal_
 Number of columns in the underlying matrices.
 
Vector< int, VectFull, CallocAlloc< int > > Nlocal_sum_
 Cumulative number of columns in the underlying matrices.
 
collection_type matrix_
 Pointers of the underlying matrices.
 
pointer data_
 
int m_
 
int n_
 

Detailed Description

template<class T, class Prop, class Storage, class Allocator = NewAlloc<T>>
class Seldon::MatrixCollection< T, Prop, Storage, Allocator >

Matrix class made of a collection of matrices.

Definition at line 37 of file MatrixCollection.hxx.

Constructor & Destructor Documentation

◆ MatrixCollection() [1/2]

template<class T , class Prop , class Storage , class Allocator >
Seldon::MatrixCollection< T, Prop, Storage, Allocator >::MatrixCollection

Default constructor.

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

Definition at line 45 of file MatrixCollection.cxx.

◆ MatrixCollection() [2/2]

template<class T , class Prop , class Storage , class Allocator >
Seldon::MatrixCollection< T, Prop, Storage, Allocator >::MatrixCollection ( int  i,
int  j 
)

Main constructor.

Builds a i x j collection matrix.

Parameters
[in]inumber of rows of matrices.
[in]jnumber of columns of matrices.

Definition at line 64 of file MatrixCollection.cxx.

Member Function Documentation

◆ Clear()

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Clear

Clears the matrix.

Destructs the matrix.

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

Definition at line 85 of file MatrixCollection.cxx.

◆ Copy()

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Copy ( const MatrixCollection< T, Prop, Storage, Allocator > &  A)

Duplicates a matrix collection.

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

Definition at line 358 of file MatrixCollection.cxx.

◆ GetData()

Matrix_Base< T, NewAlloc< T > >::pointer Seldon::Matrix_Base< T, NewAlloc< T > >::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()

Matrix_Base< T, NewAlloc< T > >::const_pointer Seldon::Matrix_Base< T, NewAlloc< T > >::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()

const void * Seldon::Matrix_Base< T, NewAlloc< T > >::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()

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetDataSize
inline

Returns the number of elements stored in memory.

Returns
The number of elements stored in memory.

Definition at line 168 of file MatrixCollectionInline.cxx.

◆ GetDataVoid()

void * Seldon::Matrix_Base< T, NewAlloc< T > >::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/4]

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetM
inline

Returns the number of rows.

Returns
the total number of rows. It is the sum of the number of rows in the underlying matrices.

Definition at line 69 of file MatrixCollectionInline.cxx.

◆ GetM() [2/4]

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/4]

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.

◆ GetM() [4/4]

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetM ( int  i) const
inline

Returns the number of rows in an underlying matrix.

Parameters
[in]irow index of the underlying matrix.
Returns
The number of rows in the underlying matrices with row index i.

Definition at line 93 of file MatrixCollectionInline.cxx.

◆ GetMatrix() [1/2]

template<class T , class Prop , class Storage , class Allocator >
MatrixCollection< T, Prop, Storage, Allocator >::matrix_reference Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetMatrix ( int  i,
int  j 
)
inline

Access to an underlying matrix.

Returns the underlying matrix (i, j).

Parameters
[in]irow index.
[in]jcolumn index.
Returns
The matrix collection (i, j).

Definition at line 198 of file MatrixCollectionInline.cxx.

◆ GetMatrix() [2/2]

template<class T , class Prop , class Storage , class Allocator >
MatrixCollection< T, Prop, Storage, Allocator >::const_matrix_reference Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetMatrix ( int  i,
int  j 
) const
inline

Access to an underlying matrix.

Returns the underlying matrix (i, j).

Parameters
[in]irow index.
[in]jcolumn index.
Returns
The matrix collection (i, j).

Definition at line 227 of file MatrixCollectionInline.cxx.

◆ GetMmatrix()

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetMmatrix
inline

Returns the number of rows.

Returns
the total number of rows. It is the sum of the number of rows in the underlying matrices.

Definition at line 81 of file MatrixCollectionInline.cxx.

◆ GetN() [1/4]

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetN
inline

Returns the number of columns.

Returns
the total number of columns. It is the sum of the number of columns in the underlying matrices.

Definition at line 113 of file MatrixCollectionInline.cxx.

◆ GetN() [2/4]

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/4]

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.

◆ GetN() [4/4]

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetN ( int  j) const
inline

Returns the number of columns in an underlying matrix.

Parameters
[in]jcolumn index of the underlying matrix.
Returns
The number of columns in the underlying matrices with column index j.

Definition at line 138 of file MatrixCollectionInline.cxx.

◆ GetNmatrix()

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetNmatrix
inline

Returns the number of columns.

Returns
the total number of columns. It is the sum of the number of columns in the underlying matrices.

Definition at line 125 of file MatrixCollectionInline.cxx.

◆ GetSize()

template<class T , class Prop , class Storage , class Allocator >
int Seldon::MatrixCollection< T, Prop, Storage, Allocator >::GetSize
inline

Returns the number of elements stored in memory.

Returns
The number of elements stored in memory.

Definition at line 157 of file MatrixCollectionInline.cxx.

◆ Nullify() [1/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Nullify

Clears the matrix.

Destructs the matrix.

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

Definition at line 109 of file MatrixCollection.cxx.

◆ Nullify() [2/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Nullify ( int  i,
int  j 
)

Clears a given underlying matrix.

Parameters
[in]irow of the underlying matrix to be nullified.
[in]jcolumn of the underlying matrix to be nullified.

Definition at line 132 of file MatrixCollection.cxx.

◆ operator()()

template<class T , class Prop , class Storage , class Allocator >
MatrixCollection< T, Prop, Storage, Allocator >::value_type Seldon::MatrixCollection< T, Prop, Storage, Allocator >::operator() ( int  i,
int  j 
) const

Access operator.

Returns the value of element (i, j).

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

Definition at line 303 of file MatrixCollection.cxx.

◆ operator=()

template<class T , class Prop , class Storage , class Allocator >
MatrixCollection< T, Prop, Storage, Allocator > & Seldon::MatrixCollection< T, Prop, Storage, Allocator >::operator= ( const MatrixCollection< T, Prop, Storage, Allocator > &  A)

Duplicates a matrix collection (assignment operator).

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

Definition at line 343 of file MatrixCollection.cxx.

◆ Print() [1/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Print

Displays the matrix collection on the standard output.

Displays elements on the standard output, in text format.

Definition at line 390 of file MatrixCollection.cxx.

◆ Print() [2/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Print ( int  i,
int  j 
) const

Displays an underlying matrix on the standard output.

Parameters
[in]mrow index of the underlying matrix.
[in]ncolumn index of the underlying matrix.

Definition at line 408 of file MatrixCollection.cxx.

◆ Read() [1/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Read ( istream &  FileStream)

Reads the matrix collection from an input stream.

Reads a matrix collection stored in binary format from a stream. The number of rows of matrices (integer) and the number of columns of matrices (integer) are read, and the underlying matrices are then read in the same order as it should be in memory (e.g. row-major storage).

Parameters
[in,out]FileStreaminput stream.

Definition at line 602 of file MatrixCollection.cxx.

◆ Read() [2/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Read ( string  FileName)

Reads the matrix collection from a file.

Reads a matrix collection stored in binary format in a file. The number of rows of matrices (integer) and the number of columns of matrices (integer) are read, and the underlying matrices are then read in the same order as it should be in memory (e.g. row-major storage).

Parameters
[in]FileNameinput file name.

Definition at line 575 of file MatrixCollection.cxx.

◆ Reallocate()

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Reallocate ( int  i,
int  j 
)

Reallocates memory to resize the matrix collection.

On exit, the matrix is a matrix collection with i x j underlying matrices.

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

Definition at line 164 of file MatrixCollection.cxx.

◆ SetMatrix() [1/2]

template<class T , class Prop , class Storage , class Allocator >
template<class T0 , class Prop0 , class Allocator0 >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::SetMatrix ( int  i,
int  j,
const Matrix< T0, Prop0, RowSparse, Allocator0 > &  A 
)

Sets an underlying matrix in the matrix collection.

Parameters
[in]irow of the underlying matrix to be set.
[in]jcolumn of the underlying matrix to be set.
[in]matrixnew value for the underlying matrix.

Definition at line 245 of file MatrixCollection.cxx.

◆ SetMatrix() [2/2]

template<class T , class Prop , class Storage , class Allocator >
template<class T0 , class Prop0 , class Storage0 , class Allocator0 >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::SetMatrix ( int  i,
int  j,
const Matrix< T0, Prop0, Storage0, Allocator0 > &  A 
)

Sets an underlying matrix in the matrix collection.

Parameters
[in]irow of the underlying matrix to be set.
[in]jcolumn of the underlying matrix to be set.
[in]matrixnew value for the underlying matrix.

Definition at line 190 of file MatrixCollection.cxx.

◆ Write() [1/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Write ( ostream &  FileStream,
bool  with_size = true 
) const

Writes the matrix collection to an output stream.

Writes the matrix collection to an output stream in binary format. The number of rows of matrices (integer) and the number of columns of matrices (integer) are written, and the underlying matrices are then written in the same order as in memory (e.g. row-major storage).

Parameters
[in,out]FileStreamoutput stream.
[in]with_sizeif set to 'false', the dimensions of the matrix are not saved.

Definition at line 467 of file MatrixCollection.cxx.

◆ Write() [2/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::Write ( string  FileName,
bool  with_size 
) const

Writes the matrix collection in a file.

Stores the matrix collection in a file in binary format. The number of rows of matrices (integer) and the number of columns of matrices (integer) are written, and the underlying matrices are then written in the same order as in memory (e.g. row-major storage).

Parameters
[in]FileNameoutput file name.
[in]with_sizeif set to 'false', the dimensions of the matrix are not saved.

Definition at line 438 of file MatrixCollection.cxx.

◆ WriteText() [1/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::WriteText ( ostream &  FileStream) const

Writes the matrix collection to an output stream.

Stores the matrix to an output stream in text format. Only the underlying matrices are written, without the dimensions. Each row is written on a single line and elements of a row are delimited by tabulations.

Parameters
[in,out]FileStreamoutput stream.

Definition at line 539 of file MatrixCollection.cxx.

◆ WriteText() [2/2]

template<class T , class Prop , class Storage , class Allocator >
void Seldon::MatrixCollection< T, Prop, Storage, Allocator >::WriteText ( string  FileName) const

Writes the matrix collection in a file.

Stores the matrix in a file in text format. Only the underlying matrices are written, without the dimensions. Each row is written on a single line and elements of a row are delimited by tabulations.

Parameters
[in]FileNameoutput file name.

Definition at line 510 of file MatrixCollection.cxx.


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