Post by Chris MarshallI'd like to put a plug in here for what I call
PDL3 "use cases" where you give a short
example of code showing what you would
like to be able to do, and if you know the
equivalent that would be helpful as well.
For this specific example, I can think of a
number of options for implementations that
might be investigated. One possibility is
that a dimension could be "index named"
via an index_name hash and then slice
might do the lookup for you in the call
with a specific value, passing the entire
index_name hash object might generate
a loop over all the index values...
Ingo, I know some of this maps into your
PDL::Dims features. Feel free to expand.
The sln() function does that, just that unless you specify an index, the
whole piddle is returned. So you only need to supply those index names
which you want to restrict.
As Chris said, each dimension has its own hash, referred to by PDLs hdr
method(s).
pdl> p keys %{$x->hdr}
x dimnames y ndims
pdl> $x=xvals(10,12)+yvals(10,12)
pdl> p $x
[
[ 0 1 2 3 4 5 6 7 8 9]
[ 1 2 3 4 5 6 7 8 9 10]
[ 2 3 4 5 6 7 8 9 10 11]
[ 3 4 5 6 7 8 9 10 11 12]
[ 4 5 6 7 8 9 10 11 12 13]
[ 5 6 7 8 9 10 11 12 13 14]
[ 6 7 8 9 10 11 12 13 14 15]
[ 7 8 9 10 11 12 13 14 15 16]
[ 8 9 10 11 12 13 14 15 16 17]
[ 9 10 11 12 13 14 15 16 17 18]
[10 11 12 13 14 15 16 17 18 19]
[11 12 13 14 15 16 17 18 19 20]
]
pdl> initdim $x,'x'
pdl> initdim $x,'y'
pdl> p sln $x
[
[ 0 1 2 3 4 5 6 7 8 9]
[ 1 2 3 4 5 6 7 8 9 10]
[ 2 3 4 5 6 7 8 9 10 11]
[ 3 4 5 6 7 8 9 10 11 12]
[ 4 5 6 7 8 9 10 11 12 13]
[ 5 6 7 8 9 10 11 12 13 14]
[ 6 7 8 9 10 11 12 13 14 15]
[ 7 8 9 10 11 12 13 14 15 16]
[ 8 9 10 11 12 13 14 15 16 17]
[ 9 10 11 12 13 14 15 16 17 18]
[10 11 12 13 14 15 16 17 18 19]
[11 12 13 14 15 16 17 18 19 20]
]
pdl> p sln $x,'x',3
[
[ 3]
[ 4]
[ 5]
[ 6]
[ 7]
[ 8]
[ 9]
[10]
[11]
[12]
[13]
[14]
]
pdl> p sln $x,x=>"1:5:2",y=>"3:7:2"
[
[ 4 6 8]
[ 6 8 10]
[ 8 10 12]
]
Ingo
Post by Chris Marshall--Chris
thanks Chris for mentioning it. I just uploaded a new version. I'd
appreciate any feedback on usability, features, etc.
Ingo
Post by Chris MarshallTake a look at PDL::Dims.
Is there a way to use hash-like keys for the rows ?
I mean w/o using external hash-to-idx map.