Skip to content

Commit a84c95b

Browse files
linpeizePeizeLinmohanchen
authored
add const for variable functions (#7037)
* add const for variable functions * add const for variable functions --------- Co-authored-by: linpz <linpz@mail.ustc.edu.cn> Co-authored-by: Mohan Chen <mohanchen@pku.edu.cn>
1 parent 9f550b3 commit a84c95b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+117
-117
lines changed

source/source_base/complexarray.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void ComplexArray::operator=(const std::complex < double> c){
8585
const int size = this->getSize();
8686
for (int i = 0; i < size; i++)
8787
ptr[i] = c;}
88-
ComplexArray ComplexArray::operator+(const ComplexArray &cd){
88+
ComplexArray ComplexArray::operator+(const ComplexArray &cd) const{
8989
const int size = this->getSize();
9090
assert(size==cd.getSize());
9191
ComplexArray cd2(*this);
@@ -98,7 +98,7 @@ void ComplexArray::operator+=(const ComplexArray & cd){
9898
for (int i = 0; i < size; i++)
9999
ptr[i] += cd.ptr[i];
100100
}
101-
ComplexArray ComplexArray::operator-(const ComplexArray &cd){
101+
ComplexArray ComplexArray::operator-(const ComplexArray &cd) const{
102102
const int size = this->getSize();
103103
assert(size==cd.getSize());
104104
ComplexArray cd2(*this);
@@ -123,7 +123,7 @@ ComplexArray operator*(const double r, const ComplexArray &cd){
123123
for (int i = 0; i < size; i++)
124124
cd2.ptr[i] *= r;
125125
return cd2;}
126-
ComplexArray ComplexArray::operator*(const double r){
126+
ComplexArray ComplexArray::operator*(const double r) const{
127127
ComplexArray cd2(*this);
128128
const int size = this->getSize();
129129
for (int i = 0; i < size; i++)
@@ -135,7 +135,7 @@ ComplexArray operator*(const std::complex < double> c, const ComplexArray &cd){
135135
for (int i = 0; i < size; i++)
136136
cd2.ptr[i] = c * cd.ptr[i];
137137
return cd2;}
138-
ComplexArray ComplexArray::operator*(const std::complex < double> c){
138+
ComplexArray ComplexArray::operator*(const std::complex < double> c) const{
139139
const int size = this->getSize();
140140
ComplexArray cd(size);
141141
for (int i = 0; i < size; i++)

source/source_base/complexarray.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ class ComplexArray
3535
/// Assignment of scalar: all entries set to c.
3636
void operator=(std::complex <double> c);
3737
/// Add two ComplexArray
38-
ComplexArray operator+(const ComplexArray &cd);
38+
ComplexArray operator+(const ComplexArray &cd) const;
3939
/// Accumulate sum of ComplexArray
4040
void operator+=(const ComplexArray &cd);
4141
/// Subtract two ComplexArray
42-
ComplexArray operator-(const ComplexArray &cd);
42+
ComplexArray operator-(const ComplexArray &cd) const;
4343
/// Accumulate difference of arrays
4444
void operator-=(const ComplexArray &cd);
4545
/// Scale a ComplexArray by real r
46-
ComplexArray operator*(const double r);
46+
ComplexArray operator*(const double r) const;
4747
/// Scale a ComplexArray by a std::complex number c
48-
ComplexArray operator*(const std::complex <double> c);
48+
ComplexArray operator*(const std::complex <double> c) const;
4949
/// Scale a ComplexArray by real number in place
5050
void operator*=(const double r);
5151
/// Scale a ComplexArray by std::complex c in place

source/source_base/complexmatrix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ std::ostream & ComplexMatrix::print( std::ostream & os, const double threshold_a
438438
return os;
439439
}
440440

441-
bool ComplexMatrix::checkreal(void)
441+
bool ComplexMatrix::checkreal(void) const
442442
{
443443
const double tiny = 1e-12;
444444
for(int i=0;i<this->nr;i++)

source/source_base/complexmatrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ComplexMatrix
6262
std::ostream & print( std::ostream & os, const double threshold_abs=0.0, const double threshold_imag=0.0 ) const; // Peize Lin add 2021.09.08
6363

6464
// check if all the elements are real
65-
bool checkreal(void);
65+
bool checkreal(void) const;
6666

6767
using type=std::complex<double>; // Peiae Lin add 2022.08.08 for template
6868
};

source/source_base/formatter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FmtCore
6666
*
6767
* @return std::string
6868
*/
69-
const std::string& fmt() { return fmt_; }
69+
const std::string& fmt() const { return fmt_; }
7070
/**
7171
* Python-style string functions will be implemented here as toolbox
7272
*/

source/source_base/opt_CG.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ class Opt_CG
4545
int& ifPD // if postive definit
4646
);
4747

48-
double get_residual()
48+
double get_residual() const
4949
{
5050
return sqrt(this->gg_);
5151
};
52-
int get_iter()
52+
int get_iter() const
5353
{
5454
return this->iter_;
5555
}

source/source_basis/module_nao/radial_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void RadialSet::indexing()
138138
}
139139
}
140140

141-
const NumericalRadial& RadialSet::chi(const int l, const int izeta)
141+
const NumericalRadial& RadialSet::chi(const int l, const int izeta) const
142142
{
143143
int i = index_map_[l * nzeta_max_ + izeta];
144144
#ifdef __DEBUG

source/source_basis/module_nao/radial_set.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class RadialSet
159159
int nzeta_max() const { return nzeta_max_; }
160160
int nchi() const { return nchi_; }
161161

162-
const NumericalRadial& chi(const int l, const int izeta);
162+
const NumericalRadial& chi(const int l, const int izeta) const;
163163
const NumericalRadial* cbegin() const { return chi_; }
164164
const NumericalRadial* cend() const { return chi_ + nchi_; }
165165
///@}

source/source_cell/pseudo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void pseudo::check_betar()
3838
}
3939
}
4040

41-
void pseudo::print_pseudo(std::ofstream& ofs)
41+
void pseudo::print_pseudo(std::ofstream& ofs) const
4242
{
4343
print_pseudo_vl(ofs);
4444
ofs << "\n pseudo : ";
@@ -50,7 +50,7 @@ void pseudo::print_pseudo(std::ofstream& ofs)
5050
ofs << "\n ----------------------";
5151
}
5252

53-
void pseudo::print_pseudo_atom(std::ofstream &ofs)
53+
void pseudo::print_pseudo_atom(std::ofstream& ofs) const
5454
{
5555
print_pseudo_h(ofs);
5656
ofs << "\n pseudo_atom : ";
@@ -66,15 +66,15 @@ void pseudo::print_pseudo_atom(std::ofstream &ofs)
6666
}
6767

6868

69-
void pseudo::print_pseudo_vl(std::ofstream &ofs)
69+
void pseudo::print_pseudo_vl(std::ofstream& ofs) const
7070
{
7171
ofs << "\n pseudo_vl:";
7272
print_pseudo_atom(ofs);
7373
output::printr1_d(ofs, "vloc_at : ", vloc_at.data(), mesh);
7474
ofs << "\n ----------------------------------- ";
7575
}
7676

77-
void pseudo::print_pseudo_h(std::ofstream &ofs)
77+
void pseudo::print_pseudo_h(std::ofstream& ofs) const
7878
{
7979
ofs << "\n pseudo_info :";
8080
ofs << "\n nv " << nv;

source/source_cell/pseudo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ class pseudo
8282
*/
8383
void check_betar();
8484

85-
void print_pseudo_h(std::ofstream& ofs);
86-
void print_pseudo_atom(std::ofstream& ofs);
87-
void print_pseudo_vl(std::ofstream& ofs);
88-
void print_pseudo(std::ofstream& ofs);
85+
void print_pseudo_h(std::ofstream& ofs) const;
86+
void print_pseudo_atom(std::ofstream& ofs) const;
87+
void print_pseudo_vl(std::ofstream& ofs) const;
88+
void print_pseudo(std::ofstream& ofs) const;
8989
};
9090

9191
#endif // PSEUDO_H

0 commit comments

Comments
 (0)