1- #include < pybind11/numpy.h>
2- #include < pybind11/pybind11.h>
3-
4- #include " source_base/math_sphbes.h"
1+ #include " ../utils/pybind_utils.h"
52#include " source_base/math_integral.h"
3+ #include " source_base/math_sphbes.h"
64#include " source_base/spherical_bessel_transformer.h"
75
8- #include " ../utils/pybind_utils.h"
6+ #include < pybind11/numpy.h>
7+ #include < pybind11/pybind11.h>
98
109namespace py = pybind11;
1110using namespace pybind11 ::literals;
@@ -25,21 +24,13 @@ void bind_base_math(py::module& m)
2524 [](const int n, py::array_t <double > r, const double q, const int l, py::array_t <double > jl) {
2625 check_1d_array (r, " r" );
2726 check_1d_array (jl, " jl" );
28- ModuleBase::Sphbes::sphbesj (n,
29- get_array_ptr (r),
30- q,
31- l,
32- get_array_ptr (jl));
27+ ModuleBase::Sphbes::sphbesj (n, get_array_ptr (r), q, l, get_array_ptr (jl));
3328 })
3429 .def_static (" dsphbesj" ,
3530 [](const int n, py::array_t <double > r, const double q, const int l, py::array_t <double > djl) {
3631 check_1d_array (r, " r" );
3732 check_1d_array (djl, " djl" );
38- ModuleBase::Sphbes::dsphbesj (n,
39- get_array_ptr (r),
40- q,
41- l,
42- get_array_ptr (djl));
33+ ModuleBase::Sphbes::dsphbesj (n, get_array_ptr (r), q, l, get_array_ptr (djl));
4334 })
4435 .def_static (" sphbes_zeros" , [](const int l, const int n, py::array_t <double > zeros) {
4536 check_1d_array (zeros, " zeros" );
@@ -49,76 +40,68 @@ void bind_base_math(py::module& m)
4940 // python binding for class Integral
5041 py::class_<ModuleBase::Integral>(m, " Integral" )
5142 .def (py::init<>())
52- .def_static (" Simpson_Integral" , [](const int mesh, py::array_t <double > func, py::array_t <double > rab, double asum) {
53- check_1d_array (func, " func" );
54- check_1d_array (rab, " rab" );
43+ .def_static (" Simpson_Integral" ,
44+ [](const int mesh, py::array_t <double > func, py::array_t <double > rab, double asum) {
45+ check_1d_array (func, " func" );
46+ check_1d_array (rab, " rab" );
5547
56- double isum = asum;
57- ModuleBase::Integral::Simpson_Integral (mesh,
58- get_array_ptr (func),
59- get_array_ptr (rab),
60- isum);
61- return isum;
62- })
63- .def_static (" Simpson_Integral" , [](const int mesh, py::array_t <double > func, const double dr, double asum){
64- check_1d_array (func, " func" );
48+ double isum = asum;
49+ ModuleBase::Integral::Simpson_Integral (mesh, get_array_ptr (func), get_array_ptr (rab), isum);
50+ return isum;
51+ })
52+ .def_static (" Simpson_Integral" ,
53+ [](const int mesh, py::array_t <double > func, const double dr, double asum) {
54+ check_1d_array (func, " func" );
6555
66- double isum = asum;
67- ModuleBase::Integral::Simpson_Integral (mesh,
68- get_array_ptr (func),
69- dr,
70- isum);
71- return isum;
72- })
73- .def_static (" Simpson_Integral_0toall" , [](const int mesh, py::array_t <double > func, py::array_t <double > rab, py::array_t <double > asum){
74- check_1d_array (func, " func" );
75- check_1d_array (rab, " rab" );
76- check_1d_array (asum, " asum" );
77- ModuleBase::Integral::Simpson_Integral_0toall (mesh,
78- get_array_ptr (func),
79- get_array_ptr (rab),
80- get_array_ptr (asum));
81- })
82- .def_static (" Simpson_Integral_alltoinf" , [](const int mesh, py::array_t <double > func, py::array_t <double > rab, py::array_t <double > asum){
83- check_1d_array (func, " func" );
84- check_1d_array (rab, " rab" );
85- check_1d_array (asum, " asum" );
86- ModuleBase::Integral::Simpson_Integral_alltoinf (mesh,
87- get_array_ptr (func),
88- get_array_ptr (rab),
89- get_array_ptr (asum));
90- })
91- .def_static (" simpson" , [](const int n, py::array_t <double > f, const double dx){
92- check_1d_array (f, " f" );
93- return ModuleBase::Integral::simpson (n,
94- get_array_ptr (f),
95- dx);
96- })
97- .def_static (" simpson" , [](const int n, py::array_t <double > f, py::array_t <double > h){
98- check_1d_array (f, " f" );
99- check_1d_array (h, " h" );
100- return ModuleBase::Integral::simpson (n,
101- get_array_ptr (f),
102- get_array_ptr (h));
103- })
104- .def_static (" Gauss_Legendre_grid_and_weight" , [](const int n, py::array_t <double > x, py::array_t <double > w){
105- check_1d_array (x, " x" );
106- check_1d_array (w, " w" );
107- ModuleBase::Integral::Gauss_Legendre_grid_and_weight (n,
108- get_array_ptr (x),
109- get_array_ptr (w));
110- })
111- .def_static (" Gauss_Legendre_grid_and_weight" , [](const double xmin, const double xmax, const int n, py::array_t <double > x, py::array_t <double > w){
112- check_1d_array (x, " x" );
113- check_1d_array (w, " w" );
114- ModuleBase::Integral::Gauss_Legendre_grid_and_weight (xmin,
115- xmax,
116- n,
117- get_array_ptr (x),
118- get_array_ptr (w));
119- });
120- py::class_<ModuleBase::SphericalBesselTransformer>(m, " SphericalBesselTransformer" )
121- .def (py::init<>());
56+ double isum = asum;
57+ ModuleBase::Integral::Simpson_Integral (mesh, get_array_ptr (func), dr, isum);
58+ return isum;
59+ })
60+ .def_static (" Simpson_Integral_0toall" ,
61+ [](const int mesh, py::array_t <double > func, py::array_t <double > rab, py::array_t <double > asum) {
62+ check_1d_array (func, " func" );
63+ check_1d_array (rab, " rab" );
64+ check_1d_array (asum, " asum" );
65+ ModuleBase::Integral::Simpson_Integral_0toall (mesh,
66+ get_array_ptr (func),
67+ get_array_ptr (rab),
68+ get_array_ptr (asum));
69+ })
70+ .def_static (" Simpson_Integral_alltoinf" ,
71+ [](const int mesh, py::array_t <double > func, py::array_t <double > rab, py::array_t <double > asum) {
72+ check_1d_array (func, " func" );
73+ check_1d_array (rab, " rab" );
74+ check_1d_array (asum, " asum" );
75+ ModuleBase::Integral::Simpson_Integral_alltoinf (mesh,
76+ get_array_ptr (func),
77+ get_array_ptr (rab),
78+ get_array_ptr (asum));
79+ })
80+ .def_static (" simpson" ,
81+ [](const int n, py::array_t <double > f, const double dx) {
82+ check_1d_array (f, " f" );
83+ return ModuleBase::Integral::simpson (n, get_array_ptr (f), dx);
84+ })
85+ .def_static (" simpson" ,
86+ [](const int n, py::array_t <double > f, py::array_t <double > h) {
87+ check_1d_array (f, " f" );
88+ check_1d_array (h, " h" );
89+ return ModuleBase::Integral::simpson (n, get_array_ptr (f), get_array_ptr (h));
90+ })
91+ .def_static (" Gauss_Legendre_grid_and_weight" ,
92+ [](const int n, py::array_t <double > x, py::array_t <double > w) {
93+ check_1d_array (x, " x" );
94+ check_1d_array (w, " w" );
95+ ModuleBase::Integral::Gauss_Legendre_grid_and_weight (n, get_array_ptr (x), get_array_ptr (w));
96+ })
97+ .def_static (
98+ " Gauss_Legendre_grid_and_weight" ,
99+ [](const double xmin, const double xmax, const int n, py::array_t <double > x, py::array_t <double > w) {
100+ check_1d_array (x, " x" );
101+ check_1d_array (w, " w" );
102+ ModuleBase::Integral::Gauss_Legendre_grid_and_weight (xmin, xmax, n, get_array_ptr (x), get_array_ptr (w));
103+ });
104+ py::class_<ModuleBase::SphericalBesselTransformer>(m, " SphericalBesselTransformer" ).def (py::init<>());
122105}
123106
124107PYBIND11_MODULE (_base_pack, m)
0 commit comments