pdepe/pde1dm's vectorized option

5 visualizaciones (últimos 30 días)
feynman feynman
feynman feynman el 4 de Feb. de 2024
Comentada: feynman feynman el 10 de Mzo. de 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 comentarios
Torsten
Torsten el 10 de Mzo. de 2024
Editada: Torsten el 10 de Mzo. de 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 el 10 de Mzo. de 2024
thank you very much for the hint!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by