Skip to content

Commit ae173e6

Browse files
committed
Make pretty (6th attempt)
1 parent 26e8842 commit ae173e6

2,028 files changed

Lines changed: 339134 additions & 299738 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

python/pyabacus/src/ModuleBase/py_base_math.cpp

Lines changed: 108 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -14,116 +14,122 @@ using namespace pyabacus::utils;
1414
template <typename... Args>
1515
using overload_cast_ = pybind11::detail::overload_cast_impl<Args...>;
1616

17-
void bind_base_math(py::module& m)
17+
void
18+
bind_base_math (py::module& m)
1819
{
1920
// python binding for class Sphbes
20-
py::class_<ModuleBase::Sphbes>(m, "Sphbes")
21-
.def(py::init<>())
22-
.def_static("sphbesj", overload_cast_<const int, const double>()(&ModuleBase::Sphbes::sphbesj), "l"_a, "x"_a)
23-
.def_static("dsphbesj", overload_cast_<const int, const double>()(&ModuleBase::Sphbes::dsphbesj), "l"_a, "x"_a)
24-
.def_static("sphbesj",
25-
[](const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> jl) {
26-
check_1d_array(r, "r");
27-
check_1d_array(jl, "jl");
28-
ModuleBase::Sphbes::sphbesj(n,
29-
get_array_ptr(r),
30-
q,
31-
l,
32-
get_array_ptr(jl));
33-
})
34-
.def_static("dsphbesj",
35-
[](const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> djl) {
36-
check_1d_array(r, "r");
37-
check_1d_array(djl, "djl");
38-
ModuleBase::Sphbes::dsphbesj(n,
39-
get_array_ptr(r),
40-
q,
41-
l,
42-
get_array_ptr(djl));
43-
})
44-
.def_static("sphbes_zeros", [](const int l, const int n, py::array_t<double> zeros) {
45-
check_1d_array(zeros, "zeros");
46-
ModuleBase::Sphbes::sphbes_zeros(l, n, get_array_ptr(zeros));
47-
});
21+
py::class_<ModuleBase::Sphbes> (m, "Sphbes")
22+
.def (py::init<> ())
23+
.def_static ("sphbesj", overload_cast_<const int, const double> () (&ModuleBase::Sphbes::sphbesj), "l"_a, "x"_a)
24+
.def_static ("dsphbesj",
25+
overload_cast_<const int, const double> () (&ModuleBase::Sphbes::dsphbesj),
26+
"l"_a,
27+
"x"_a)
28+
.def_static ("sphbesj",
29+
[] (const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> jl)
30+
{
31+
check_1d_array (r, "r");
32+
check_1d_array (jl, "jl");
33+
ModuleBase::Sphbes::sphbesj (n, get_array_ptr (r), q, l, get_array_ptr (jl));
34+
})
35+
.def_static ("dsphbesj",
36+
[] (const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> djl)
37+
{
38+
check_1d_array (r, "r");
39+
check_1d_array (djl, "djl");
40+
ModuleBase::Sphbes::dsphbesj (n, get_array_ptr (r), q, l, get_array_ptr (djl));
41+
})
42+
.def_static ("sphbes_zeros",
43+
[] (const int l, const int n, py::array_t<double> zeros)
44+
{
45+
check_1d_array (zeros, "zeros");
46+
ModuleBase::Sphbes::sphbes_zeros (l, n, get_array_ptr (zeros));
47+
});
4848

4949
// python binding for class Integral
50-
py::class_<ModuleBase::Integral>(m, "Integral")
51-
.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");
50+
py::class_<ModuleBase::Integral> (m, "Integral")
51+
.def (py::init<> ())
52+
.def_static (
53+
"Simpson_Integral",
54+
[] (const int mesh, py::array_t<double> func, py::array_t<double> rab, double asum)
55+
{
56+
check_1d_array (func, "func");
57+
check_1d_array (rab, "rab");
5558

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");
59+
double isum = asum;
60+
ModuleBase::Integral::Simpson_Integral (mesh, get_array_ptr (func), get_array_ptr (rab), isum);
61+
return isum;
62+
})
63+
.def_static ("Simpson_Integral",
64+
[] (const int mesh, py::array_t<double> func, const double dr, double asum)
65+
{
66+
check_1d_array (func, "func");
6567

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<>());
68+
double isum = asum;
69+
ModuleBase::Integral::Simpson_Integral (mesh, get_array_ptr (func), dr, isum);
70+
return isum;
71+
})
72+
.def_static ("Simpson_Integral_0toall",
73+
[] (const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum)
74+
{
75+
check_1d_array (func, "func");
76+
check_1d_array (rab, "rab");
77+
check_1d_array (asum, "asum");
78+
ModuleBase::Integral::Simpson_Integral_0toall (mesh,
79+
get_array_ptr (func),
80+
get_array_ptr (rab),
81+
get_array_ptr (asum));
82+
})
83+
.def_static ("Simpson_Integral_alltoinf",
84+
[] (const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum)
85+
{
86+
check_1d_array (func, "func");
87+
check_1d_array (rab, "rab");
88+
check_1d_array (asum, "asum");
89+
ModuleBase::Integral::Simpson_Integral_alltoinf (mesh,
90+
get_array_ptr (func),
91+
get_array_ptr (rab),
92+
get_array_ptr (asum));
93+
})
94+
.def_static ("simpson",
95+
[] (const int n, py::array_t<double> f, const double dx)
96+
{
97+
check_1d_array (f, "f");
98+
return ModuleBase::Integral::simpson (n, get_array_ptr (f), dx);
99+
})
100+
.def_static ("simpson",
101+
[] (const int n, py::array_t<double> f, py::array_t<double> h)
102+
{
103+
check_1d_array (f, "f");
104+
check_1d_array (h, "h");
105+
return ModuleBase::Integral::simpson (n, get_array_ptr (f), get_array_ptr (h));
106+
})
107+
.def_static (
108+
"Gauss_Legendre_grid_and_weight",
109+
[] (const int n, py::array_t<double> x, py::array_t<double> w)
110+
{
111+
check_1d_array (x, "x");
112+
check_1d_array (w, "w");
113+
ModuleBase::Integral::Gauss_Legendre_grid_and_weight (n, get_array_ptr (x), get_array_ptr (w));
114+
})
115+
.def_static (
116+
"Gauss_Legendre_grid_and_weight",
117+
[] (const double xmin, const double xmax, const int n, py::array_t<double> x, py::array_t<double> w)
118+
{
119+
check_1d_array (x, "x");
120+
check_1d_array (w, "w");
121+
ModuleBase::Integral::Gauss_Legendre_grid_and_weight (xmin,
122+
xmax,
123+
n,
124+
get_array_ptr (x),
125+
get_array_ptr (w));
126+
});
127+
py::class_<ModuleBase::SphericalBesselTransformer> (m, "SphericalBesselTransformer").def (py::init<> ());
122128
}
123129

124-
PYBIND11_MODULE(_base_pack, m)
130+
PYBIND11_MODULE (_base_pack, m)
125131
{
126-
m.doc() = "Submodule for pyabacus: ModuleBase";
132+
m.doc () = "Submodule for pyabacus: ModuleBase";
127133

128-
bind_base_math(m);
134+
bind_base_math (m);
129135
}

0 commit comments

Comments
 (0)