Clear Filters
Clear Filters

pdepe/pde1dm's vectorized option

8 views (last 30 days)
feynman feynman
feynman feynman on 4 Feb 2024
Commented: feynman feynman on 10 Mar 2024
In pdepe, when vectorized is turned on, the elapsed time is the same as that when vectorized is off. Why no improvement?
The doc of pde1dm says that for vectorized mode, we return coefficients at multiple x locations, so in the pdefunc function
nx=length(x); c = ones(1,nx);
need to replace the original
c=1
While pde1dm requires the above change in the pdefunc function code, when c and s in the pdefunc function aren't changed to their vector form, pdepe still allows vectorized to be turned on. Why such a difference?
  18 Comments
Torsten
Torsten on 10 Mar 2024
Edited: Torsten on 10 Mar 2024
Sure, if you can vectorize this loop in the "pdepe" code and rewrite "pdentrp" such that it accepts array inputs, you are done:
% Interior points
for ii = 2:nx-1
[U,Ux] = pdentrp(singular,m,xmesh(ii),u(:,ii),xmesh(ii+1),u(:,ii+1),xi(ii));
[cR,fR,sR] = feval(pde,xi(ii),tnow,U,Ux,varargin{:});
denom = zxmp1(ii) * cR + xzmp1(ii-1) * cL;
denom(denom == 0) = 1;
up(:,ii) = ((xim(ii) * fR - xim(ii-1) * fL) + ...
(zxmp1(ii) * sR + xzmp1(ii-1) * sL)) ./ denom;
cL = cR;
fL = fR;
sL = sR;
end
feynman feynman
feynman feynman on 10 Mar 2024
thank you very much for the hint!

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!