Skip to content

Commit e5afecb

Browse files
committed
Rename leading dimension vars from camel to snake case
1 parent 6c40de7 commit e5afecb

File tree

8 files changed

+50
-49
lines changed

8 files changed

+50
-49
lines changed

source/module_hsolver/diago_david.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func,
152152
const SPsiFunc& spsi_func,
153153
const int dim,
154154
const int nband,
155-
const int ldPsi,
155+
const int ld_psi,
156156
T *psi_in,
157157
Real* eigenvalue_in,
158158
const Real david_diag_thr,
@@ -191,20 +191,20 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func,
191191
if(this->use_paw)
192192
{
193193
#ifdef USE_PAW
194-
GlobalC::paw_cell.paw_nl_psi(1, reinterpret_cast<const std::complex<double>*> (psi_in + m*ldPsi),
194+
GlobalC::paw_cell.paw_nl_psi(1, reinterpret_cast<const std::complex<double>*> (psi_in + m*ld_psi),
195195
reinterpret_cast<std::complex<double>*>(&this->spsi[m * dim]));
196196
#endif
197197
}
198198
else
199199
{
200-
// phm_in->sPsi(psi_in + m*ldPsi, &this->spsi[m * dim], dim, dim, 1);
201-
spsi_func(psi_in + m*ldPsi,&this->spsi[m*dim],dim,dim,1);
200+
// phm_in->sPsi(psi_in + m*ld_psi, &this->spsi[m * dim], dim, dim, 1);
201+
spsi_func(psi_in + m*ld_psi,&this->spsi[m*dim],dim,dim,1);
202202
}
203203
}
204204
// begin SchmidtOrth
205205
for (int m = 0; m < nband; m++)
206206
{
207-
syncmem_complex_op()(this->ctx, this->ctx, basis + dim*m, psi_in + m*ldPsi, dim);
207+
syncmem_complex_op()(this->ctx, this->ctx, basis + dim*m, psi_in + m*ld_psi, dim);
208208

209209
this->SchmidtOrth(dim,
210210
nband,
@@ -289,7 +289,7 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func,
289289

290290
// update eigenvectors of Hamiltonian
291291

292-
setmem_complex_op()(this->ctx, psi_in, 0, nband * ldPsi);
292+
setmem_complex_op()(this->ctx, psi_in, 0, nband * ld_psi);
293293
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
294294
gemm_op<T, Device>()(this->ctx,
295295
'N',
@@ -304,7 +304,7 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func,
304304
nbase_x,
305305
this->zero,
306306
psi_in, // C dim * nband
307-
ldPsi
307+
ld_psi
308308
);
309309

310310
if (!this->notconv || (dav_iter == david_maxiter))
@@ -324,7 +324,7 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func,
324324
nbase_x,
325325
eigenvalue_in,
326326
psi_in,
327-
ldPsi,
327+
ld_psi,
328328
this->hpsi,
329329
this->spsi,
330330
this->hcc,
@@ -788,7 +788,7 @@ void DiagoDavid<T, Device>::diag_zhegvx(const int& nbase,
788788
* @param nbase_x The maximum dimension of the reduced basis set.
789789
* @param eigenvalue_in Pointer to the array of eigenvalues.
790790
* @param psi_in Pointer to the array of wavefunctions.
791-
* @param ldPsi The leading dimension of the wavefunction array.
791+
* @param ld_psi The leading dimension of the wavefunction array.
792792
* @param hpsi Pointer to the output array for the updated basis set.
793793
* @param spsi Pointer to the output array for the updated basis set (nband-th column).
794794
* @param hcc Pointer to the output array for the updated reduced Hamiltonian.
@@ -803,7 +803,7 @@ void DiagoDavid<T, Device>::refresh(const int& dim,
803803
const int nbase_x, // maximum dimension of the reduced basis set
804804
const Real* eigenvalue_in,
805805
const T *psi_in,
806-
const int ldPsi,
806+
const int ld_psi,
807807
T* hpsi,
808808
T* spsi,
809809
T* hcc,
@@ -869,7 +869,7 @@ void DiagoDavid<T, Device>::refresh(const int& dim,
869869

870870
for (int m = 0; m < nband; m++)
871871
{
872-
syncmem_complex_op()(this->ctx, this->ctx, basis + dim*m,psi_in + m*ldPsi, dim);
872+
syncmem_complex_op()(this->ctx, this->ctx, basis + dim*m,psi_in + m*ld_psi, dim);
873873
/*for (int ig = 0; ig < npw; ig++)
874874
basis(m, ig) = psi(m, ig);*/
875875
}
@@ -1158,7 +1158,7 @@ void DiagoDavid<T, Device>::planSchmidtOrth(const int nband, std::vector<int>& p
11581158
* @tparam Device The device type (CPU or GPU).
11591159
* @param hpsi_func The function object that computes the matrix-blockvector product H * psi.
11601160
* @param spsi_func The function object that computes the matrix-blockvector product overlap S * psi.
1161-
* @param ldPsi The leading dimension of the psi_in array.
1161+
* @param ld_psi The leading dimension of the psi_in array.
11621162
* @param psi_in The input wavefunction.
11631163
* @param eigenvalue_in The array to store the eigenvalues.
11641164
* @param david_diag_thr The convergence threshold for the diagonalization.
@@ -1173,7 +1173,7 @@ void DiagoDavid<T, Device>::planSchmidtOrth(const int nband, std::vector<int>& p
11731173
template <typename T, typename Device>
11741174
int DiagoDavid<T, Device>::diag(const HPsiFunc& hpsi_func,
11751175
const SPsiFunc& spsi_func,
1176-
const int ldPsi,
1176+
const int ld_psi,
11771177
T *psi_in,
11781178
Real* eigenvalue_in,
11791179
const Real david_diag_thr,
@@ -1188,7 +1188,7 @@ int DiagoDavid<T, Device>::diag(const HPsiFunc& hpsi_func,
11881188
int sum_dav_iter = 0;
11891189
do
11901190
{
1191-
sum_dav_iter += this->diag_once(hpsi_func, spsi_func, dim, nband, ldPsi, psi_in, eigenvalue_in, david_diag_thr, david_maxiter);
1191+
sum_dav_iter += this->diag_once(hpsi_func, spsi_func, dim, nband, ld_psi, psi_in, eigenvalue_in, david_diag_thr, david_maxiter);
11921192
++ntry;
11931193
} while (!check_block_conv(ntry, this->notconv, ntry_max, notconv_max));
11941194

source/module_hsolver/diago_david.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ class DiagoDavid : public DiagH<T, Device>
6060
* For generalized eigenvalue problem HX = λSX,
6161
* this function computes the product of the overlap matrix S and a blockvector X.
6262
*
63-
* @param[in] X Pointer to the input blockvector.
64-
* @param[out] SX Pointer to the output blockvector.
65-
* @param[in] nrow Leading dimension of spsi. Dimension of SX: nbands * nrow.
66-
* @param[in] npw Leading dimension of psi. Number of plane waves.
67-
* @param[in] nbands Number of vectors.
63+
* @param[in] X Pointer to the input blockvector.
64+
* @param[out] SX Pointer to the output blockvector.
65+
* @param[in] ld_spsi Leading dimension of spsi. Dimension of SX: nbands * nrow.
66+
* @param[in] ld_psi Leading dimension of psi. Number of plane waves.
67+
* @param[in] nbands Number of vectors.
6868
*
6969
* @note called like spsi(in, out, dim, dim, 1)
7070
*/
@@ -73,7 +73,7 @@ class DiagoDavid : public DiagH<T, Device>
7373
int diag(
7474
const HPsiFunc& hpsi_func, // function void hpsi(T*, T*, const int, const int)
7575
const SPsiFunc& spsi_func, // function void spsi(T*, T*, const int, const int, const int)
76-
const int ldPsi, // Leading dimension of the psi input
76+
const int ld_psi, // Leading dimension of the psi input
7777
T *psi_in, // Pointer to eigenvectors
7878
Real* eigenvalue_in, // Pointer to store the resulting eigenvalues
7979
const Real david_diag_thr, // Convergence threshold for the Davidson iteration
@@ -128,7 +128,7 @@ class DiagoDavid : public DiagH<T, Device>
128128
const SPsiFunc& spsi_func,
129129
const int dim,
130130
const int nband,
131-
const int ldPsi,
131+
const int ld_psi,
132132
T *psi_in,
133133
Real* eigenvalue_in,
134134
const Real david_diag_thr,
@@ -161,7 +161,7 @@ class DiagoDavid : public DiagH<T, Device>
161161
const int nbase_x,
162162
const Real* eigenvalue,
163163
const T *psi_in,
164-
const int ldPsi,
164+
const int ld_psi,
165165
T* hpsi,
166166
T* spsi,
167167
T* hcc,

source/module_hsolver/hsolver_pw.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,12 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
437437
// hpsi_func (X, HX, ld, nvec) -> HX = H(X), X and HX blockvectors of size ld x nvec
438438
auto hpsi_func = [hm, ngk_pointer](T *psi_in,
439439
T *hpsi_out,
440-
const int ldPsi,
440+
const int ld_psi,
441441
const int nvec) {
442442
ModuleBase::timer::tick("DavSubspace", "hpsi_func");
443443

444444
// Convert "pointer data stucture" to a psi::Psi object
445-
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ldPsi, ngk_pointer);
445+
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ld_psi, ngk_pointer);
446446

447447
psi::Range bands_range(true, 0, 0, nvec-1);
448448

@@ -485,7 +485,7 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
485485
// dimensions of matrix to be solved
486486
const int dim = psi.get_current_nbas(); /// dimension of matrix
487487
const int nband = psi.get_nbands(); /// number of eigenpairs sought
488-
const int ldPsi = psi.get_nbasis(); /// leading dimension of psi
488+
const int ld_psi = psi.get_nbasis(); /// leading dimension of psi
489489

490490
// Davidson matrix-blockvector functions
491491

@@ -494,12 +494,12 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
494494
// hpsi_func (X, HX, ld, nvec) -> HX = H(X), X and HX blockvectors of size ld x nvec
495495
auto hpsi_func = [hm, ngk_pointer](T *psi_in,
496496
T *hpsi_out,
497-
const int ldPsi,
497+
const int ld_psi,
498498
const int nvec) {
499499
ModuleBase::timer::tick("David", "hpsi_func");
500500

501501
// Convert pointer of psi_in to a psi::Psi object
502-
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ldPsi, ngk_pointer);
502+
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ld_psi, ngk_pointer);
503503

504504
psi::Range bands_range(true, 0, 0, nvec-1);
505505

@@ -514,13 +514,14 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
514514
/// spsi(X, SX, nrow, npw, nbands)
515515
/// nrow is leading dimension of spsi, npw is leading dimension of psi, nbands is number of vecs
516516
auto spsi_func = [hm](const T* psi_in, T* spsi_out,
517-
const int ldSpsi, // dimension of spsi: nbands * nrow
518-
const int ldPsi, // number of plane waves
519-
const int nvec // number of bands
517+
const int ld_spsi, // Leading dimension of spsi. Dimension of SX: nbands * nrow.
518+
const int ld_psi, // Leading dimension of psi. Number of plane waves.
519+
const int nvec // Number of vectors(bands)
520520
){
521521
ModuleBase::timer::tick("David", "spsi_func");
522522
// sPsi determines S=I or not by GlobalV::use_uspp inside
523-
hm->sPsi(psi_in, spsi_out, ldSpsi, ldPsi, nvec);
523+
// sPsi(psi, spsi, nrow, npw, nbands)
524+
hm->sPsi(psi_in, spsi_out, ld_spsi, ld_psi, nvec);
524525
ModuleBase::timer::tick("David", "spsi_func");
525526
};
526527

@@ -533,7 +534,7 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
533534
// do diag and add davidson iteration counts up to avg_iter
534535
DiagoIterAssist<T, Device>::avg_iter += static_cast<double>(david.diag(hpsi_func,
535536
spsi_func,
536-
ldPsi,
537+
ld_psi,
537538
psi.get_pointer(),
538539
eigenvalue,
539540
david_diag_thr,

source/module_hsolver/test/diago_david_float_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class DiagoDavPrepare
8989

9090
const int dim = phi.get_current_nbas() ;
9191
const int nband = phi.get_nbands();
92-
const int ldPsi =phi.get_nbasis();
92+
const int ld_psi =phi.get_nbasis();
9393
hsolver::DiagoDavid<std::complex<float>> dav(precondition, nband, dim, order, false, comm_info);
9494

9595
hsolver::DiagoIterAssist<std::complex<float>>::PW_DIAG_NMAX = maxiter;
@@ -108,9 +108,9 @@ class DiagoDavPrepare
108108

109109

110110
auto hpsi_func = [phm](std::complex<float>* psi_in,std::complex<float>* hpsi_out,
111-
const int ldPsi, const int nvec)
111+
const int ld_psi, const int nvec)
112112
{
113-
auto psi_iter_wrapper = psi::Psi<std::complex<float>>(psi_in, 1, nvec, ldPsi, nullptr);
113+
auto psi_iter_wrapper = psi::Psi<std::complex<float>>(psi_in, 1, nvec, ld_psi, nullptr);
114114
psi::Range bands_range(1, 0, 0, nvec-1);
115115
using hpsi_info = typename hamilt::Operator<std::complex<float>>::hpsi_info;
116116
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
@@ -119,7 +119,7 @@ class DiagoDavPrepare
119119
auto spsi_func = [phm](const std::complex<float>* psi_in, std::complex<float>* spsi_out,const int nrow, const int npw, const int nbands){
120120
phm->sPsi(psi_in, spsi_out, nrow, npw, nbands);
121121
};
122-
dav.diag(hpsi_func,spsi_func, ldPsi, phi.get_pointer(), en, eps, maxiter);
122+
dav.diag(hpsi_func,spsi_func, ld_psi, phi.get_pointer(), en, eps, maxiter);
123123

124124
#ifdef __MPI
125125
end = MPI_Wtime();

source/module_hsolver/test/diago_david_real_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class DiagoDavPrepare
9191

9292
const int dim = phi.get_current_nbas();
9393
const int nband = phi.get_nbands();
94-
const int ldPsi = phi.get_nbasis();
94+
const int ld_psi = phi.get_nbasis();
9595
hsolver::DiagoDavid<double> dav(precondition, nband, dim, order, false, comm_info);
9696

9797
hsolver::DiagoIterAssist<double>::PW_DIAG_NMAX = maxiter;
@@ -110,9 +110,9 @@ class DiagoDavPrepare
110110

111111

112112
auto hpsi_func = [phm](double* psi_in,double* hpsi_out,
113-
const int ldPsi, const int nvec)
113+
const int ld_psi, const int nvec)
114114
{
115-
auto psi_iter_wrapper = psi::Psi<double>(psi_in, 1, nvec, ldPsi, nullptr);
115+
auto psi_iter_wrapper = psi::Psi<double>(psi_in, 1, nvec, ld_psi, nullptr);
116116
psi::Range bands_range(true, 0, 0, nvec-1);
117117
using hpsi_info = typename hamilt::Operator<double>::hpsi_info;
118118
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
@@ -121,7 +121,7 @@ class DiagoDavPrepare
121121
auto spsi_func = [phm](const double* psi_in, double* spsi_out,const int nrow, const int npw, const int nbands){
122122
phm->sPsi(psi_in, spsi_out, nrow, npw, nbands);
123123
};
124-
dav.diag(hpsi_func,spsi_func, ldPsi, phi.get_pointer(), en, eps, maxiter);
124+
dav.diag(hpsi_func,spsi_func, ld_psi, phi.get_pointer(), en, eps, maxiter);
125125

126126
#ifdef __MPI
127127
end = MPI_Wtime();

source/module_hsolver/test/diago_david_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class DiagoDavPrepare
9191

9292
const int dim = phi.get_current_nbas();
9393
const int nband = phi.get_nbands();
94-
const int ldPsi = phi.get_nbasis();
94+
const int ld_psi = phi.get_nbasis();
9595
hsolver::DiagoDavid<std::complex<double>> dav(precondition, nband, dim, order, false, comm_info);
9696

9797
hsolver::DiagoIterAssist<std::complex<double>>::PW_DIAG_NMAX = maxiter;
@@ -110,9 +110,9 @@ class DiagoDavPrepare
110110

111111

112112
auto hpsi_func = [phm](std::complex<double>* psi_in,std::complex<double>* hpsi_out,
113-
const int ldPsi, const int nvec)
113+
const int ld_psi, const int nvec)
114114
{
115-
auto psi_iter_wrapper = psi::Psi<std::complex<double>>(psi_in, 1, nvec, ldPsi, nullptr);
115+
auto psi_iter_wrapper = psi::Psi<std::complex<double>>(psi_in, 1, nvec, ld_psi, nullptr);
116116
psi::Range bands_range(1, 0, 0, nvec-1);
117117
using hpsi_info = typename hamilt::Operator<std::complex<double>>::hpsi_info;
118118
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
@@ -121,7 +121,7 @@ class DiagoDavPrepare
121121
auto spsi_func = [phm](const std::complex<double>* psi_in, std::complex<double>* spsi_out,const int nrow, const int npw, const int nbands){
122122
phm->sPsi(psi_in, spsi_out, nrow, npw, nbands);
123123
};
124-
dav.diag(hpsi_func,spsi_func, ldPsi, phi.get_pointer(), en, eps, maxiter);
124+
dav.diag(hpsi_func,spsi_func, ld_psi, phi.get_pointer(), en, eps, maxiter);
125125

126126
#ifdef __MPI
127127
end = MPI_Wtime();

source/module_hsolver/test/hsolver_pw_sup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ DiagoDavid<T, Device>::~DiagoDavid() {
155155
template <typename T, typename Device>
156156
int DiagoDavid<T, Device>::diag(const std::function<void(T*, T*, const int, const int)>& hpsi_func,
157157
const std::function<void(T*, T*, const int, const int, const int)>& spsi_func,
158-
const int ldPsi,
158+
const int ld_psi,
159159
T *psi_in,
160160
Real* eigenvalue_in,
161161
const Real david_diag_thr,

source/module_lr/hsolver_lrtd.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ namespace LR
8585
auto hpsi_func = [pHamilt](
8686
T* psi_in,
8787
T* hpsi_out,
88-
const int ldPsi,
88+
const int ld_psi,
8989
const int nvec)
9090
{
91-
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ldPsi, nullptr);
91+
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ld_psi, nullptr);
9292
psi::Range bands_range(true, 0, 0, nvec-1);
9393
using hpsi_info = typename hamilt::Operator<T, Device>::hpsi_info;
9494
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
@@ -120,10 +120,10 @@ namespace LR
120120
auto hpsi_func = [pHamilt](
121121
T* psi_in,
122122
T* hpsi_out,
123-
const int ldPsi,
123+
const int ld_psi,
124124
const int nvec)
125125
{
126-
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ldPsi, nullptr);
126+
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ld_psi, nullptr);
127127
psi::Range bands_range(true, 0, 0, nvec-1);
128128
using hpsi_info = typename hamilt::Operator<T, Device>::hpsi_info;
129129
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);

0 commit comments

Comments
 (0)