Skip to content

Commit

Permalink
not do mv if no-op
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Feb 13, 2024
1 parent afabc1b commit cbdf65b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions Basic/Core/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,13 @@ sub PDL::ndcoords {
unshift(@d,$type) if defined($type);
my $out = PDL->zeroes(@d);
for my $d(0..$#dims) {
my $w = $out->index($d)->mv($d,0);
my $w = $out->index($d);
$w = $w->mv($d,0) if $d != 0;
$w .= xvals($w);
}
$out;
}
*ndcoords = \&PDL::ndcoords;
*allaxisvals = \&PDL::ndcoords;
*PDL::allaxisvals = \&PDL::ndcoords;
*ndcoords = *allaxisvals = *PDL::allaxisvals = \&PDL::ndcoords;

=head2 hist
Expand Down
8 changes: 4 additions & 4 deletions Libtmp/FFT/fft.pd
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ sub PDL::fftnd {
$i = $i->copy;
foreach (0..$n) {
fft($r,$i);
$r = $r->mv(0,$n);
$i = $i->mv(0,$n);
$r = $r->mv(0,$n) if 0 != $n;
$i = $i->mv(0,$n) if 0 != $n;
}
if (!$_[0]->type->real) {
$_[0]= czip($r, $i);
Expand Down Expand Up @@ -332,8 +332,8 @@ sub PDL::ifftnd {
$n--;
foreach (0..$n) {
ifft($r,$i);
$r = $r->mv(0,$n);
$i = $i->mv(0,$n);
$r = $r->mv(0,$n) if 0 != $n;
$i = $i->mv(0,$n) if 0 != $n;
}
if (!$_[0]->type->real) {
$_[0]= czip($r, $i);
Expand Down
6 changes: 3 additions & 3 deletions Libtmp/ImageND/imagend.pd
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,18 @@ sub PDL::rebin {
} elsif ($odims[$i] != $idims[$i]) { # If something changes
if (!($odims[$i] % $idims[$i])) { # Cells map 1 -> n
my ($r) = $odims[$i]/$idims[$i];
$y = $x->mv($i,0)->dupN($r);
$y = ($i==0 ? $x : $x->mv($i,0))->dupN($r);
} elsif (!($idims[$i] % $odims[$i])) { # Cells map n -> 1
my ($r) = $idims[$i]/$odims[$i];
$x = $x->mv($i,0);
$x = $x->mv($i,0) if $i != 0;
# -> copy so won\'t corrupt input PDL
$y = $x->slice("0:-1:$r")->copy;
foreach (1..$r-1) {
$y += $x->slice("$_:-1:$r");
}
$y /= $r;
} else { # Cells map n -> m
&PDL::_rebin_int($x->mv($i,0), $y = null, $odims[$i]);
&PDL::_rebin_int(($i==0 ? $x : $x->mv($i,0)), $y = null, $odims[$i]);
}
$x = $y->mv(0,$i);
}
Expand Down

0 comments on commit cbdf65b

Please sign in to comment.