Intresting! I have learned much more from this topic than I have in the
last year with J.
On Sun, Apr 5, 2015 at 8:12 PM, David Lambert wrote:
> http://www.jsoftware.com/jwiki/Essays/Odometer
>
> Fastest of these is the sparse solution
> (4 $. $.)@($&1)
>
> To fill your table assuming you've use
>
> >>> On Sat, Apr 4, 2015 at 11:21 PM, R.E. Boss
> wrote:
> >>>
> >>>
> >>>> >,{<@i."0[2 3 4
> >>>> 0 0 0
> >>>> 0 0 1
> >>>> 0 0 2
> >>>> 0 0 3
> >>>>
http://www.jsoftware.com/jwiki/Essays/Odometer
Fastest of these is the sparse solution
(4 $. $.)@($&1)
To fill your table assuming you've used c notation:
odometer =: (4 $. $.)@($&1)
i=:{.
j=:1&{
k=:{:
($ ([: ((i*j) - (i*k) - (j*k))"1 odometer))2 3 4
0 0 0 0
0 1 2 3
0 2 4
>>>> 0 1 0
>>>> 0 1 1
>>>> 0 1 2
>>>> 0 1 3
>>>> 0 2 0
>>>> 0 2 1
>>>> 0 2 2
>>>> 0 2 3
>>>> 1 0 0
>>>> 1 0 1
>>>> 1 0 2
>>>> 1 0 3
>>>> 1 1 0
>>
2
>>> 0 1 3
>>> 0 2 0
>>> 0 2 1
>>> 0 2 2
>>> 0 2 3
>>> 1 0 0
>>> 1 0 1
>>> 1 0 2
>>> 1 0 3
>>> 1 1 0
>>> 1 1 1
>>> 1 1 2
>>> 1 1 3
>>> 1 2 0
>>> 1 2 1
>>>
Lots of replies already to your main question.
As for
"Another question is how to fill the table with values depending
on indexes of cell? For example, F[i,j,k] = (i * j) - (i * k) + (j * k) ":
As Henry says, you might not in practice need the whole index array;
you also might not need to pop
m [mailto:programming-
boun...@forums.jsoftware.com] On Behalf Of Nollaig MacKenzie
Sent: zaterdag 4 april 2015 23:16
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] indexing a table
Is something like this what you have in mind?
m=. i. 2 3 4
indmak m
0 0 0
0 0 1
oftware.com [mailto:programming-
> > boun...@forums.jsoftware.com] On Behalf Of Nollaig MacKenzie
> > Sent: zaterdag 4 april 2015 23:16
> > To: programm...@jsoftware.com
> > Subject: Re: [Jprogramming] indexing a table
> >
> > Is something like this what you ha
Nice! I missed a #: verb. Thanks a lot.
On Sat, Apr 4, 2015 at 11:20 PM, Henry Rich wrote:
> Standard idiom (we call it the odometer function):
>
> ind3d =: (#: i.@(*/))
>
> It's very fast.
>
> Henry Rich
>
> On 4/4/2015 5:09 PM, Sergeif wrote:
>
>> Hi.
>>
>> How can someone create list of index
ogramming-
> boun...@forums.jsoftware.com] On Behalf Of Nollaig MacKenzie
> Sent: zaterdag 4 april 2015 23:16
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] indexing a table
>
> Is something like this what you have in mind?
>
>m=. i. 2 3 4
> indmak m
>
Standard idiom (we call it the odometer function):
ind3d =: (#: i.@(*/))
It's very fast.
Henry Rich
On 4/4/2015 5:09 PM, Sergeif wrote:
Hi.
How can someone create list of indexes of 3d table (N x M x K)?
I have written this simple code:
ind3d =: 3 : 0
'n m k' =. y
p0 =. k&|
p1 =. (m&|)@:<.@
Is something like this what you have in mind?
m=. i. 2 3 4
indmak m
0 0 0
0 0 1
0 0 2
0 0 3
0 1 0
0 1 1
0 1 2
0 1 3
0 2 0
0 2 1
0 2 2
0 2 3
1 0 0
1 0 1
1 0 2
1 0 3
1 1 0
1 1 1
Hi.
How can someone create list of indexes of 3d table (N x M x K)?
I have written this simple code:
ind3d =: 3 : 0
'n m k' =. y
p0 =. k&|
p1 =. (m&|)@:<.@:(%&k)
p2 =. <.@:(%&(m*k))
(p2 , p1 , p0)"0 (i. (n*m*k))
)
but it's very very slow. Does any tacit solution for this problem exist?
Another
13 matches
Mail list logo