I put up some basic code along these lines here:
Data cube.
Turned out going the PDL route didn't offer much -- wasn't
a math issue as much as a data access issue -- so I followed the
suggestions of
japhy and
gryng and
built a module.
It is slow, but it did the trick for me.
nop