Raul wrote:
> After chasing down some of the references from the responses to your
> question, I noticed this thread in comp.lang.c:
> https://groups.google.com/forum/#!topic/comp.lang.c/Z0mycsYvPyI/discussion

I’m not quite sure how you found that comp.lang.c thread, but the ideas 
presented there  were elaborated on in another SO thread (whose formatting and 
content I find make it easier to grasp the author’s suggestion):

http://stackoverflow.com/questions/30409991/use-a-dope-vector-to-access-arbitrary-axial-slices-of-a-multidimensional-array/30409992#30409992

> But I do not think that that "weighting vector" is a good idea. On
> modern chip architectures, the occasional multiply is free, or almost
> free, and the cost of maintaining the premultiplied weighting vector
> would be noticeable.


I don’t know enough to comment on the wisdom of using the weighting vector vs. 
doing the multiplications on the fly.  

Sounds to me like the trade-off is carrying another (#$y) integers around for 
every single array vs. calculating */\.i.#$y every time we want to do an index. 
 This is the classic time-space trade-off of CS.

On a separate note, I’m still struggling with figuring out the memory layout of 
V arrays.  

Here’s where I am right now. When I memr the words starting at the memory 
address returned by 15!:14, I see:

+-+-----+-------------------+
| |k    |56                 | // # bytes to payload
| |-----+-------------------+
| |flag |0                  | // flags
| |-----+-------------------+
| |m    |184                | // max # bytes in ravel
| |-----+-------------------+
|A|t    |262144             | // type = VERB
| |-----+-------------------+
| |c    |1                  | // reference count
| |-----+-------------------+
| |n    |1                  | // # elements in ravel
| |-----+-------------------+
| |r    |0                  | // rank
+-+-----+-------------------+
| |f1   |4725981456         | // monad
| |-----+-------------------+
| |f2   |4725981488         | // dyad
| |-----+-------------------+
| |name?|140205359197328    | // ptr somewhere: name?
| |-----+-------------------+
| |f    |0                  | // for operators
| |-----+-------------------+
| |g    |0                  | // "
| |-----+-------------------+
|V|h    |0                  | // "
| |-----+-------------------+
| |mr   |9223372036854775807| // monadic rank = _
| |-----+-------------------+
| |lr   |9223372036854775807| // left dyadic rank = _
| |-----+-------------------+
| |rr   |9223372036854775807| // right dyadic rank = _
| |-----+-------------------+
| |fdep |0                  | // function depth
| |-----+-------------------+
| |id   |126                | // identifier char = ~
+-+-----+-------------------+

But note this is slightly out of sync with the typedef in the J source. Where I 
have

     f1, f2, name?, f, g, h,       mr, ...

the source has:

     f1, f2,        f, g, h, flag, mr, ...

That is, I have a word *preceding* f,g,h, which looks like a pointer, but J’s 
source has a word *following* f,g,h, which should just be 64 bits representing 
various flags.

And, unfortunately, it’s those very 64 bits I’m interested in. 

-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to