Skip to content

Commit 7fcf348

Browse files
committed
Rename func and parameters concisely
1 parent ac53706 commit 7fcf348

File tree

9 files changed

+42
-43
lines changed

9 files changed

+42
-43
lines changed

source/source_hsolver/diago_cg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ bool DiagoCG<T, Device>::test_exit_cond(const int& ntry, const int& notconv) con
569569
// In non-self consistent calculation, do until totally converged.
570570
const bool f2 = !scf && notconv > 0;
571571
// if self consistent calculation, if not converged > 5,
572-
// using diagH_subspace and cg method again. ntry++
572+
// using diag_subspace and cg method again. ntry++
573573
const bool f3 = scf && notconv > 5;
574574
return f1 && (f2 || f3);
575575
}

source/source_hsolver/diago_dav_subspace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Diago_DavSubspace
5858
/// maximal iteration number
5959
const int iter_nmax;
6060

61-
/// is diagH_subspace needed?
61+
/// is diag_subspace needed?
6262
const bool is_subspace;
6363

6464
/// the first dimension of the matrix to be diagonalized

source/source_hsolver/diago_iter_assist.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ namespace hsolver
1818
// Produces on output n_band eigenvectors (n_band <= nstart) in evc.
1919
//----------------------------------------------------------------------
2020
template <typename T, typename Device>
21-
void DiagoIterAssist<T, Device>::diagH_subspace(const hamilt::Hamilt<T, Device>* const pHamilt, // hamiltonian operator carrier
21+
void DiagoIterAssist<T, Device>::diag_subspace(const hamilt::Hamilt<T, Device>* const pHamilt, // hamiltonian operator carrier
2222
const psi::Psi<T, Device>& psi, // [in] wavefunction
2323
psi::Psi<T, Device>& evc, // [out] wavefunction, eigenvectors
2424
Real* en, // [out] eigenvalues
2525
int n_band, // [in] number of bands to be calculated, also number of rows
2626
// of evc, if set to 0, n_band = nstart, default 0
27-
const bool is_S_orthogonal // [in] if true, psi is already orthogonalized
27+
const bool S_orth // [in] if true, psi is assumed to be already S-orthogonalized
2828
)
2929
{
3030
ModuleBase::TITLE("DiagoIterAssist", "diag_subspace");
@@ -47,7 +47,7 @@ void DiagoIterAssist<T, Device>::diagH_subspace(const hamilt::Hamilt<T, Device>*
4747
setmem_complex_op()(hcc, 0, nstart * nstart);
4848

4949
// scc is overlap matrix, only needed when psi is not orthogonal
50-
if(!is_S_orthogonal){
50+
if(!S_orth){
5151
resmem_complex_op()(scc, nstart * nstart, "DiagSub::scc");
5252
setmem_complex_op()(scc, 0, nstart * nstart);
5353
}
@@ -96,7 +96,7 @@ void DiagoIterAssist<T, Device>::diagH_subspace(const hamilt::Hamilt<T, Device>*
9696
hcc,
9797
nstart);
9898

99-
if(!is_S_orthogonal){
99+
if(!S_orth){
100100
// Only calculate S_sub if not orthogonal
101101
T *spsi = temp;
102102
// do sPsi for all bands
@@ -121,21 +121,20 @@ void DiagoIterAssist<T, Device>::diagH_subspace(const hamilt::Hamilt<T, Device>*
121121
if (GlobalV::NPROC_IN_POOL > 1)
122122
{
123123
Parallel_Reduce::reduce_pool(hcc, nstart * nstart);
124-
if(!is_S_orthogonal){
124+
if(!S_orth){
125125
Parallel_Reduce::reduce_pool(scc, nstart * nstart);
126126
}
127127
}
128128

129129
// after generation of H and (optionally) S matrix, diag them
130-
if (is_S_orthogonal) {
130+
if (S_orth) {
131131
// Solve standard eigenproblem: H_sub * y = lambda * y
132-
DiagoIterAssist::diagH_LAPACK_standard(nstart, n_band, hcc, nstart, en, vcc);
132+
DiagoIterAssist::diag_heevx(nstart, n_band, hcc, nstart, en, vcc);
133133
} else {
134134
// Solve generalized eigenproblem: H_sub * y = lambda * S_sub * y
135-
DiagoIterAssist::diagH_LAPACK_generalized(nstart, n_band, hcc, scc, nstart, en, vcc);
135+
DiagoIterAssist::diag_hegvd(nstart, n_band, hcc, scc, nstart, en, vcc);
136136
}
137137

138-
139138
const int ld_temp = in_place ? dmax : dmin;
140139

141140
{ // code block to calculate evc
@@ -160,7 +159,7 @@ void DiagoIterAssist<T, Device>::diagH_subspace(const hamilt::Hamilt<T, Device>*
160159
delmem_complex_op()(temp);
161160
}
162161
delmem_complex_op()(hcc);
163-
if(!is_S_orthogonal){
162+
if(!S_orth){
164163
delmem_complex_op()(scc);
165164
}
166165
delmem_complex_op()(vcc);
@@ -315,7 +314,7 @@ void DiagoIterAssist<T, Device>::diagH_subspace_init(hamilt::Hamilt<T, Device>*
315314
}
316315
}*/
317316

318-
DiagoIterAssist::diagH_LAPACK_generalized(nstart, n_band, hcc, scc, nstart, en, vcc);
317+
DiagoIterAssist::diag_hegvd(nstart, n_band, hcc, scc, nstart, en, vcc);
319318

320319
export_vcc(vcc, nstart, n_band);
321320

@@ -381,15 +380,15 @@ void DiagoIterAssist<T, Device>::diagH_subspace_init(hamilt::Hamilt<T, Device>*
381380
}
382381

383382
template <typename T, typename Device>
384-
void DiagoIterAssist<T, Device>::diagH_LAPACK_standard(const int matrix_size,
383+
void DiagoIterAssist<T, Device>::diag_heevx(const int matrix_size,
385384
const int num_eigenpairs,
386385
const T *h,
387386
const int ldh,
388387
Real *e, // always in CPU
389388
T *v)
390389
{
391-
ModuleBase::TITLE("DiagoIterAssist", "diagH_LAPACK_standard");
392-
ModuleBase::timer::tick("DiagoIterAssist", "diagH_LAPACK_standard");
390+
ModuleBase::TITLE("DiagoIterAssist", "diag_heevx");
391+
ModuleBase::timer::tick("DiagoIterAssist", "diag_heevx");
393392

394393
Real *eigenvalues = nullptr;
395394
// device memory for eigenvalues
@@ -414,20 +413,20 @@ void DiagoIterAssist<T, Device>::diagH_LAPACK_standard(const int matrix_size,
414413

415414
delmem_var_op()(eigenvalues);
416415

417-
ModuleBase::timer::tick("DiagoIterAssist", "diagH_LAPACK_standard");
416+
ModuleBase::timer::tick("DiagoIterAssist", "diag_heevx");
418417
}
419418

420419
template <typename T, typename Device>
421-
void DiagoIterAssist<T, Device>::diagH_LAPACK_generalized(const int nstart,
420+
void DiagoIterAssist<T, Device>::diag_hegvd(const int nstart,
422421
const int nbands,
423422
const T *hcc,
424423
const T *scc,
425424
const int ldh, // nstart
426425
Real *e, // always in CPU
427426
T *vcc)
428427
{
429-
ModuleBase::TITLE("DiagoIterAssist", "diagH_LAPACK_generalized");
430-
ModuleBase::timer::tick("DiagoIterAssist", "diagH_LAPACK_generalized");
428+
ModuleBase::TITLE("DiagoIterAssist", "diag_hegvd");
429+
ModuleBase::timer::tick("DiagoIterAssist", "diag_hegvd");
431430

432431
Real *eigenvalues = nullptr;
433432
resmem_var_op()(eigenvalues, nstart);
@@ -465,7 +464,7 @@ void DiagoIterAssist<T, Device>::diagH_LAPACK_generalized(const int nstart,
465464
// dngvx_op<Real, Device>()(ctx, nstart, ldh, hcc, scc, nbands, res, vcc);
466465
// }
467466

468-
ModuleBase::timer::tick("DiagoIterAssist", "diagH_LAPACK_generalized");
467+
ModuleBase::timer::tick("DiagoIterAssist", "diag_hegvd");
469468
}
470469

471470
template <typename T, typename Device>
@@ -557,7 +556,7 @@ void DiagoIterAssist<T, Device>::diag_responce( const T* hcc,
557556
setmem_complex_op()(vcc, 0, nstart * nstart);
558557

559558
// after generation of H and S matrix, diag them
560-
DiagoIterAssist::diagH_LAPACK_generalized(nstart, nstart, hcc, scc, nstart, en, vcc);
559+
DiagoIterAssist::diag_hegvd(nstart, nstart, hcc, scc, nstart, en, vcc);
561560

562561
{ // code block to calculate tar_mat
563562
ModuleBase::gemm_op<T, Device>()('N',
@@ -599,7 +598,7 @@ void DiagoIterAssist<T, Device>::diag_subspace_psi(const T* hcc,
599598
setmem_complex_op()(vcc, 0, nstart * nstart);
600599

601600
// after generation of H and S matrix, diag them
602-
DiagoIterAssist::diagH_LAPACK_generalized(nstart, nstart, hcc, scc, nstart, en, vcc);
601+
DiagoIterAssist::diag_hegvd(nstart, nstart, hcc, scc, nstart, en, vcc);
603602

604603
{ // code block to calculate tar_mat
605604
const int dmin = evc.get_current_ngk();
@@ -633,7 +632,7 @@ template <typename T, typename Device>
633632
bool DiagoIterAssist<T, Device>::test_exit_cond(const int& ntry, const int& notconv)
634633
{
635634
//================================================================
636-
// If this logical function is true, need to do diagH_subspace
635+
// If this logical function is true, need to do diag_subspace
637636
// and cg again.
638637
//================================================================
639638

@@ -649,7 +648,7 @@ bool DiagoIterAssist<T, Device>::test_exit_cond(const int& ntry, const int& notc
649648
const bool f2 = ((!scf && (notconv > 0)));
650649

651650
// if self consistent calculation, if not converged > 5,
652-
// using diagH_subspace and cg method again. ntry++
651+
// using diag_subspace and cg method again. ntry++
653652
const bool f3 = ((scf && (notconv > 5)));
654653
return (f1 && (f2 || f3));
655654
}

source/source_hsolver/diago_iter_assist.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class DiagoIterAssist
4444
* @param n_band Number of bands (eigenvalues/eigenvectors) to compute. Default is 0 (all).
4545
* @param is_S_orthogonal If true, assumes the input wavefunction is already orthogonalized.
4646
*/
47-
static void diagH_subspace(const hamilt::Hamilt<T, Device>* const pHamilt,
47+
static void diag_subspace(const hamilt::Hamilt<T, Device>* const pHamilt,
4848
const psi::Psi<T, Device>& psi,
4949
psi::Psi<T, Device>& evc,
5050
Real *en,
@@ -70,13 +70,13 @@ class DiagoIterAssist
7070
const std::function<void(T*, const int)>& add_to_hcc = [](T* null, const int n) {},
7171
const std::function<void(const T* const, const int, const int)>& export_vcc = [](const T* null, const int n, const int m) {});
7272

73-
static void diagH_LAPACK_standard(const int nstart,
73+
static void diag_heevx(const int nstart,
7474
const int nbands,
7575
const T *hcc,
7676
const int ldh,
7777
Real *e,
7878
T *vcc);
79-
static void diagH_LAPACK_generalized(const int nstart,
79+
static void diag_hegvd(const int nstart,
8080
const int nbands,
8181
const T *hcc,
8282
const T *sc,

source/source_hsolver/hsolver_pw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
247247
if (this->method == "cg")
248248
{
249249
// wrap the subspace_func into a lambda function
250-
// if assume_orthogonal is true, then solve standard eigenproblem
250+
// if S_orth is true, then assume psi is S-orthogonal, solve standard eigenproblem
251251
// otherwise, solve generalized eigenproblem
252-
auto subspace_func = [hm, cur_nbasis](const ct::Tensor& psi_in, ct::Tensor& psi_out, const bool assume_S_orthogonal) {
252+
auto subspace_func = [hm, cur_nbasis](const ct::Tensor& psi_in, ct::Tensor& psi_out, const bool S_orth) {
253253
// psi_in should be a 2D tensor:
254254
// psi_in.shape() = [nbands, nbasis]
255255
const auto ndim = psi_in.shape().ndim();
@@ -269,7 +269,7 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
269269
ct::DeviceType::CpuDevice,
270270
ct::TensorShape({psi_in.shape().dim_size(0)}));
271271

272-
DiagoIterAssist<T, Device>::diagH_subspace(hm, psi_in_wrapper, psi_out_wrapper, eigen.data<Real>(), assume_S_orthogonal);
272+
DiagoIterAssist<T, Device>::diag_subspace(hm, psi_in_wrapper, psi_out_wrapper, eigen.data<Real>(), S_orth);
273273
};
274274
DiagoCG<T, Device> cg(this->basis_type,
275275
this->calculation_type,

source/source_hsolver/kernels/dngvd_op.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ struct dnevx_op
9797
///
9898
/// Input Parameters
9999
/// @param d : the type of device
100-
/// @param matrix_size : the size of square matrix
100+
/// @param ndim : the size of square matrix
101101
/// @param lda : leading dimension of the matrix
102-
/// @param A : the hermitian matrix A in A x=lambda x (row major)
103-
/// @param num_eigenpairs : the number of eigenpairs to be calculated
102+
/// @param A : the hermitian matrix A in A x=lambda x
103+
/// @param neig : the number of eigenpairs to be calculated
104104
/// Output Parameter
105105
/// @param eigenvalues: calculated eigenvalues
106-
/// @param eigenvectors: calculated eigenvectors (row major)
107-
void operator()(const Device *d, const int matrix_size, const int lda, const T *A, const int num_eigenpairs, Real *eigenvalues, T *eigenvectors);
106+
/// @param eigenvectors: calculated eigenvectors
107+
void operator()(const Device *d, const int ndim, const int lda, const T *A, const int neig, Real *eigenvalues, T *eigenvectors);
108108
};
109109

110110
#if __CUDA || __UT_USE_CUDA || __ROCM || __UT_USE_ROCM

source/source_hsolver/test/test_diago_assist.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class TestDiagoIterAssist : public ::testing::Test
2727
std::ofstream temp_ofs;
2828
};
2929

30-
TEST_F(TestDiagoIterAssist, diagH_subspace)
30+
TEST_F(TestDiagoIterAssist, diag_subspace)
3131
{
32-
dia_f::diagH_subspace();
33-
dia_d::diagH_subspace();
32+
dia_f::diag_subspace();
33+
dia_d::diag_subspace();
3434
EXPECT_EQ(true);
3535
}
3636

source/source_lcao/module_lr/hsolver_lrtd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace LR
110110
}
111111
else if (method == "cg")
112112
{
113-
////// `diagH_subspace` needs refactor:
113+
////// `diag_subspace` needs refactor:
114114
////// replace `Hamilt*` with `hpsi_func`
115115
////// or I cannot use `is_subspace=true` as my `HamiltLR` does not inherit `Hamilt`.
116116

@@ -129,7 +129,7 @@ namespace LR
129129
// auto eigen = ct::Tensor(ct::DataTypeToEnum<Real<T>>::value,
130130
// ct::DeviceType::CpuDevice,
131131
// ct::TensorShape({ psi_in.shape().dim_size(0) }));
132-
// hsolver::DiagoIterAssist<T>::diagH_subspace(hm, psi_in_wrapper, psi_out_wrapper, eigen.data<Real<T>>());
132+
// hsolver::DiagoIterAssist<T>::diag_subspace(hm, psi_in_wrapper, psi_out_wrapper, eigen.data<Real<T>>());
133133
// };
134134

135135
////// why diago_cg depends on basis_type?

source/source_psi/psi_init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ void PSIInit<T, Device>::initialize_psi(Psi<std::complex<double>>* psi,
166166
}
167167
else
168168
{
169-
// for diagH_subspace, psi_device->get_pointer() and kspw_psi->get_pointer() can be the same
170-
hsolver::DiagoIterAssist<T, Device>::diagH_subspace(p_hamilt,
169+
// for diag_subspace, psi_device->get_pointer() and kspw_psi->get_pointer() can be the same
170+
hsolver::DiagoIterAssist<T, Device>::diag_subspace(p_hamilt,
171171
*psi_device,
172172
*kspw_psi,
173173
etatom.data(),

0 commit comments

Comments
 (0)