Skip to content

Commit 3b71fc5

Browse files
committed
inline more functions in base_matrix
1 parent 8fdd6ba commit 3b71fc5

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

source/module_hamilt_lcao/module_hcontainer/base_matrix.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,6 @@ assert(this->value_begin != nullptr);
120120
}
121121
}
122122

123-
template <typename T>
124-
void BaseMatrix<T>::add_element(int mu, int nu, const T& value)
125-
{
126-
#ifdef __DEBUG
127-
assert(this->value_begin != nullptr);
128-
#endif
129-
int index = mu * this->ncol_local + nu;
130-
value_begin[index] += value;
131-
}
132-
133-
template <typename T>
134-
T* BaseMatrix<T>::get_pointer() const
135-
{
136-
return value_begin;
137-
}
138-
139123
// operator= for copy assignment
140124
template <typename T>
141125
BaseMatrix<T>& BaseMatrix<T>::operator=(const BaseMatrix<T>& other)

source/module_hamilt_lcao/module_hcontainer/base_matrix.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ class BaseMatrix
5252
* @param nu column index
5353
* @param value value to be added
5454
*/
55-
void add_element(int mu, int nu, const T& value);
55+
void add_element(int mu, int nu, const T& value)
56+
{
57+
#ifdef __DEBUG
58+
assert(this->value_begin != nullptr);
59+
#endif
60+
int index = mu * this->ncol_local + nu;
61+
value_begin[index] += value;
62+
};
5663

5764
// for inside matrix
5865
/**
@@ -64,17 +71,17 @@ class BaseMatrix
6471
*/
6572
T& get_value(const size_t& i_row, const size_t& j_col) const
6673
{
67-
#ifdef __DEBUG
68-
assert(this->value_begin != nullptr);
69-
#endif
70-
int index = i_row * this->ncol_local + j_col;
71-
return value_begin[index];
74+
#ifdef __DEBUG
75+
assert(this->value_begin != nullptr);
76+
#endif
77+
int index = i_row * this->ncol_local + j_col;
78+
return value_begin[index];
7279
};
7380

7481
/**
7582
* @brief get pointer of value from a submatrix
7683
*/
77-
T* get_pointer() const;
84+
T* get_pointer() const { return value_begin; };
7885

7986
// operator= for copy assignment
8087
BaseMatrix& operator=(const BaseMatrix& other);

0 commit comments

Comments
 (0)