Your comment makes me think that I should expand on my thinking.
I was responding to neitzel's suggestion that "the offset for the
first data atom might or might not require some rounding up".
This is a reference to the fact that some C compilers will put a C
struct in memory in an order which is different from the declaration
order and/or with padding in the structure. But that only happens in
certain situations which are not relevant in the context of the J
implementation. I could go into this in more detail, but that's
probably best done in a different forum.
As for extended precision and boxed values, I think the best way to
explore them is to use 3!:1.
For example,
I.~:/(3!:1]1x),:3!:1]2x
80
Here, the byte which is different between the representation of 1x and
2x is the 80th byte. (I'm using a 64 bit implementation of J).
$3!:1]1x
88
11 8$a.i.3!:1]1x
227 0 0 0 0 0 0 0
64 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
40 0 0 0 0 0 0 0
227 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
In other words, the 1 in the last row here is that particular byte.
The first seven rows correspond to the labeled values from this line
of C:
typedef struct {I k,flag,m,t,c,n,r,s[1];}* A;
I forget what the next rows are, but I remember finding them earlier
and I felt satisfied then that it was fairly obvious (not necessarily
efficient, but obvious - and extended precision is not really about
efficiency). It's basically a slightly simplified version of the A
struct - an extended precision integer is essentially a list of
"digits" where the digits are expressed in some base which is
significantly larger than 10.
I hope this helps,
--
Raul
On Thu, Jun 20, 2013 at 5:55 PM, greg heil <[email protected]> wrote:
> i think i am going to have to punt on eXtended. Maybe even boxed if
> padding is a problem. That would be sad as i know of no other
> effective way for ragged arrays.
>
> greg
> ~krsnadas.org
>
> --
>
> from: Raul Miller <[email protected]>
> to: Programming forum <[email protected]>
> date: 20 June 2013 14:20
> subject: Re: [Jprogramming] calling jj.dll
>
> I do not think that you can find any examples of this.
>
>>The underlying mechanism only makes sense when mixing structure elements
>>which have different sizes.
>
>>Still, if you can find any examples, it would be great to hear about them.
>
> Thanks,
>
> --
> Raul
>
> --
>
> from: [email protected]
> to: [email protected]
> date: 20 June 2013 13:59
> subject: Re: [Jprogramming] calling jj.dll
>
> GREG> 2)Is there a formula for header size depending on rank?
> RAUL> So, expressed in C, it's (7+rank)*sizeof I
>
>>There may also be some padding after the s[] shape elements and before the
>>data values following the header in order to have the data values properly
>>aligned. (Think of "doubles" requiring 8-byte alignment, and having such
>>padding always for uniformity reasons.) This is platform-dependent.
>
> So, while Raul's
>
> (7+rank)*sizeof I
>
>>indeed covers all relevant header elements, the offset for the first data
>>atom might or might not require some rounding up.
>
> As all the London Tubers know: "Mind the gap!"
>
> Martin
>
> PS (aka Padding Space):
>
>>This padding space was occasionally an issue back when I made the J Unix
>>ports. Just very seldom, a test in the test suite would fail because two
>>arrays wouldn't match (-:) anymore -- when that padding area wasn't properly
>>initialized. Difficult to reproduce and debug, back then.
>
>>This is also what I *DON'T* like about the use 15!:0 for base functionalities
>>such as regexes or mmapped files: it pushes APIs which are portable at the C
>>source level into the J level where the code working across many platforms
>>gets very, very messy. (Good luck, Greg!)
>
> --
>
> from: Raul Miller <[email protected]>
> to: Programming forum <[email protected]>
> date: 19 June 2013 14:15
> subject: Re: [Jprogramming] calling jj.dll
>
> On Tue, Jun 18, 2013 at 9:07 AM, greg heil <[email protected]> wrote:
>> 1)Is there a citation for the meaning of x vs i?
>
> http://www.jsoftware.com/help/user/call_procedure.htm
>
>> 2)Is there a formula for header size depending on rank?
>
> https://github.com/openj/core/blob/master/jtype.h#L41 says:
> typedef struct {I k,flag,m,t,c,n,r,s[1];}* A;
>
> and
> +/','='k,flag,m,t,c,n,r,s'
> 7
>
> So, expressed in C, it's (7+rank)*sizeof I
>
>>(Because counting commas ignores the s, which is the shape of the array. The
>>number of elements in the shape is the rank of the array.)
>
>>And, of course, sizeof I is 4 on a 32 bit machine and 8 on a 64 bit machine.
>
> FYI,
> Raul
>
>
>
>
>
>
>
>> 1)Is there a citation for the meaning of x vs i?
>
> http://www.jsoftware.com/help/user/call_procedure.htm
>
>> 2)Is there a formula for header size depending on rank?
>
> https://github.com/openj/core/blob/master/jtype.h#L41 says:
> typedef struct {I k,flag,m,t,c,n,r,s[1];}* A;
>
> and
> +/','='k,flag,m,t,c,n,r,s'
> 7
>
> So, expressed in C, it's (7+rank)*sizeof I
>
> (Because counting commas ignores the s, which is the shape of the
> array. The number of elements in the shape is the rank of the array.)
>
> And, of course, sizeof I is 4 on a 32 bit machine and 8 on a 64 bit machine.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm