28 #ifndef _MATRIX_INTERFACE_HPP_
29 #define _MATRIX_INTERFACE_HPP_
35 namespace matrix_interface {
51 void init(
size_t n_row,
size_t n_col);
66 bool local_index(
size_t g_row,
size_t g_col,
size_t& i)
const;
68 size_t& lindex)
const;
82 template <
typename UnaryOperation>
90 void bcast(D* buffer,
int count,
int root)
const;
100 const std::vector<size_t>& local_position,
102 template <
typename C>
104 const std::vector<int>& dest_rank,
105 const std::vector<size_t>& local_position,
107 template <
typename C>
109 const std::vector<size_t>& local_position,
111 template <
typename C>
113 template <
typename C>
115 template <
typename C>
118 template <
typename C>
120 template <
typename C>
122 template <
typename C>
124 template <
typename C>
126 template <
typename C>
128 template <
typename C>
130 template <
typename C>
132 template <
typename C>
135 template <
typename C>
137 template <
typename C>
139 template <
typename C>
141 template <
typename C>
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.
Matrix & operator+=(const Matrix &rhs)
Matrix()
Constructor of a size-zero matrix.
C value_type
double or complex
Definition: matrix_interface.hpp:40
Matrix(const comm_type &comm)
Constructor of a size-zero matrix.
C allreduce_sum(C value) const
Return the summation of a scalar. Every processes returns the same value.
void print_info(std::ostream &) const
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
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.
size_t local_row_size() const
int get_comm_size() const
Return the size of the MPI communicator.
Matrix & operator/=(C rhs)
Matrix & operator*=(C rhs)
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.
Matrix & operator-=(const Matrix &rhs)
constexpr static size_t matrix_type_tag
Definition: matrix_interface.hpp:43
Matrix & map(UnaryOperation op)
constexpr static char * matrix_type_name
Definition: matrix_interface.hpp:44
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
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