mptensor  v0.3.0
Parallel Library for Tensor Network Methods
mptensor::matrix_interface::Matrix< C > Class Template Reference

Inteface of Matrix class. More...

#include <matrix_interface.hpp>

Public Types

typedef C value_type
 double or complex More...
 
typedef int comm_type
 Set MPI_Comm for MPI programm. More...
 

Public Member Functions

 Matrix ()
 Constructor of a size-zero matrix. More...
 
 Matrix (const comm_type &comm)
 Constructor of a size-zero matrix. More...
 
 Matrix (size_t n_row, size_t n_col)
 Constructor of a (n_row, n_col) matrix. More...
 
 Matrix (const comm_type &comm, size_t n_row, size_t n_col)
 Constructor of a (n_row, n_col) matrix. More...
 
void init (size_t n_row, size_t n_col)
 
const comm_typeget_comm () const
 Return the MPI communicator. More...
 
int get_comm_size () const
 Return the size of the MPI communicator. More...
 
int get_comm_rank () const
 Return the MPI rank. More...
 
void print_info (std::ostream &) const
 
const C & operator[] (size_t i) const
 Const array subscript operator. More...
 
C & operator[] (size_t i)
 Array subscript operator. More...
 
const C * head () const
 
C * head ()
 
size_t local_size () const
 Return the number of elements in this process. More...
 
void global_index (size_t i, size_t &g_row, size_t &g_col) const
 
bool local_index (size_t g_row, size_t g_col, size_t &i) const
 
void local_position (size_t g_row, size_t g_col, int &comm_rank, size_t &lindex) const
 
size_t local_row_size () const
 
size_t local_col_size () const
 
size_t local_row_index (size_t lindex) const
 
size_t local_col_index (size_t lindex) const
 
size_t global_row_index (size_t lindex_row) const
 
size_t global_col_index (size_t lindex_col) const
 
Matrixoperator+= (const Matrix &rhs)
 
Matrixoperator-= (const Matrix &rhs)
 
Matrixoperator*= (C rhs)
 
Matrixoperator/= (C rhs)
 
template<typename UnaryOperation >
Matrixmap (UnaryOperation op)
 
std::vector< C > flatten ()
 Return the flattened vector. More...
 
void barrier () const
 Wrapper of MPI_Barrier. More...
 
allreduce_sum (C value) const
 Return the summation of a scalar. Every processes returns the same value. More...
 
template<typename D >
void bcast (D *buffer, int count, int root) const
 Wrapper of MPI_Bcast. More...
 
void prep_local_to_global () const
 Preprocess for fast conversion from local index to global one. More...
 
void prep_global_to_local () const
 Preprocess for fast conversion from local index to global one. More...
 
void save_index (const std::string &filename) const
 

Static Public Attributes

constexpr static size_t matrix_type_tag = MATRIX_TYPE_TAG_INTERFACE
 
constexpr static char * matrix_type_name = (char*)"Interface"
 

Related Functions

(Note that these are not member functions.)

template<typename C >
int matrix_eigh (Matrix< C > &a, std::vector< double > &s)
 Eigenvalues of a hermite (symmetric) matrix. More...
 

Detailed Description

template<typename C>
class mptensor::matrix_interface::Matrix< C >

Inteface of Matrix class.

This class shows the list of members, which should be implemented in a Matrix class.

Warning
A Matrix class is not necessary to inherint this class because we use duck typing.
Template Parameters
Ctype of elements (double or complex).

Member Typedef Documentation

◆ comm_type

template<typename C >
typedef int mptensor::matrix_interface::Matrix< C >::comm_type

Set MPI_Comm for MPI programm.

◆ value_type

template<typename C >
typedef C mptensor::matrix_interface::Matrix< C >::value_type

double or complex

Constructor & Destructor Documentation

◆ Matrix() [1/4]

template<typename C >
mptensor::matrix_interface::Matrix< C >::Matrix< C > ( )

Constructor of a size-zero matrix.

Note
MPI communicator is set to MPI_COMM_WORLD or MPI_COMM_SELF.

◆ Matrix() [2/4]

template<typename C >
mptensor::matrix_interface::Matrix< C >::Matrix< C > ( const comm_type comm)
explicit

Constructor of a size-zero matrix.

Parameters
[in]commMPI communicator.

◆ Matrix() [3/4]

template<typename C >
mptensor::matrix_interface::Matrix< C >::Matrix< C > ( size_t  n_row,
size_t  n_col 
)

Constructor of a (n_row, n_col) matrix.

Parameters
[in]n_rowsize of row.
[in]n_colsize of column.
Note
MPI communicator is set to MPI_COMM_WORLD or MPI_COMM_SELF.

◆ Matrix() [4/4]

template<typename C >
mptensor::matrix_interface::Matrix< C >::Matrix< C > ( const comm_type comm,
size_t  n_row,
size_t  n_col 
)

Constructor of a (n_row, n_col) matrix.

Parameters
[in]commMPI communicator.
[in]n_rowsize of row.
[in]n_colsize of column.

Member Function Documentation

◆ allreduce_sum()

template<typename C >
C mptensor::matrix_interface::Matrix< C >::allreduce_sum ( value) const

Return the summation of a scalar. Every processes returns the same value.

Returns
The summation of val.

◆ barrier()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::barrier ( ) const

Wrapper of MPI_Barrier.

◆ bcast()

template<typename C >
template<typename D >
void mptensor::matrix_interface::Matrix< C >::bcast ( D *  buffer,
int  count,
int  root 
) const

Wrapper of MPI_Bcast.

Parameters
[in]bufferStarting address of buffer.
[in]countNumber of entries in buffer.
[in]rootRank of broadcast root.

◆ flatten()

template<typename C >
std::vector< C > mptensor::matrix_interface::Matrix< C >::flatten ( )

Return the flattened vector.

Returns
the flattened vector. (global)

◆ get_comm()

template<typename C >
const Matrix< C >::comm_type & mptensor::matrix_interface::Matrix< C >::get_comm ( ) const

Return the MPI communicator.

Returns
MPI communicator.

◆ get_comm_rank()

template<typename C >
int mptensor::matrix_interface::Matrix< C >::get_comm_rank ( ) const

Return the MPI rank.

Returns
the rank of process.

◆ get_comm_size()

template<typename C >
int mptensor::matrix_interface::Matrix< C >::get_comm_size ( ) const

Return the size of the MPI communicator.

Returns
The size of the MPI communicator.

◆ global_col_index()

template<typename C >
size_t mptensor::matrix_interface::Matrix< C >::global_col_index ( size_t  lindex_col) const

◆ global_index()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::global_index ( size_t  i,
size_t &  g_row,
size_t &  g_col 
) const

◆ global_row_index()

template<typename C >
size_t mptensor::matrix_interface::Matrix< C >::global_row_index ( size_t  lindex_row) const

◆ head() [1/2]

template<typename C >
C* mptensor::matrix_interface::Matrix< C >::head ( )

◆ head() [2/2]

template<typename C >
const C* mptensor::matrix_interface::Matrix< C >::head ( ) const

◆ init()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::init ( size_t  n_row,
size_t  n_col 
)

◆ local_col_index()

template<typename C >
size_t mptensor::matrix_interface::Matrix< C >::local_col_index ( size_t  lindex) const

◆ local_col_size()

template<typename C >
size_t mptensor::matrix_interface::Matrix< C >::local_col_size ( ) const

◆ local_index()

template<typename C >
bool mptensor::matrix_interface::Matrix< C >::local_index ( size_t  g_row,
size_t  g_col,
size_t &  i 
) const

◆ local_position()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::local_position ( size_t  g_row,
size_t  g_col,
int &  comm_rank,
size_t &  lindex 
) const

◆ local_row_index()

template<typename C >
size_t mptensor::matrix_interface::Matrix< C >::local_row_index ( size_t  lindex) const

◆ local_row_size()

template<typename C >
size_t mptensor::matrix_interface::Matrix< C >::local_row_size ( ) const

◆ local_size()

template<typename C >
size_t mptensor::matrix_interface::Matrix< C >::local_size ( ) const

Return the number of elements in this process.

Returns
Size of local storage.

◆ map()

template<typename C >
template<typename UnaryOperation >
Matrix& mptensor::matrix_interface::Matrix< C >::map ( UnaryOperation  op)

◆ operator*=()

template<typename C >
Matrix& mptensor::matrix_interface::Matrix< C >::operator*= ( rhs)

◆ operator+=()

template<typename C >
Matrix& mptensor::matrix_interface::Matrix< C >::operator+= ( const Matrix< C > &  rhs)

◆ operator-=()

template<typename C >
Matrix& mptensor::matrix_interface::Matrix< C >::operator-= ( const Matrix< C > &  rhs)

◆ operator/=()

template<typename C >
Matrix& mptensor::matrix_interface::Matrix< C >::operator/= ( rhs)

◆ operator[]() [1/2]

template<typename C >
C & mptensor::matrix_interface::Matrix< C >::operator[] ( size_t  i)

Array subscript operator.

Attention
This function does not check validity of local index.

◆ operator[]() [2/2]

template<typename C >
const C & mptensor::matrix_interface::Matrix< C >::operator[] ( size_t  i) const

Const array subscript operator.

Attention
This function does not check validity of local index.

◆ prep_global_to_local()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::prep_global_to_local ( ) const

Preprocess for fast conversion from local index to global one.

◆ prep_local_to_global()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::prep_local_to_global ( ) const

Preprocess for fast conversion from local index to global one.

◆ print_info()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::print_info ( std::ostream &  ) const

◆ save_index()

template<typename C >
void mptensor::matrix_interface::Matrix< C >::save_index ( const std::string &  filename) const

Friends And Related Function Documentation

◆ matrix_eigh()

template<typename C >
int matrix_eigh ( Matrix< C > &  a,
std::vector< double > &  s 
)
related

Eigenvalues of a hermite (symmetric) matrix.

Parameters
[in]aThe hermite or symmetric matrix. On exit, it may be destroyed.
[out]sThe eigenvalues in ascending order.
Returns
information from the library.

Member Data Documentation

◆ matrix_type_name

template<typename C >
constexpr static char* mptensor::matrix_interface::Matrix< C >::matrix_type_name = (char*)"Interface"
staticconstexpr

◆ matrix_type_tag

template<typename C >
constexpr static size_t mptensor::matrix_interface::Matrix< C >::matrix_type_tag = MATRIX_TYPE_TAG_INTERFACE
staticconstexpr

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