Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Skip Cave
Testing Roger's rotational duplicate finder: ts=:6!:2 , 7!:2@] $x=.odo 8#8 16777216 8 ts 't0=.llr0 x' 37.0263 2.14749e9 ts 't1=.llr1 x' 26.6041 2.14749e9 ts 't3=.llr3 x' 34.1857 1.28849e10 ts 't2=.llr2 x' |out of memory: llr2 | (c*i.n){}."1/:~(c#i.n),.((n*c)$i.c) |."_1 c#y ts=:6!:2 , 7

Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Roger Hui
Partition the matrix by the smallest element, then work separately on each partition. On Tue, May 19, 2020 at 8:11 PM Skip Cave wrote: > Testing Roger's rotational duplicate finder: > > ts=:6!:2 , 7!:2@] > > $x=.odo 8#8 > > 16777216 8 > > ts 't0=.llr0 x' > > 37.0263 2.14749e9 > > ts 't1=.llr1 x

Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Skip Cave
Testing Roger's rotational duplicate finder: ts=:6!:2 , 7!:2@] $x=.odo 8#8 16777216 8 ts 't0=.llr0 x' 37.0263 2.14749e9 ts 't1=.llr1 x' 26.6041 2.14749e9 ts 't3=.llr3 x' 34.1857 1.28849e10 ts 't2=.llr2 x' |out of memory: llr2 | (c*i.n){}."1/:~(c#i.n),.((n*c)$i.c) |."_1 c#y ts=:6!:2 , 7

Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Roger Hui
I think in such cases you ought to do i.!.0~x first (as the write-up points out). Then you'd be working with small-range integers and the maximum element shouldn't cause a problem. Unless you are working with a huge x. In which case you have other problems. On Tue, May 19, 2020 at 6:32 PM Raul M

Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Raul Miller
Perhaps worth noting that the "radius limit" is calculable based on the type of the numbers in the argument. For integer values, on a 64 bit machine, radius*#y should not exceed 9223372036854775807 datatype 9223372036854775807 integer datatype 9223372036854775807+1 floating It gets a littl

Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Roger Hui
I understand and sympathize with the difficulties. I submit that in the APL Chat Forum post there is enough English description to make it understandable and helpful even if you don't understand every APL symbol. On Tue, May 19, 2020 at 10:01 AM Skip Cave wrote: > Roger, > > It has been many y

Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Skip Cave
Roger, It has been many years since I programmed in APL. My last APL work project was in 1976-77 designing character recognition algorithms on a Harris terminal (IBM selectric mechanisms) with an acoustic coupler, using University Computing Company's IBM Mainframe timesharing in Dallas Texas. When

Re: [Jprogramming] Finding rotational duplicates

2020-05-19 Thread Roger Hui
I have written a lengthier description of the solutions in the Dyalog APL Chat Forum. It is in APL rather than J notation, but may be helpful. The main thing to remember is that " (the rank operator) is ⍤ in Dyalog APL. On Sun, May 17, 2020

Re: [Jprogramming] Finding rotational duplicates

2020-05-17 Thread Skip Cave
Roger, The llr versions you provided are interesting and useful. I expect to learn much by analysing them. Skip Cave On Sun, May 17, 2020 at 3:09 PM Roger Hui wrote: > (I posted the following msg which appears not to be distributed. Not yet > in the archive, at least. Sorry if you receive t

Re: [Jprogramming] Finding rotational duplicates

2020-05-17 Thread Roger Hui
(I posted the following msg which appears not to be distributed. Not yet in the archive, at least. Sorry if you receive this more than once.) llr0=: {.@(/:~)@(i.@# |."0 1 ])"1 llr1=: {.@(/:~)@(([: I. ] = <./)|."0 1 ])"1 llr2=: 3 : 0 c=. {: $ y n=. # y (c*i.n) { }."1 /:~ (c#i.n) ,. ((n*c)$i.

Re: [Jprogramming] Finding rotational duplicates

2020-05-17 Thread Raul Miller
"lexicographically least" means "sorts first". B=: (#~ 0={."1) (i.20) |."0 1 ?20#2 B 0 1 1 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 0 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 0

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Skip Cave
Roger's phrase 'lexicographically least rotation' was new to me, so i looked it up in Wikipedia . That article described several methods for finding the "lexicographical minimum string rotation." I will try to understand Roger

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Roger Hui
Since the lexicographically least rotation necessarily begins with the least element of a row, llr=: {. @ (/:~) @ (([: I. ] = <./) |."0 1 ])"1 Less computation if the least element doesn't occur many times in a row. On Sat, May 16, 2020 at 10:59 PM Roger Hui wrote: > Find the lexicographically

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Roger Hui
Find the lexicographically least of all the rotations of each row. Not very efficient, but works. llr=: {.@(/:~)@(i.@# |."0 1 ])"1 $ odo 3#5 125 3 $ llr odo 3#5 125 3 $ ~. llr odo 3#5 45 3 On Sat, May 16, 2020 at 10:50 PM Skip Cave wrote: > The acid test is to find all the rotation

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread 'Bo Jacoby' via Programming
   (|.~i.&1@(= <./))"1 n 1 3 2 4 1 2 3 4 1 2 3 4 1 3 2 4 1 3 2 4 1 2 3 4 1 2 3 4 1 3 2 4 Well, that is everybody else's idea. Bo Den søndag den 17. maj 2020 03.21.43 CEST skrev Roger Hui : > I could be wrong. Right.  I was wrong. On Sat, May 16, 2020 at 6:18 PM Rau

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Skip Cave
The acid test is to find all the rotational duplicates of a full odometer sequence: *odo=:#:i.@(*/)* NB. Odometer verb * $n=.odo 3#5 * *125 3* *rd=:3 :'(y i."_1 <./"1 y)|."_1 y'* NB. Roger's rotational duplication verb *$rdn=.rd n* NB. Return all rows to key form. *125 3* * $rdn1=.~. rdn* NB

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Roger Hui
> I could be wrong. Right. I was wrong. On Sat, May 16, 2020 at 6:18 PM Raul Miller wrote: > For example: > >A=: 2 3 1 2 1,: 2 1 2 3 1 >2 1 |.("_1) A > 1 2 1 2 3 > 1 2 3 1 2 >2 4 |.("_1) A > 1 2 1 2 3 > 1 2 1 2 3 > > Thanks, > > -- > Raul > > On Sat, May 16, 2020 at 9:11 PM Roger

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Raul Miller
For example: A=: 2 3 1 2 1,: 2 1 2 3 1 2 1 |.("_1) A 1 2 1 2 3 1 2 3 1 2 2 4 |.("_1) A 1 2 1 2 3 1 2 1 2 3 Thanks, -- Raul On Sat, May 16, 2020 at 9:11 PM Roger Hui wrote: > > The question is, do you get a unique key (signature) if you rotate a row so > that the first occurrence of

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Roger Hui
The question is, do you get a unique key (signature) if you rotate a row so that the first occurrence of the minimum value is first? I thought the answer was yes after thinking about it for a minute. I could be wrong. On Sat, May 16, 2020 at 5:53 PM Raul Miller wrote: > A critical question he

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Raul Miller
A critical question here is whether the minimum value can appear more than once in each row, or whether the examples (where each value is has a unique appearance in each row) are adequately complex. Thanks, -- Raul On Sat, May 16, 2020 at 8:15 PM Roger Hui wrote: > > Hmm, you just want the key

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Skip Cave
Thanks Roger! That's exactly what I needed. The boxed solution is also useful in a couple of instances. Skip On Sat, May 16, 2020 at 7:15 PM Roger Hui wrote: > Hmm, you just want the keys: rotate each row so that the minimum item is > first. > >(n i."_1 <./"1 n)|."_1 n > 1 3 2 4 > 1 2 3 4

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Roger Hui
Hmm, you just want the keys: rotate each row so that the minimum item is first. (n i."_1 <./"1 n)|."_1 n 1 3 2 4 1 2 3 4 1 2 3 4 1 3 2 4 1 3 2 4 1 2 3 4 1 2 3 4 1 3 2 4 On Sat, May 16, 2020 at 5:11 PM Roger Hui wrote: >((n i."_1 <./"1 n)|."_1 n) ┌───┬───┐ > │2 4 1 3│2 3 4 1│ >

Re: [Jprogramming] Finding rotational duplicates

2020-05-16 Thread Roger Hui
((n i."_1 <./"1 n)|."_1 n) wrote: > I have run across this issue a few times in the past. > The following 8x4 array has several rows that are 'rotational duplicates'. > > ]n=.8 4$2 4 1 3 2 3 4 1 3 4 1 2 3 2 4 1 1 3 2 4 4 1 2 3 1 2 3 4 4 1 3 2 > > 2 4 1 3 > > 2 3 4 1 > > 3 4 1 2 > > 3 2 4 1 > >