Skip to content

Commit

Permalink
Improve formatting of spatialDistribution pseudo-code
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Nov 11, 2020
1 parent e5f1e16 commit a240071
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions chapters/operatorsandexpressions.tex
Expand Up @@ -857,27 +857,33 @@ \subsubsection{spatialDistribution}\label{spatialdistribution}
* also known as "short-circuit evaluation of x and y".
*/
if positiveVelocity then
out1 := interpolate(points, values, 1-(x-x0));
out1 := interpolate(points, values, 1 - (x - x0));
out0 := values[1]; // similar to in0 but avoiding algebraic loop
else
out0 := interpolate(points, values, 0-(x-x0));
out0 := interpolate(points, values, 0 - (x - x0));
out1 := values[end]; // similar to in1 but avoiding algebraic loop
end if;
when <acceptedStep> then
if x>x0 then
if x > x0 then
m := size(points, 1);
while m > 0 <and then> points[m] + (x - x0) >= 1 loop
m := m-1;
m := m - 1;
end while;
values := cat(1, {in0}, values[1:m], {interpolate(points, values,1-(x-x0))});
values := cat(1,
{in0},
values[1:m],
{interpolate(points, values, 1 - (x - x0))});
points := cat(1, {0}, points[1:m] .+ (x-x0), {1});
elseif x<x0 then
elseif x < x0 then
m := 1;
while m < size(points, 1) <and then> points[m] + (x - x0) <= 0 loop
m := m+1;
m := m + 1;
end while;
values := cat(1, {interpolate(points, values, 0 - (x - x0))}, values[m:end], {in1});
points := cat(1, {0}, points[m:end] .+ (x-x0), {1});
values := cat(1,
{interpolate(points, values, 0 - (x - x0))},
values[m:end],
{in1});
points := cat(1, {0}, points[m:end] .+ (x - x0), {1});
end if;
x0 := x;
end when;
Expand Down

0 comments on commit a240071

Please sign in to comment.