#$=head1 NAME #$ #$fold - fold the ends inside #$ #$=head1 SYNOPSIS #$ #$C #$ #$=head1 PARAMETERS #$ #$=over 4 #$ #$=item adj,add,x,y - #$ #$ Standard operator interface #$ #$=back #$ #$=head1 DESCRIPTION #$ #$Fold portion of y outside x back in on itself #$ #$=head1 SEE ALSO #$ #$L #$ #$=head1 LIBRARY #$ #$B #$ #$=cut module fold { # fold the ends inside #% _lop (x, y) integer :: nu, nr, np, nt nu = size (y) nt = size (x) np = (nt + nu) /2 nr = (nt - nu) /2 + 1 if (adj) { x (nt:np+1:-1) = y (nu-nt+np+1:nu ) + x (nt:np+1:-1) x (nr-1: 1:-1) = y ( 1:nr-1) + x (nr-1: 1:-1) x (nr:np) = y + x (nr:np) } else { y = y + x (nr:np) y ( 1:nr-1) = y ( 1:nr-1) + x (nr-1: 1:-1) y (nu-nt+np+1:nu ) = y (nu-nt+np+1:nu ) + x (nt:np+1:-1) } }