I have a data structure problem that I think I need some help on.
The goal is to have an abstraction for N arbitrarily but statically shaped
growable arrays. These arrays are in D. The Shapes of the arrays are in
Ds. I have a series of flags for each cell of the arrays Z which is a
boolean mask on D. I then have a set of data X that maps to arbitrary
cells in D. Xi should represent the mapping indexes that indicate what
cells X maps onto in D.
I have three basic operations that I need to perform here. The first is to
recognize all the flags for a given mapping Xi are set in Z. The second is
to optionally resize the arrays Z and D only if necessary based on the
mapping Xi. The third is to assign X to the cells mapped by Xi.
Right now I was thinking of initializing D and Z something like this:
Ds←(3 3) (4 4) (5 5)
D←Ds⍴¨⊂⍬
Z←Ds⍴¨0
Next, Let's say that I want to make a diagonal boolean matrix out of the
first and third matrices, but leave the second matrix alone. I could do
this manually:
{(1 ⍵⊃D)←1}¨(1 1) (2 2) (3 3)
...
But this is nasty and complex. Moreover, with a normal matrix I could just
do something like:
A[(1 1) (2 2) (3 3)]←1
However, I cannot do this using Pick (⊃).
Then, if I want to inconsiderately resize all arrays, I could do something
like this:
D[⊃¨Xi]←(⌈/¨¨1↓¨Xi)↑¨D[⊃¨Xi]
Or at least, that's the general idea. This leads to a format of Xi to
something like:
Xi←(((I ...) (I ...)) ...)
At least, if we were to use the standard ⌷ format for the inner indexes.
But obviously this combination of formats doesn't work well at all for Xi
or for doing indexed assignments, because I can't find a way to do the
equivalent of this:
D[1]
0 0 0
0 0 0
0 0 0
⎕←D[(1 ((1 3) 2))]←1
0 1 0
0 0 0
0 1 0
I wonder if someone here has some ideas about how this all might work? In
general, given that I am flexible on the whole thing, I want to be able to
do something like this:
D
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
D⊣D STORE ((1 ((1 1) (2 2) (3 3))) (2 (1,⍳3))) 1
1 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 1 0
0 0 1 0 0 0 0 1 0
I'd like to be able to be as flexible in specifying the indexes as I am
able to be normally with Index (⌷) and with Bracket indexing of various
forms.
--
Aaron W. Hsu |
arc...@sacrideo.us |
http://www.sacrideo.us
לֵ֤ב חֲכָמִים֙ בְּבֵ֣ית אֵ֔בֶל וְלֵ֥ב כְּסִילִ֖ים בְּבֵ֥ית שִׂמְחָֽה