Skip to content

Commit 7353295

Browse files
committed
Finish
1 parent 2391a68 commit 7353295

File tree

3 files changed

+16
-56
lines changed

3 files changed

+16
-56
lines changed

source/module_base/test/math_chebyshev_test.cpp

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ class MathChebyshevTest : public testing::Test
107107

108108
TEST_F(MathChebyshevTest, calcoef_real)
109109
{
110-
#ifdef __MPI
111-
#undef __MPI
112-
#endif
113110
auto fun_x6 = [&](double x) { return fun.x6(x); };
114111
auto fun_x7 = [&](double x) { return fun.x7(x); };
115112
p_chetest = new ModuleBase::Chebyshev<double>(10);
@@ -133,9 +130,6 @@ TEST_F(MathChebyshevTest, calcoef_real)
133130

134131
TEST_F(MathChebyshevTest, calcoef_pair)
135132
{
136-
#ifdef __MPI
137-
#undef __MPI
138-
#endif
139133
auto fun_x6 = [&](double x) { return fun.x6(x); };
140134
auto fun_x7 = [&](double x) { return fun.x7(x); };
141135
p_chetest = new ModuleBase::Chebyshev<double>(10);
@@ -154,9 +148,6 @@ TEST_F(MathChebyshevTest, calcoef_pair)
154148

155149
TEST_F(MathChebyshevTest, calcoef_complex)
156150
{
157-
#ifdef __MPI
158-
#undef __MPI
159-
#endif
160151
auto fun_expi = [&](std::complex<double> x) { return fun.expi(x); };
161152
const int norder = 100;
162153
const double PI = 3.14159265358979323846;
@@ -178,9 +169,6 @@ TEST_F(MathChebyshevTest, calcoef_complex)
178169

179170
TEST_F(MathChebyshevTest, calfinalvec_real)
180171
{
181-
#ifdef __MPI
182-
#undef __MPI
183-
#endif
184172
const int norder = 100;
185173
const double E = 2.718281828459046;
186174
p_chetest = new ModuleBase::Chebyshev<double>(norder);
@@ -215,9 +203,6 @@ TEST_F(MathChebyshevTest, calfinalvec_real)
215203

216204
TEST_F(MathChebyshevTest, calfinalvec_complex)
217205
{
218-
#ifdef __MPI
219-
#undef __MPI
220-
#endif
221206
const int norder = 100;
222207
const double E = 2.718281828459046;
223208
p_chetest = new ModuleBase::Chebyshev<double>(norder);
@@ -252,9 +237,6 @@ TEST_F(MathChebyshevTest, calfinalvec_complex)
252237

253238
TEST_F(MathChebyshevTest, calpolyvec_complex)
254239
{
255-
#ifdef __MPI
256-
#undef __MPI
257-
#endif
258240
const int norder = 100;
259241
const double E = 2.718281828459046;
260242
p_chetest = new ModuleBase::Chebyshev<double>(norder);
@@ -302,9 +284,6 @@ TEST_F(MathChebyshevTest, calpolyvec_complex)
302284

303285
TEST_F(MathChebyshevTest, tracepolyA)
304286
{
305-
#ifdef __MPI
306-
#undef __MPI
307-
#endif
308287
const int norder = 100;
309288
p_chetest = new ModuleBase::Chebyshev<double>(norder);
310289

@@ -359,7 +338,6 @@ TEST_F(MathChebyshevTest, checkconverge)
359338
{
360339
#ifdef __MPI
361340
#undef __MPI
362-
#endif
363341
const int norder = 100;
364342
p_chetest = new ModuleBase::Chebyshev<double>(norder);
365343
auto fun_sigma_y
@@ -401,13 +379,12 @@ TEST_F(MathChebyshevTest, checkconverge)
401379

402380
delete[] v;
403381
delete p_chetest;
382+
#define __MPI
383+
#endif
404384
}
405385

406386
TEST_F(MathChebyshevTest, recurs)
407387
{
408-
#ifdef __MPI
409-
#undef __MPI
410-
#endif
411388
testing::internal::CaptureStdout();
412389
EXPECT_EXIT(ModuleBase::Chebyshev<double> noneche(0), ::testing::ExitedWithCode(1), "");
413390
std::string output = testing::internal::GetCapturedStdout();
@@ -423,9 +400,6 @@ TEST_F(MathChebyshevTest, recurs)
423400
#ifdef __ENABLE_FLOAT_FFTW
424401
TEST_F(MathChebyshevTest, calcoef_real_float)
425402
{
426-
#ifdef __MPI
427-
#undef __MPI
428-
#endif
429403
auto fun_x6f = [&](float x) { return fun.x6(x); };
430404
auto fun_x7f = [&](float x) { return fun.x7(x); };
431405
p_fchetest = new ModuleBase::Chebyshev<float>(10);
@@ -448,9 +422,6 @@ TEST_F(MathChebyshevTest, calcoef_real_float)
448422

449423
TEST_F(MathChebyshevTest, calcoef_pair_float)
450424
{
451-
#ifdef __MPI
452-
#undef __MPI
453-
#endif
454425
auto fun_x6f = [&](float x) { return fun.x6(x); };
455426
auto fun_x7f = [&](float x) { return fun.x7(x); };
456427
p_fchetest = new ModuleBase::Chebyshev<float>(10);
@@ -469,9 +440,6 @@ TEST_F(MathChebyshevTest, calcoef_pair_float)
469440

470441
TEST_F(MathChebyshevTest, calcoef_complex_float)
471442
{
472-
#ifdef __MPI
473-
#undef __MPI
474-
#endif
475443
auto fun_expif = [&](std::complex<float> x) { return fun.expi(x); };
476444
const int norder = 100;
477445
const float PI = 3.14159265358979323846;
@@ -493,9 +461,6 @@ TEST_F(MathChebyshevTest, calcoef_complex_float)
493461

494462
TEST_F(MathChebyshevTest, calfinalvec_real_float)
495463
{
496-
#ifdef __MPI
497-
#undef __MPI
498-
#endif
499464
const int norder = 100;
500465
const float E = 2.718281828459046;
501466
p_fchetest = new ModuleBase::Chebyshev<float>(norder);
@@ -530,9 +495,6 @@ TEST_F(MathChebyshevTest, calfinalvec_real_float)
530495

531496
TEST_F(MathChebyshevTest, calfinalvec_complex_float)
532497
{
533-
#ifdef __MPI
534-
#undef __MPI
535-
#endif
536498
const int norder = 100;
537499
const float E = 2.718281828459046;
538500
p_fchetest = new ModuleBase::Chebyshev<float>(norder);
@@ -567,9 +529,6 @@ TEST_F(MathChebyshevTest, calfinalvec_complex_float)
567529

568530
TEST_F(MathChebyshevTest, calpolyvec_float)
569531
{
570-
#ifdef __MPI
571-
#undef __MPI
572-
#endif
573532
const int norder = 100;
574533
const float E = 2.718281828459046;
575534
p_fchetest = new ModuleBase::Chebyshev<float>(norder);
@@ -617,9 +576,6 @@ TEST_F(MathChebyshevTest, calpolyvec_float)
617576

618577
TEST_F(MathChebyshevTest, tracepolyA_float)
619578
{
620-
#ifdef __MPI
621-
#undef __MPI
622-
#endif
623579
const int norder = 100;
624580
p_fchetest = new ModuleBase::Chebyshev<float>(norder);
625581

@@ -669,9 +625,6 @@ TEST_F(MathChebyshevTest, tracepolyA_float)
669625

670626
TEST_F(MathChebyshevTest, checkconverge_float)
671627
{
672-
#ifdef __MPI
673-
#undef __MPI
674-
#endif
675628
const int norder = 100;
676629
p_fchetest = new ModuleBase::Chebyshev<float>(norder);
677630

source/module_base/test/opt_CG_test.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,64 +148,69 @@ TEST_F(CG_test, Stand_Solve_LinearEq)
148148
{
149149
#ifdef __MPI
150150
#undef __MPI
151-
#endif
152151
CG_Solve_LinearEq();
153152
EXPECT_NEAR(x[0], 0.5, DOUBLETHRESHOLD);
154153
EXPECT_NEAR(x[1], 1.6429086563584579739e-18, DOUBLETHRESHOLD);
155154
EXPECT_NEAR(x[2], 1.5, DOUBLETHRESHOLD);
156155
ASSERT_EQ(final_iter, 4);
157156
ASSERT_EQ(cg.get_iter(), 4);
157+
#define __MPI
158+
#endif
158159
}
159160

160161
TEST_F(CG_test, PR_Solve_LinearEq)
161162
{
162163
#ifdef __MPI
163164
#undef __MPI
164-
#endif
165165
Solve(1, 0);
166166
EXPECT_NEAR(x[0], 0.50000000000003430589, DOUBLETHRESHOLD);
167167
EXPECT_NEAR(x[1], -3.4028335704761047964e-14, DOUBLETHRESHOLD);
168168
EXPECT_NEAR(x[2], 1.5000000000000166533, DOUBLETHRESHOLD);
169169
ASSERT_EQ(final_iter, 3);
170170
ASSERT_EQ(cg.get_iter(), 3);
171+
#define __MPI
172+
#endif
171173
}
172174

173175
TEST_F(CG_test, HZ_Solve_LinearEq)
174176
{
175177
#ifdef __MPI
176178
#undef __MPI
177-
#endif
178179
Solve(2, 0);
179180
EXPECT_NEAR(x[0], 0.49999999999999944489, DOUBLETHRESHOLD);
180181
EXPECT_NEAR(x[1], -9.4368957093138305936e-16, DOUBLETHRESHOLD);
181182
EXPECT_NEAR(x[2], 1.5000000000000011102, DOUBLETHRESHOLD);
182183
ASSERT_EQ(final_iter, 3);
183184
ASSERT_EQ(cg.get_iter(), 3);
185+
#define __MPI
186+
#endif
184187
}
185188

186189
TEST_F(CG_test, PR_Min_Func)
187190
{
188191
#ifdef __MPI
189192
#undef __MPI
190-
#endif
191193
Solve(1, 1);
192194
EXPECT_NEAR(x[0], 4.0006805979150792396, DOUBLETHRESHOLD);
193195
EXPECT_NEAR(x[1], 2.0713759992720870429, DOUBLETHRESHOLD);
194196
EXPECT_NEAR(x[2], 9.2871067233169171118, DOUBLETHRESHOLD);
195197
ASSERT_EQ(final_iter, 18);
196198
ASSERT_EQ(cg.get_iter(), 18);
199+
#define __MPI
200+
#endif
197201
}
198202

199203
TEST_F(CG_test, HZ_Min_Func)
200204
{
201205
#ifdef __MPI
202206
#undef __MPI
203-
#endif
204207
Solve(2, 1);
205208
EXPECT_NEAR(x[0], 4.0006825378033568086, DOUBLETHRESHOLD);
206209
EXPECT_NEAR(x[1], 2.0691732100663737803, DOUBLETHRESHOLD);
207210
EXPECT_NEAR(x[2], 9.2780872787668311474, DOUBLETHRESHOLD);
208211
ASSERT_EQ(final_iter, 18);
209212
ASSERT_EQ(cg.get_iter(), 18);
213+
#define __MPI
214+
#endif
210215
}
211216
// g++ -std=c++11 ../opt_CG.cpp ../opt_DCsrch.cpp ./CG_test.cpp ./test_tools.cpp -lgtest -lpthread -lgtest_main -o test.exe

source/module_base/test/opt_TN_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,26 @@ TEST_F(TN_test, TN_Solve_LinearEq)
112112
{
113113
#ifdef __MPI
114114
#undef __MPI
115-
#endif
116115
Solve(0);
117116
EXPECT_NEAR(x[0], 0.50000000000003430589, DOUBLETHRESHOLD);
118117
EXPECT_NEAR(x[1], -3.4028335704761047964e-14, DOUBLETHRESHOLD);
119118
EXPECT_NEAR(x[2], 1.5000000000000166533, DOUBLETHRESHOLD);
120119
ASSERT_EQ(final_iter, 1);
121120
ASSERT_EQ(tn.get_iter(), 1);
121+
#define __MPI
122+
#endif
122123
}
123124

124125
TEST_F(TN_test, TN_Min_Func)
125126
{
126127
#ifdef __MPI
127128
#undef __MPI
128-
#endif
129129
Solve(1);
130130
EXPECT_NEAR(x[0], 4.0049968540891525137, DOUBLETHRESHOLD);
131131
EXPECT_NEAR(x[1], 2.1208751163987624722, DOUBLETHRESHOLD);
132132
EXPECT_NEAR(x[2], 9.4951527720891863993, DOUBLETHRESHOLD);
133133
ASSERT_EQ(final_iter, 6);
134134
ASSERT_EQ(tn.get_iter(), 6);
135+
#define __MPI
136+
#endif
135137
}

0 commit comments

Comments
 (0)