Hi again, By the way, I made a small package which may be useful (unless its functionality is already part of PDL and I missed it): PDL::ApplyDim. The idea is to factor out a common shuffling and unshuffling of indices before calling pdl functions/methods that act only on the first dimension(s). So, instead of
$pdl->mv($dim,0)->function($some, $extra, $args)->mv(0, $dim); one may write $pdl->apply_to(\&function, $dim, $some, $extra, $args); $pdl->apply_to("function", $dim, $some, $extra, $args); apply_to($pdl, \&function", $dim, $some, $extra, $args); or apply_to($pdl, "function", $dim, $some, $extra, $args); ... For example, a scalar time dependent field, f(x,y,z,t) may be represented by a 4D ndarray $f. We have $f->xvals, $f->yvals, $f->zvals, but no $f->tvals. We could define sub tvals($pdl){$pdl->apply_to(3, \&xvals) Similarly, instead of $pdl->reorder(3,2,0,1)->function(@otherargs)->reorder(2,3,1,0); to move dimensions 3 and 2 to the front and shift the rest towards the end, apply the function and then recover the original order, one may write $pdl->apply_to(\&function, [3,2], @otherargs); or more generally $pdl->apply_to(\&function, [$d0, $d1, $d2...], @otherargs); The converse function is apply_not_to, to move the given dimensions to the end, applying the function and then restoring them back to the front. For example, to make a D-dimensional Fourier transform of a rank 3 tensor field, represented by a (D+3)-dimensional ndarray, one would have to move the first three dimensions (the tesorial indices) to the end, perform the D-dimensional Fourier transform over the first D indices and then bring the tensorial indices back to the front. Regards, Luis On Sat, Jan 11, 2025 at 11:52:53AM -0600, Luis Mochan wrote: > I didn't know (or had forgotten) about the pptemplate; I'll try it, thanks. -- o W. Luis Mochán, | tel:(52)(777)329-1734 /<(*) Instituto de Ciencias Físicas, UNAM | fax:(52)(777)317-5388 `>/ /\ Av. Universidad s/n CP 62210 | (*)/\/ \ Cuernavaca, Morelos, México | moc...@fis.unam.mx /\_/\__/ GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16 C2DF 5F0A C52B 791E B9EB _______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel