Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct SPH {
- x: Vec<f32>,
- y: Vec<f32>,
- h: Vec<f32>,
- }
- impl SPH {
- fn new() -> Self {
- SPH {
- x: vec![0.; 10],
- y: vec![0.; 10],
- h: vec![0.; 10],
- }
- }
- }
- // pair(d_x, d_y, d_h, s_x, s_y, s_h);
- fn pair(d_x: &[f32], d_y: &[f32], d_h: &mut [f32], s_x: &[f32], s_y: &[f32], s_h: &[f32]) {
- for i in 0..d_h.len() {
- for j in 0..s_h.len(){
- d_h[i] += s_x[j] * s_y[j] * d_x[i] * d_y[i];
- }
- }
- }
- macro_rules! macro_pair{
- ($func_name:ident, $dest:ty, $source:ty) => {
- $func_name(& dest.x, &dest.y, &mut dest.h, &source.x, &source.y, &source.h);
- }
- }
- fn main() {
- let mut sph_d = SPH::new();
- let sph_s = SPH::new();
- // pair(&sph_d.x, &sph_d.y, &mut sph_d.h, &sph_s.x, &sph_s.y, &sph_s.h);
- macro_pair!(pair, sph_d, sph_s);
- }
Add Comment
Please, Sign In to add comment