It's unusual in J to need the full odometer array. Are you sure that your problem requires it?

Henry rich

On 4/4/2015 5:48 PM, Sergeif wrote:
Thanks! It's 10x faster than my code but 10x slower than odometer function.
Anyway I lernt the catalogue verb from this.

On Sat, Apr 4, 2015 at 11:21 PM, R.E. Boss <[email protected]> wrote:


    >,{<@i."0[2 3 4
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
1 1 2
1 1 3
1 2 0
1 2 1
1 2 2
1 2 3

R.E. Boss


-----Original Message-----
From: [email protected] [mailto:programming-
[email protected]] On Behalf Of Nollaig MacKenzie
Sent: zaterdag 4 april 2015 23:16
To: [email protected]
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
       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
       1 1 2
       1 1 3

       1 2 0
       1 2 1
       1 2 2
       1 2 3
          indmak
        (#: i.)@$


On 2015.04.04 23:09:58, you,
  the extraordinary Sergeif, spake thus:

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 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).
----------------------------------------------------------------------
For information about J forums see
http://www.jsoftware.com/forums.htm

--
Nollaig MacKenzie
http://www.yorku.ca/nollaig
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

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

Reply via email to