Hmm.. and playing with this idea shows that I'm not on quite on the
right track for the n-2 case.

   +/@, (i.3)=  -~/~^:2 i.3
18
   #3 parMD 5
25

I can get away with bits for the n-1 case, but I need to track two
independent free positions for the n-2 case.

-- 
Raul

On Thu, Nov 23, 2017 at 5:36 AM, 'Mike Day' via Programming
<[email protected]> wrote:
> It's pretty efficient though.
>
> Here's the result of a crude 13 : tacitisation,  resulting from replacing
> all (i.x) by y, and assuming the single argument is n :
>     RDM1 =: (([: |. >:/~) #&(,/) ] + (1 j. ] =/ -~/~) #"1"_1 -~/~ ) @: i. @
> <:
>
>     |: RDM1 4
> 0 0 0 0 0 0
> 0 1 1 1 1 1
> 1 0 2 1 2 2
> 2 2 0 2 1 2
>
>    ts'RDM1 10'
> 0.000420082 216064
>    ts'rgfMD/9 10'
> 0.00145139 27264
>
> The main overhead in mine for k=n-1 appears to be in the
> makeinsert routine,  even with a somewhat more efficient
> use of it than in the listing I posted yesterday.I might
> special-case it...
>
> Thanks for using 1j1 in the left arg of # - if I'd ever seen
> that, I'd certainly forgotten it!  V useful.
>
> Perhaps best to leave k=3, n-2, etc, to the existing codes.
>
> I phorgot phumbs... phrom my laptop,
>
> Mike
>
>
>
> On 23/11/2017 09:59, Raul Miller wrote:
>>
>> Well.. hmm...
>>
>> Here's the heart of that k=n-1 expression:
>>
>>     (i.x)=/-~/~i.x)
>>
>> For example:
>>     (i.4)=/-~/~i.4
>> 1 0 0 0
>> 0 1 0 0
>> 0 0 1 0
>> 0 0 0 1
>>
>> 0 1 0 0
>> 0 0 1 0
>> 0 0 0 1
>> 0 0 0 0
>>
>> 0 0 1 0
>> 0 0 0 1
>> 0 0 0 0
>> 0 0 0 0
>>
>> 0 0 0 1
>> 0 0 0 0
>> 0 0 0 0
>> 0 0 0 0
>>
>> (As you can see, it's not incredibly efficient. It might make sense to
>> transform one of those dimensions into index values to gain an order
>> of magnitude in compactness. You do not have to worry much about index
>> values all 0 rows because those get compressed out later. But the
>> problem you would have to solve is: what do you replace the rightmost
>> # operation with, when working with indices? It will probably be
>> something like an index and ravel and then another transformation to
>> get the partition control list. On the positive side, this should
>> eliminate the need to subtrace/add the rows - which is how I am
>> inserting non-zero values into the final rows with that # operation.)
>>
>> Anyways...
>>
>> In principle you could use a similar expression with a rank-4 bit
>> array which a triangular plane slicing it in a similar fashion (or,
>> ok, maybe map that to a rank 3 array of indices). But of course, you
>> lose an additional order of magnitude in efficiency from the
>> additional array rank - though sparse arrays might help here,
>> depending on how the expressions work. But I've not thought up any
>> good expressions for constructing that array.
>>
>> Thanks,
>>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
> ----------------------------------------------------------------------
> 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