Skip to content

Commit

Permalink
Make the signature of rle accurate for the new usage.
Browse files Browse the repository at this point in the history
This required some very light PP acrobatics to allow a & b to have
different dimension than c but still make threading work OK.
  • Loading branch information
d-lamb committed Sep 29, 2016
1 parent 19b3a39 commit 2151584
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Basic/Slices/slices.pd
Expand Up @@ -1253,7 +1253,9 @@ EOD

pp_def(
'rle',
Pars=>'c(n); indx [o]a(n); [o]b(n);',
Pars=>'c(n); indx [o]a(m); [o]b(m);',
#this RedoDimsCode sets $SIZE(m)==$SIZE(n), but the slice in the PMCode below makes m<=n.
RedoDimsCode=>'$SIZE(m)=$PDL(c)->dims[0];',
PMCode=><<'EOC',
sub PDL::rle {
my $c = shift;
Expand All @@ -1268,21 +1270,21 @@ EOC
PDL_Indx j=0,sn=$SIZE(n);
$GENERIC(c) cv, clv;
clv = $c(n=>0);
$b(n=>0) = clv;
$a(n=>0) = 0;
$b(m=>0) = clv;
$a(m=>0) = 0;
loop (n) %{
cv = $c();
if (cv == clv) {
$a(n=>j)++;
$a(m=>j)++;
} else {
j++;
$b(n=>j) = clv = cv;
$a(n=>j) = 1;
$b(m=>j) = clv = cv;
$a(m=>j) = 1;
}
%}
for (j++;j<sn;j++) {
$a(n=>j) = 0;
$b(n=>j) = 0;
for (j++;j<$SIZE(m);j++) {
$a(m=>j) = 0;
$b(m=>j) = 0;
}
',
Doc => <<'EOD'
Expand Down

0 comments on commit 2151584

Please sign in to comment.