Skip to content

Commit a3ba673

Browse files
[pre-commit.ci lite] apply automatic fixes
1 parent 2716cef commit a3ba673

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

source/module_hsolver/test/diago_david_real_test.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ void lapackEigen(int& npw, std::vector<double>& hm, double* e, bool outtime = fa
4848
double* work2 = new double[lwork];
4949
dsyev_(&tmp_c1, &tmp_c2, &npw, tmp.data(), &npw, e, work2, &lwork, &info);
5050
end = clock();
51-
if (info) std::cout << "ERROR: Lapack solver, info=" << info << std::endl;
52-
if (outtime) std::cout << "Lapack Run time: " << (double)(end - start) / CLOCKS_PER_SEC << " S" << std::endl;
51+
if (info) { std::cout << "ERROR: Lapack solver, info=" << info << std::endl;
52+
}
53+
if (outtime) { std::cout << "Lapack Run time: " << (double)(end - start) / CLOCKS_PER_SEC << " S" << std::endl;
54+
}
5355
delete[] work2;
5456
}
5557
class DiagoDavPrepare
@@ -73,7 +75,8 @@ class DiagoDavPrepare
7375
//calculate eigenvalues by LAPACK;
7476
double* e_lapack = new double[npw];
7577
double* ev;
76-
if (mypnum == 0) lapackEigen(npw, DIAGOTEST::hmatrix_d, e_lapack, DETAILINFO);
78+
if (mypnum == 0) { lapackEigen(npw, DIAGOTEST::hmatrix_d, e_lapack, DETAILINFO);
79+
}
7780

7881
//do Diago_David::diag()
7982
double* en = new double[npw];
@@ -110,7 +113,7 @@ class DiagoDavPrepare
110113
const int ldPsi, const int nvec)
111114
{
112115
auto psi_iter_wrapper = psi::Psi<double>(psi_in, 1, nvec, ldPsi, nullptr);
113-
psi::Range bands_range(1, 0, 0, nvec-1);
116+
psi::Range bands_range(true, 0, 0, nvec-1);
114117
using hpsi_info = typename hamilt::Operator<double>::hpsi_info;
115118
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
116119
phm->ops->hPsi(info);
@@ -130,7 +133,8 @@ class DiagoDavPrepare
130133

131134
if (mypnum == 0)
132135
{
133-
if (DETAILINFO) std::cout << "diag Run time: " << use_time << std::endl;
136+
if (DETAILINFO) { std::cout << "diag Run time: " << use_time << std::endl;
137+
}
134138
for (int i = 0;i < nband;i++)
135139
{
136140
EXPECT_NEAR(en[i], e_lapack[i], CONVTHRESHOLD);
@@ -147,8 +151,9 @@ class DiagoDavTest : public ::testing::TestWithParam<DiagoDavPrepare> {};
147151
TEST_P(DiagoDavTest, RandomHamilt)
148152
{
149153
DiagoDavPrepare ddp = GetParam();
150-
if (DETAILINFO && ddp.mypnum == 0) std::cout << "npw=" << ddp.npw << ", nband=" << ddp.nband << ", sparsity="
154+
if (DETAILINFO && ddp.mypnum == 0) { std::cout << "npw=" << ddp.npw << ", nband=" << ddp.nband << ", sparsity="
151155
<< ddp.sparsity << ", eps=" << ddp.eps << std::endl;
156+
}
152157

153158
HPsi<double> hpsi(ddp.nband, ddp.npw, ddp.sparsity);
154159
DIAGOTEST::hmatrix_d = hpsi.hamilt();
@@ -235,7 +240,8 @@ int main(int argc, char** argv)
235240

236241
testing::InitGoogleTest(&argc, argv);
237242
::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners();
238-
if (myrank != 0) delete listeners.Release(listeners.default_result_printer());
243+
if (myrank != 0) { delete listeners.Release(listeners.default_result_printer());
244+
}
239245

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

0 commit comments

Comments
 (0)