I believe the most important difficulty faced here is in trying to mix n-dimension slice-type operations (ending "ND": whichND, indexND, whereND) with single-dimension slice-type ops (which, index, where). What you call "threading" (now known as "broadcasting", in line with other array-programming environments) isn't really at play here, other than the (quite correct for your application) use of n-dimensional ops.
It's possible to switch between the two modes of indexing an ndarray using https://metacpan.org/pod/PDL::Primitive#one2nd.
To answer your last question: depending on what kind of iterating you have in mind, your general approach of supplying what looks to me like a "kernel" (+/-1 on the various dims) to add to the results of a whichND looks sound. Doing all the things you want to happen in a single PDL operation (on data that holds all the operands) is what I believe is "the PDL way".
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.