Skip to content

Commit 26fa4d5

Browse files
committed
modify the name by removing "_" in macro TEST/TEST_F
modify the comment by moving name and date behind the function name replace self-difined PI by the macro M_PI defined in math.in
1 parent 83e4445 commit 26fa4d5

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

source/module_base/math_integral.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ class Integral
1414
~Integral();
1515

1616
/**
17-
* @brief simpson integral. Peize Lin accelerate 2017-10-02
17+
* @brief simpson integral.
1818
*
19-
* @param mesh [in] mhe number of grid points (should be odd)
19+
* @param mesh [in] number of grid points (should be odd)
2020
* @param func [in] function to be integrated
2121
* @param rab [in] a list of interval
2222
* @param asum [out] the final integral value
2323
*/
24-
static void Simpson_Integral
25-
(
24+
static void Simpson_Integral // Peize Lin accelerate 2017-10-02
25+
(
2626
const int mesh,
2727
const double * const func,
2828
const double * const rab,
2929
double &asum
3030
);
3131

3232
/**
33-
* @brief simpson integral. Peize Lin accelerate 2017-10-02
33+
* @brief simpson integral.
3434
*
35-
* @param mesh [in] mhe number of grid points (should be odd)
35+
* @param mesh [in] number of grid points (should be odd)
3636
* @param func [in] function to be integrated
3737
* @param dr [in] interval
3838
* @param asum [out] the final integral value
3939
*/
40-
static void Simpson_Integral
40+
static void Simpson_Integral //Peize Lin accelerate 2017-10-02
4141
(
4242
const int mesh,
4343
const double * const func,
@@ -46,15 +46,15 @@ class Integral
4646
);
4747

4848
/**
49-
* @brief simpson integral. Peize Lin add 2016-02-14.
49+
* @brief simpson integral.
5050
*
5151
*
52-
* @param mesh [in] mhe number of grid points
52+
* @param mesh [in] number of grid points
5353
* @param func [in] function to be integrated
5454
* @param rab [in] a list of interval
5555
* @param asum [out] a list of integral value. asum[i] = integral from 0 to i. The max index of asum is an even (mesh-1 or mesh).
5656
*/
57-
static void Simpson_Integral_0toall
57+
static void Simpson_Integral_0toall //Peize Lin add 2016-02-14.
5858
(
5959
const int mesh,
6060
const double * const func,
@@ -63,14 +63,14 @@ class Integral
6363
);
6464

6565
/**
66-
* @brief simpson integral. Peize Lin add 2016-02-14.
66+
* @brief simpson integral.
6767
*
68-
* @param mesh [in] mhe number of grid points
68+
* @param mesh [in] number of grid points
6969
* @param func [in] function to be integrated
7070
* @param rab [in] r(i) * dr(i)/di * di or (b-a)/2n
7171
* @param asum [out] a list of integral value. sum[i] = integral from i to mesh-1.
7272
*/
73-
static void Simpson_Integral_alltoinf
73+
static void Simpson_Integral_alltoinf //Peize Lin add 2016-02-14.
7474
(
7575
const int mesh,
7676
const double * const func,

source/module_base/test/math_integral_test.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
#include<math.h>
55

6-
#define PI 3.14159265358979
76
#define doublethreshold 1e-12
87

8+
9+
910
/************************************************
1011
* unit test of class Integral
1112
***********************************************/
@@ -19,7 +20,7 @@
1920
*
2021
*/
2122

22-
class Simpson_Integral_sinx : public testing::Test
23+
class SimpsonIntegralSinx : public testing::Test
2324
{
2425
/**
2526
* test the integral of sinx between [0,PI],
@@ -31,7 +32,7 @@ class Simpson_Integral_sinx : public testing::Test
3132
double* func;
3233
double* rab;
3334
int mesh = 10001;
34-
double dr = PI/(mesh-1);
35+
double dr = M_PI/(mesh-1);
3536
double asum;
3637
double* asumlist;
3738
double expectvalue = 2.0;
@@ -44,7 +45,7 @@ class Simpson_Integral_sinx : public testing::Test
4445

4546
for (int i=0;i<mesh;i++)
4647
{
47-
func[i] = sin(PI*i/(mesh-1));
48+
func[i] = sin(M_PI*i/(mesh-1));
4849
rab[i] = dr;
4950
}
5051
}
@@ -57,21 +58,23 @@ class Simpson_Integral_sinx : public testing::Test
5758
}
5859
};
5960

60-
TEST_F(Simpson_Integral_sinx,Simpson_Integral_rab)
61+
62+
63+
TEST_F(SimpsonIntegralSinx,SimpsonIntegralRab)
6164
{
6265
ModuleBase::Integral::Simpson_Integral(mesh,func,rab,asum);
6366
EXPECT_NEAR(asum,expectvalue,doublethreshold);
6467
EXPECT_DEATH(ModuleBase::Integral::Simpson_Integral(mesh-1,func,rab,asum),"");
6568
}
6669

67-
TEST_F(Simpson_Integral_sinx,Simpson_Integral_dr)
70+
TEST_F(SimpsonIntegralSinx,SimpsonIntegralDr)
6871
{
6972
ModuleBase::Integral::Simpson_Integral(mesh,func,dr,asum);
7073
EXPECT_NEAR(asum,expectvalue,doublethreshold);
7174
EXPECT_DEATH(ModuleBase::Integral::Simpson_Integral(mesh-1,func,dr,asum),"");
7275
}
7376

74-
TEST_F(Simpson_Integral_sinx,Simpson_Integral_0toall)
77+
TEST_F(SimpsonIntegralSinx,SimpsonIntegral0toall)
7578
{
7679
int halfmesh = round(mesh/2);
7780
ModuleBase::Integral::Simpson_Integral_0toall(mesh,func,rab,asumlist);
@@ -82,7 +85,7 @@ TEST_F(Simpson_Integral_sinx,Simpson_Integral_0toall)
8285
}
8386

8487

85-
TEST_F(Simpson_Integral_sinx,Simpson_Integral_alltoinf)
88+
TEST_F(SimpsonIntegralSinx,SimpsonIntegralAlltoinf)
8689
{
8790
int halfmesh = round(mesh/2);
8891
ModuleBase::Integral::Simpson_Integral_alltoinf(mesh,func,rab,asumlist);

0 commit comments

Comments
 (0)