Skip to content

Commit f811ceb

Browse files
[pre-commit.ci lite] apply automatic fixes
1 parent b3cdbb5 commit f811ceb

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

source/module_hsolver/test/diago_david_float_test.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ void lapackEigen(int &npw, std::vector<std::complex<float>> &hm, float * e, bool
4646
char tmp_c1 = 'V', tmp_c2 = 'U';
4747
cheev_(&tmp_c1, &tmp_c2, &npw, tmp.data(), &npw, e, work2, &lwork, rwork, &info);
4848
end = clock();
49-
if(info) std::cout << "ERROR: Lapack solver, info=" << info <<std::endl;
50-
if (outtime) std::cout<<"Lapack Run time: "<<(float)(end - start) / CLOCKS_PER_SEC<<" S"<<std::endl;
49+
if(info) { std::cout << "ERROR: Lapack solver, info=" << info <<std::endl;
50+
}
51+
if (outtime) { std::cout<<"Lapack Run time: "<<(float)(end - start) / CLOCKS_PER_SEC<<" S"<<std::endl;
52+
}
5153

5254
delete [] rwork;
5355
delete [] work2;
@@ -74,7 +76,8 @@ class DiagoDavPrepare
7476
//calculate eigenvalues by LAPACK;
7577
float* e_lapack = new float[npw];
7678
float* ev;
77-
if(mypnum == 0) lapackEigen(npw, DIAGOTEST::hmatrix_f, e_lapack,DETAILINFO);
79+
if(mypnum == 0) { lapackEigen(npw, DIAGOTEST::hmatrix_f, e_lapack,DETAILINFO);
80+
}
7881

7982
//do Diago_David::diag()
8083
float* en = new float[npw];
@@ -111,7 +114,7 @@ class DiagoDavPrepare
111114
const int ld_psi, const int nvec)
112115
{
113116
auto psi_iter_wrapper = psi::Psi<std::complex<float>>(psi_in, 1, nvec, ld_psi, nullptr);
114-
psi::Range bands_range(1, 0, 0, nvec-1);
117+
psi::Range bands_range(true, 0, 0, nvec-1);
115118
using hpsi_info = typename hamilt::Operator<std::complex<float>>::hpsi_info;
116119
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
117120
phm->ops->hPsi(info);
@@ -131,7 +134,8 @@ class DiagoDavPrepare
131134

132135
if(mypnum == 0)
133136
{
134-
if (DETAILINFO) std::cout<<"diag Run time: "<< use_time << std::endl;
137+
if (DETAILINFO) { std::cout<<"diag Run time: "<< use_time << std::endl;
138+
}
135139
for(int i=0;i<nband;i++)
136140
{
137141
EXPECT_NEAR(en[i],e_lapack[i],CONVTHRESHOLD);
@@ -148,8 +152,9 @@ class DiagoDavTest : public ::testing::TestWithParam<DiagoDavPrepare> {};
148152
TEST_P(DiagoDavTest,RandomHamilt)
149153
{
150154
DiagoDavPrepare ddp = GetParam();
151-
if (DETAILINFO&&ddp.mypnum==0) std::cout << "npw=" << ddp.npw << ", nband=" << ddp.nband << ", sparsity="
155+
if (DETAILINFO&&ddp.mypnum==0) { std::cout << "npw=" << ddp.npw << ", nband=" << ddp.nband << ", sparsity="
152156
<< ddp.sparsity << ", eps=" << ddp.eps << std::endl;
157+
}
153158

154159
HPsi<std::complex<float>> hpsi(ddp.nband, ddp.npw, ddp.sparsity);
155160
DIAGOTEST::hmatrix_f = hpsi.hamilt();
@@ -236,7 +241,8 @@ int main(int argc, char **argv)
236241

237242
testing::InitGoogleTest(&argc, argv);
238243
::testing::TestEventListeners &listeners = ::testing::UnitTest::GetInstance()->listeners();
239-
if (myrank != 0) delete listeners.Release(listeners.default_result_printer());
244+
if (myrank != 0) { delete listeners.Release(listeners.default_result_printer());
245+
}
240246

241247
int result = RUN_ALL_TESTS();
242248
if (myrank == 0 && result != 0)

0 commit comments

Comments
 (0)