28#ifndef _MATRIX_INTERFACE_HPP_
29#define _MATRIX_INTERFACE_HPP_
35namespace matrix_interface {
51 void init(
size_t n_row,
size_t n_col);
82 template <
typename UnaryOperation>
100 const std::vector<size_t>& local_position,
105 const std::vector<size_t>& local_position,
109 const std::vector<size_t>& local_position,
Inteface of Matrix class.
Definition matrix_interface.hpp:38
std::vector< C > flatten()
Return the flattened vector.
size_t local_col_index(size_t lindex) const
size_t local_size() const
Return the number of elements in this process.
static constexpr size_t matrix_type_tag
Definition matrix_interface.hpp:43
Matrix()
Constructor of a size-zero matrix.
C value_type
double or complex
Definition matrix_interface.hpp:40
Matrix & map(UnaryOperation op)
Matrix(const comm_type &comm)
Constructor of a size-zero matrix.
Matrix & operator-=(const Matrix &rhs)
Matrix & operator+=(const Matrix &rhs)
C allreduce_sum(C value) const
Return the summation of a scalar. Every processes returns the same value.
void print_info(std::ostream &) const
static constexpr char * matrix_type_name
Definition matrix_interface.hpp:44
void prep_global_to_local() const
Preprocess for fast conversion from local index to global one.
size_t global_row_index(size_t lindex_row) const
const C & operator[](size_t i) const
Const array subscript operator.
size_t local_col_size() const
int comm_type
Set MPI_Comm for MPI programm.
Definition matrix_interface.hpp:41
Matrix & operator*=(C rhs)
void local_position(size_t g_row, size_t g_col, int &comm_rank, size_t &lindex) const
bool local_index(size_t g_row, size_t g_col, size_t &i) const
size_t global_col_index(size_t lindex_col) const
void init(size_t n_row, size_t n_col)
void prep_local_to_global() const
Preprocess for fast conversion from local index to global one.
void save_index(const std::string &filename) const
C & operator[](size_t i)
Array subscript operator.
void global_index(size_t i, size_t &g_row, size_t &g_col) const
void bcast(D *buffer, int count, int root) const
Wrapper of MPI_Bcast.
Matrix & operator/=(C rhs)
size_t local_row_size() const
int get_comm_size() const
Return the size of the MPI communicator.
const comm_type & get_comm() const
Return the MPI communicator.
int get_comm_rank() const
Return the MPI rank.
size_t local_row_index(size_t lindex) const
Matrix(size_t n_row, size_t n_col)
Constructor of a (n_row, n_col) matrix.
void barrier() const
Wrapper of MPI_Barrier.
Matrix(const comm_type &comm, size_t n_row, size_t n_col)
Constructor of a (n_row, n_col) matrix.
std::string filename(const std::string &prefix, int proc_size)
Definition common.hpp:32
std::complex< double > complex
Definition complex.hpp:38
constexpr size_t MATRIX_TYPE_TAG_INTERFACE
Definition matrix.hpp:33
Documentation of Matrix class interface.
int matrix_eig(Matrix< C > &a, std::vector< complex > &s, Matrix< complex > &u)
double min(const Matrix< C > &a)
Return the minimum element.
int matrix_qr(Matrix< C > &a, Matrix< C > &r)
int matrix_eigh(Matrix< C > &a, std::vector< double > &s, Matrix< C > &u)
double max_abs(const Matrix< C > &a)
Return the maximum of the absolute value of elements.
C matrix_trace(const Matrix< C > &a)
double max(const Matrix< C > &a)
Return the maximum element.
double min_abs(const Matrix< C > &a)
Return the minimum of the absolute value of elements.
int matrix_solve(Matrix< C > &a, Matrix< C > &b)
Solve linear equation .
void sum_matrix_data(const Matrix< C > &M, const std::vector< int > &dest_rank, const std::vector< size_t > &local_position, Matrix< C > &M_new)
void replace_matrix_data(const Matrix< C > &M, const std::vector< int > &dest_rank, const std::vector< size_t > &local_position, Matrix< C > &M_new)
void matrix_product(const Matrix< C > &a, const Matrix< C > &b, Matrix< C > &c)
int matrix_svd(Matrix< C > &a, Matrix< C > &u, std::vector< double > &s, Matrix< C > &v)
Definition complex.hpp:34