Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 66 additions & 83 deletions python/pyabacus/src/ModuleBase/py_base_math.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>

#include "source_base/math_sphbes.h"
#include "../utils/pybind_utils.h"
#include "source_base/math_integral.h"
#include "source_base/math_sphbes.h"
#include "source_base/sph_bessel_tf.h"

#include "../utils/pybind_utils.h"
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>

namespace py = pybind11;
using namespace pybind11::literals;
Expand All @@ -25,21 +24,13 @@ void bind_base_math(py::module& m)
[](const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> jl) {
check_1d_array(r, "r");
check_1d_array(jl, "jl");
ModuleBase::Sphbes::sphbesj(n,
get_array_ptr(r),
q,
l,
get_array_ptr(jl));
ModuleBase::Sphbes::sphbesj(n, get_array_ptr(r), q, l, get_array_ptr(jl));
})
.def_static("dsphbesj",
[](const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> djl) {
check_1d_array(r, "r");
check_1d_array(djl, "djl");
ModuleBase::Sphbes::dsphbesj(n,
get_array_ptr(r),
q,
l,
get_array_ptr(djl));
ModuleBase::Sphbes::dsphbesj(n, get_array_ptr(r), q, l, get_array_ptr(djl));
})
.def_static("sphbes_zeros", [](const int l, const int n, py::array_t<double> zeros) {
check_1d_array(zeros, "zeros");
Expand All @@ -49,76 +40,68 @@ void bind_base_math(py::module& m)
// python binding for class Integral
py::class_<ModuleBase::Integral>(m, "Integral")
.def(py::init<>())
.def_static("Simpson_Integral", [](const int mesh, py::array_t<double> func, py::array_t<double> rab, double asum) {
check_1d_array(func, "func");
check_1d_array(rab, "rab");
.def_static("Simpson_Integral",
[](const int mesh, py::array_t<double> func, py::array_t<double> rab, double asum) {
check_1d_array(func, "func");
check_1d_array(rab, "rab");

double isum = asum;
ModuleBase::Integral::Simpson_Integral(mesh,
get_array_ptr(func),
get_array_ptr(rab),
isum);
return isum;
})
.def_static("Simpson_Integral", [](const int mesh, py::array_t<double> func, const double dr, double asum){
check_1d_array(func, "func");
double isum = asum;
ModuleBase::Integral::Simpson_Integral(mesh, get_array_ptr(func), get_array_ptr(rab), isum);
return isum;
})
.def_static("Simpson_Integral",
[](const int mesh, py::array_t<double> func, const double dr, double asum) {
check_1d_array(func, "func");

double isum = asum;
ModuleBase::Integral::Simpson_Integral(mesh,
get_array_ptr(func),
dr,
isum);
return isum;
})
.def_static("Simpson_Integral_0toall", [](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum){
check_1d_array(func, "func");
check_1d_array(rab, "rab");
check_1d_array(asum, "asum");
ModuleBase::Integral::Simpson_Integral_0toall(mesh,
get_array_ptr(func),
get_array_ptr(rab),
get_array_ptr(asum));
})
.def_static("Simpson_Integral_alltoinf", [](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum){
check_1d_array(func, "func");
check_1d_array(rab, "rab");
check_1d_array(asum, "asum");
ModuleBase::Integral::Simpson_Integral_alltoinf(mesh,
get_array_ptr(func),
get_array_ptr(rab),
get_array_ptr(asum));
})
.def_static("simpson", [](const int n, py::array_t<double> f, const double dx){
check_1d_array(f, "f");
return ModuleBase::Integral::simpson(n,
get_array_ptr(f),
dx);
})
.def_static("simpson", [](const int n, py::array_t<double> f, py::array_t<double> h){
check_1d_array(f, "f");
check_1d_array(h, "h");
return ModuleBase::Integral::simpson(n,
get_array_ptr(f),
get_array_ptr(h));
})
.def_static("Gauss_Legendre_grid_and_weight", [](const int n, py::array_t<double> x, py::array_t<double> w){
check_1d_array(x, "x");
check_1d_array(w, "w");
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(n,
get_array_ptr(x),
get_array_ptr(w));
})
.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){
check_1d_array(x, "x");
check_1d_array(w, "w");
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(xmin,
xmax,
n,
get_array_ptr(x),
get_array_ptr(w));
});
py::class_<ModuleBase::SphericalBesselTransformer>(m, "SphericalBesselTransformer")
.def(py::init<>());
double isum = asum;
ModuleBase::Integral::Simpson_Integral(mesh, get_array_ptr(func), dr, isum);
return isum;
})
.def_static("Simpson_Integral_0toall",
[](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum) {
check_1d_array(func, "func");
check_1d_array(rab, "rab");
check_1d_array(asum, "asum");
ModuleBase::Integral::Simpson_Integral_0toall(mesh,
get_array_ptr(func),
get_array_ptr(rab),
get_array_ptr(asum));
})
.def_static("Simpson_Integral_alltoinf",
[](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum) {
check_1d_array(func, "func");
check_1d_array(rab, "rab");
check_1d_array(asum, "asum");
ModuleBase::Integral::Simpson_Integral_alltoinf(mesh,
get_array_ptr(func),
get_array_ptr(rab),
get_array_ptr(asum));
})
.def_static("simpson",
[](const int n, py::array_t<double> f, const double dx) {
check_1d_array(f, "f");
return ModuleBase::Integral::simpson(n, get_array_ptr(f), dx);
})
.def_static("simpson",
[](const int n, py::array_t<double> f, py::array_t<double> h) {
check_1d_array(f, "f");
check_1d_array(h, "h");
return ModuleBase::Integral::simpson(n, get_array_ptr(f), get_array_ptr(h));
})
.def_static("Gauss_Legendre_grid_and_weight",
[](const int n, py::array_t<double> x, py::array_t<double> w) {
check_1d_array(x, "x");
check_1d_array(w, "w");
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(n, get_array_ptr(x), get_array_ptr(w));
})
.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) {
check_1d_array(x, "x");
check_1d_array(w, "w");
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(xmin, xmax, n, get_array_ptr(x), get_array_ptr(w));
});
py::class_<ModuleBase::SphericalBesselTransformer>(m, "SphericalBesselTransformer").def(py::init<>());
}

PYBIND11_MODULE(_base_pack, m)
Expand Down
Loading
Loading