Skip to content

Commit

Permalink
simplify augment with loop()
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Sep 5, 2024
1 parent ae8d223 commit 2c7db3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
42 changes: 15 additions & 27 deletions Real/real.pd
Original file line number Diff line number Diff line change
Expand Up @@ -10584,37 +10584,25 @@ EOT
);


pp_def(
'augment',
DefaultFlow => 1,
TwoWay => 1,
Pars => 'x(n); y(p);[o]out(q=CALC($SIZE(n)+$SIZE(p)))',
Code => '
loop(n) %{
$out(q=>n) = $x();
%}
register PDL_Indx i,j = 0;
for (i=$SIZE(n); i < $SIZE(q); i++,j++)
$out(q=>i) = $y(p=>j);
',
BackCode => '
loop(n) %{
$x() = $out(q=>n);
%}
register PDL_Indx i,j = 0;
for (i=$SIZE(n); i < $SIZE(q); i++,j++)
$y(p=>j) = $out(q=>i);
',
Doc => <<EOT
pp_def('augment',
DefaultFlow => 1,
TwoWay => 1,
Pars => 'x(n); y(p);[o]out(q=CALC($SIZE(n)+$SIZE(p)))',
GenericTypes => [ppdefs_all()],
Code => '
loop (q=:$SIZE(n)) %{ $out() = $x(n=>q); %}
loop (q=$SIZE(n)) %{ $out() = $y(p=>q-$SIZE(n)); %}
',
BackCode => '
loop (q=:$SIZE(n)) %{ $x(n=>q) = $out(); %}
loop (q=$SIZE(n)) %{ $y(p=>q-$SIZE(n)) = $out(); %}
',
Doc => <<EOT
=for ref

Combine two ndarrays into a single ndarray.
Combine two ndarrays into a single ndarray along the 0-th ("horizontal") dim.
This routine does backward and forward dataflow automatically.

=cut

EOT

);

pp_def('mstack',
Expand Down
2 changes: 1 addition & 1 deletion lib/PDL/LinearAlgebra/Special.pm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ The elements are:
H (i,j) = r (i+j-m+1), otherwise
where m is the size of the vector.
If c is a scalar number, it's determinant can be computed by:
If c is a scalar number, its determinant can be computed by:
floor(n/2) n
Det(H(n)) = (-1) * n
Expand Down

0 comments on commit 2c7db3b

Please sign in to comment.