Guest User

Untitled

a guest
Dec 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. struct SPH {
  2. x: Vec<f32>,
  3. y: Vec<f32>,
  4. h: Vec<f32>,
  5. }
  6.  
  7. impl SPH {
  8. fn new() -> Self {
  9. SPH {
  10. x: vec![0.; 10],
  11. y: vec![0.; 10],
  12. h: vec![0.; 10],
  13. }
  14. }
  15. }
  16.  
  17. // pair(d_x, d_y, d_h, s_x, s_y, s_h);
  18. fn pair(d_x: &[f32], d_y: &[f32], d_h: &mut [f32], s_x: &[f32], s_y: &[f32], s_h: &[f32]) {
  19. for i in 0..d_h.len() {
  20. for j in 0..s_h.len(){
  21.  
  22. d_h[i] += s_x[j] * s_y[j] * d_x[i] * d_y[i];
  23. }
  24. }
  25. }
  26. macro_rules! macro_pair{
  27. ($func_name:ident, $dest:ty, $source:ty) => {
  28. $func_name(& dest.x, &dest.y, &mut dest.h, &source.x, &source.y, &source.h);
  29. }
  30. }
  31.  
  32. fn main() {
  33. let mut sph_d = SPH::new();
  34. let sph_s = SPH::new();
  35. // pair(&sph_d.x, &sph_d.y, &mut sph_d.h, &sph_s.x, &sph_s.y, &sph_s.h);
  36. macro_pair!(pair, sph_d, sph_s);
  37. }
Add Comment
Please, Sign In to add comment