Sorry, I'd overlooked the summation over p:@I. I'd thought you were sorting the vectors, which is likely slower. M
Sent from my iPad > On 19 Jul 2023, at 02:42, Raul Miller <rauldmil...@gmail.com> wrote: > > Cannon has two repeats (^:2 rather than ^2). I'm not sure why, but > that approach seemed faster than arranging the trim and rtrim so that > only one pass was needed. > > As for p: that's so that the summation was able to sufficiently > distinguish different cube positions. > > I hope this makes sense, > > -- > Raul > >> On Tue, Jul 18, 2023 at 6:22 PM 'Mike Day' via Programming >> <programm...@jsoftware.com> wrote: >> >> A couple of qs re canon: >> why power 2? >> why p:? Isn't the I. sufficient? >> >> Cheers, >> >> Mike >> >> Sent from my iPad >> >>>> On 18 Jul 2023, at 22:14, Raul Miller <rauldmil...@gmail.com> wrote: >>> >>> One thing I was considering was categorizing shapes by their symmetry >>> (#@~.@rotall"3) and testing fewer possibilities for shapes with higher >>> symmetry. (because it's less effort to test the symmetry of one shape >>> than to canonicalize all potential downstream shapes). But I hadn't >>> developed that thought. >>> >>> -- >>> Raul >>> >>>> On Tue, Jul 18, 2023 at 2:12 PM 'Michael Day' via Programming >>>> <programm...@jsoftware.com> wrote: >>>> >>>> My not particularly small laptop manages to do that task in 19sec! >>>> >>>> Running jpm for extendall ^: (i.7) - taking ca 2.5 sec on this m/c - >>>> seems to reveal >>>> 0.08 sec for ~70500 reps in rotx, >>>> 0.26 - ~280000 in roty, >>>> 0.33, ~320000 in rotz >>>> >>>> I haven't looked deeply into the rots (!) - perhaps you could do something >>>> otherthan use powers up to 3 . >>>> >>>> The representation is nice & concise. Wikipedia mentions dual graphs, >>>> with cubes as nodes and face-face adjacency as links, but afaics, this >>>> loses the 3rd dimension, even the 2nd in some cases; eg the V-tricube >>>> is identical to the straight-3 polyomino in this rep. Arthur O'Dwyer >>>> @ quuxplusone.github.io, subject polycube snakes & ouroboroi >>>> uses srd .. as straight, right, down etc for the sub-set of singly >>>> connected >>>> (I think) pc's. >>>> >>>> All for now - got to go out, >>>> >>>> Mike >>>> >>>>> On 15/07/2023 22:03, Raul Miller wrote: >>>>> https://en.wikipedia.org/wiki/Polycube >>>>> >>>>> Today, I've been playing with polycubes (which are polyhedrons formed >>>>> from adjacent cubes). >>>>> >>>>> This requires both a representation -- a rank 3 bit array works >>>>> nicely, and a mechanism for working with cubic symmetry. For that, I >>>>> went with: >>>>> >>>>> rotx=: |."2@(2 1&|:) NB. rotate in the yz plane about the x axis >>>>> roty=: |.@(1 0 2&|:) NB. rotate in the xz plane about the y axis >>>>> rotz=: |.@(2 1 0&|:) NB. rotate in the xy plane about the z axis >>>>> >>>>> rotall=: {{ >>>>> 'X Y Z'=. y >>>>> rotx^:X roty^:Y rotz^:Z x >>>>> }}"3 1&(4 4 4#:(i.20),24+i.4) >>>>> >>>>> Here, rotall gives all 24 rotations of cubic symmetry for a given >>>>> collection of 3d cubes represented by a bit array. >>>>> >>>>> I decided to use a brute force mechanism to generate polycubes. In >>>>> other words, pad the array representation and add a single cube in >>>>> each of the locations adjacent to an existing cube: >>>>> >>>>> extend=: {{ >>>>> Y=. (-2+$y){.(1+$y){.y >>>>> new=. ($#:I.@,)Y < (_1&|. +. 1&|. +. 1&|."2 +. _1&|."2 +. 1&|."1 +. >>>>> _1&|."1) Y >>>>> ~.new {{canon 1 (,:x)} y}}"1 3 Y >>>>> }} >>>>> >>>>> Here, Y is the y argument with an extra 0 of padding in all >>>>> directions. And 'new' is the list of indices of empty locations >>>>> adjacent to cube locations. >>>>> >>>>> I also need a verb (canon) to reduce these generated polycubes to >>>>> canonical form. A lot of this is removing unnecessary rows, columns >>>>> and planes of zeros. The rest of it is picking arbitrarily (but >>>>> consistently) from the 24 possible symmetric rotations: >>>>> >>>>> offset=: {{ 1 i.~ +./+./"2 x |: *y }} >>>>> trim=: {{ (0 offset y)}."3 (1 offset y)}."2 (2 offset y)}."1 y }} >>>>> rtrim=: trim&.|.&.:(|."2)&.:(|."1) >>>>> >>>>> canon=: {{ rtrim {. (/: +/@p:@I.@,"3) rotall trim y }}^:2 >>>>> >>>>> Finally, I want to work with all polycubes of a specific order, and to >>>>> get larger batch I can use; >>>>> >>>>> extendall=: {{ ~.;<@extend"3 y }} >>>>> >>>>> And, testing, this works: >>>>> >>>>> #@> extendall&.>^:(i.8)<1 1 1 1$1 >>>>> 1 1 2 8 29 166 1023 6922 >>>>> >>>>> But, this is slow -- since I'm brute forcing all possibilities then >>>>> discarding duplicates, I need almost seven seconds on the little >>>>> laptop I'm currently using, to generate the above sequence. >>>>> >>>>> (Also, for visualization of individual polycubes, >>>>> https://code.jsoftware.com/wiki/Scripts/Plot_3D works passibly well.) >>>>> >>>>> Does anyone here have the geometric insight to improve on this approach? >>>>> >>>>> Thanks, >>>>> >>>> >>>> ---------------------------------------------------------------------- >>>> 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 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm