Advertisement
Guest User

parallel pool Constant

a guest
Apr 12th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.82 KB | None | 0 0
  1. A_ct = parallel.pool.Constant(A);
  2. b_ct = parallel.pool.Constant(b);
  3.  
  4. future_results(i) = parfeval(p, @hybrid_parallel_function, 3, A_ct, b_ct, x, x_last, buck_bound, n, start_itv, end_itv);
  5.  
  6. function [x_par, start_itv, end_itv] = hybrid_parallel_function (A_ct, b_ct, x, x_last, buck_bound, n, start_itv, end_itv)
  7.     x_par = zeros(end_itv - start_itv + 1, 1);
  8.     for i = start_itv:end_itv
  9.         x_par(i-start_itv+1) = b_ct.Value(i);
  10.         x_par(i-start_itv+1) = x_par(i-start_itv+1) - A_ct.Value(i, 1:buck_bound) * x(1:buck_bound);
  11.         x_par(i-start_itv+1) = x_par(i-start_itv+1) - A_ct.Value(i, buck_bound+1:i-1) * x_last(buck_bound+1:i-1);
  12.         x_par(i-start_itv+1) = x_par(i-start_itv+1) - A_ct.Value(i, i+1:n) * x_last(i+1:n);
  13.         x_par(i-start_itv+1) = x_par(i-start_itv+1) / A_ct.Value(i, i);
  14.     end
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement