hermespy-rt

Minimalistic signal processing ray-tracer in C
git clone https://git.ea.contact/hermespy-rt
Log | Files | Refs

commit c47da21a13b3fcd239aa07656c7fa1789f76a7b8
parent ecee01318a3f755140ca5ed1966e225ab656790c
Author: Egor Achkasov <eaachkasov@edu.hse.ru>
Date:   Tue, 14 Jan 2025 15:32:25 +0100

Add num_samples arg

Diffstat:
Mcompute_paths.c | 4++--
Mcompute_paths.h | 3+++
Mcompute_paths_pybind11.cpp | 13++++++++-----
Mtest.c | 3++-
Mtest.py | 4+++-
5 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/compute_paths.c b/compute_paths.c @@ -389,6 +389,7 @@ void compute_paths( IN size_t num_tx, /* number of transmitters */ IN size_t num_paths, /* number of paths */ IN size_t num_bounces, /* number of bounces */ + IN size_t num_samples, /* number of samples */ OUT float *a_te_re, /* output array real parts of TE gains (num_rx, num_tx, num_paths) */ OUT float *a_te_im, /* output array imaginary parts of TE gains (num_rx, num_tx, num_paths) */ OUT float *a_tm_re, /* output array real parts of TM gains (num_rx, num_tx, num_paths) */ @@ -472,8 +473,7 @@ void compute_paths( tau[off] += t / SPEED_OF_LIGHT; /* Advance the ray to the hit point */ *h = vec3_scale(&r->d, t); - *h = vec3_add(h, &r->o); - r->o = *h; + r->o = vec3_add(h, &r->o); } } free(h); diff --git a/compute_paths.h b/compute_paths.h @@ -22,6 +22,8 @@ * \param num_rx number of receivers. Must be > 0 * \param num_tx number of transmitters. Must be > 0 * \param num_paths number of paths to compute. Must be > 0 + * \param num_bounces number of bounces to compute. Must be > 0 + * \param num_samples number of samples in the original signal. Must be > 0 * \param a_te_re output array of real parts of transverse electric gains, shape (num_rx, num_tx, num_paths) * \param a_te_im output array of imaginary parts of transverse electric gains, shape (num_rx, num_tx, num_paths) * \param a_tm_re output array of real parts of transverse magnetic gains, shape (num_rx, num_tx, num_paths) @@ -39,6 +41,7 @@ void compute_paths( IN size_t num_tx, /* number of transmitters */ IN size_t num_paths, /* number of paths */ IN size_t num_bounces, /* number of bounces */ + IN size_t num_samples, /* number of samples */ OUT float *a_te_re, /* output array real parts of TE gains (num_rx, num_tx, num_paths) */ OUT float *a_te_im, /* output array imaginary parts of TE gains (num_rx, num_tx, num_paths) */ OUT float *a_tm_re, /* output array real parts of TM gains (num_rx, num_tx, num_paths) */ diff --git a/compute_paths_pybind11.cpp b/compute_paths_pybind11.cpp @@ -12,9 +12,9 @@ extern "C" { namespace py = pybind11; std::tuple< - py::array_t<float>, py::array_t<float>, - py::array_t<float>, py::array_t<float>, - py::array_t<float> > + py::array_t<float>, py::array_t<float>, // a_te_re, a_te_im + py::array_t<float>, py::array_t<float>, // a_tm_re, a_tm_im + py::array_t<float> > // tau compute_paths_wrapper( const std::string &mesh_filepath, py::array_t<float> rx_positions, @@ -25,7 +25,8 @@ compute_paths_wrapper( int num_rx, int num_tx, int num_paths, - int num_bounces + int num_bounces, + int num_samples ) { // Prepare input arrays (this is a basic implementation, check shapes and memory layout) py::buffer_info rx_pos_info = rx_positions.request(); @@ -52,6 +53,7 @@ compute_paths_wrapper( (size_t)num_tx, (size_t)num_paths, (size_t)num_bounces, + (size_t)num_samples, a_te_re, a_te_im, a_tm_re, a_tm_im, // Gains tau // Delays ); @@ -90,7 +92,8 @@ PYBIND11_MODULE(rt, m) { py::arg("num_rx"), py::arg("num_tx"), py::arg("num_paths"), - py::arg("num_bounces")); + py::arg("num_bounces"), + py::arg("num_samples")); // Scene filepaths m.def("get_scene_fp_box", diff --git a/test.c b/test.c @@ -19,6 +19,7 @@ int main(int argc, char **argv) size_t num_tx = 1; size_t num_paths = 10000; size_t num_bounces = 3; + size_t num_samples = 150; float *a_te_re = (float*)malloc(num_rx * num_tx * num_paths * sizeof(float)); float *a_te_im = (float*)malloc(num_rx * num_tx * num_paths * sizeof(float)); float *a_tm_re = (float*)malloc(num_rx * num_tx * num_paths * sizeof(float)); @@ -31,7 +32,7 @@ int main(int argc, char **argv) rx_velocities, tx_velocities, carrier_frequency, - num_rx, num_tx, num_paths, num_bounces, + num_rx, num_tx, num_paths, num_bounces, num_samples, a_te_re, a_te_im, a_tm_re, a_tm_im, tau); diff --git a/test.py b/test.py @@ -12,6 +12,7 @@ num_rx = 1 num_tx = 1 num_paths = 10000 num_bounces = 3 +num_samples = 150 # Call compute_paths a_te_re, a_te_im, a_tm_re, a_tm_im, tau = compute_paths( @@ -24,7 +25,8 @@ a_te_re, a_te_im, a_tm_re, a_tm_im, tau = compute_paths( num_rx, num_tx, num_paths, - num_bounces + num_bounces, + num_samples ) print(f"TE Gains: {a_te_re + 1.j*a_te_im}")