[Jprogramming] Comaring Arrays
Jon Hough
jghough at outlook.com
Thu Jul 10 12:16:37 UTC 2014
I away from my computer at the moment. When I get back I will show you my code.
The gist is I am making a simple permutation group theory script(i am not talking about simple groups, i mean a simple script).
Anyway, what I have so far is trying to conjugate a group with itself, so i can nub out the resulting duplicates and get all the conjugacy classes of the group.
--- Original Message ---
From: "Dan Bron" <j at bron.us>
Sent: July 10, 2014 8:38 PM
To: programming at jsoftware.com
Subject: Re: [Jprogramming] Comaring Arrays
Good point. We could fix this up by asking an additional question: are the items of A unique? There's a million ways to ask that, but maybe we're in a cutesy mood today:
e. *./@:*. ~:@:]
Though with the ~:, I'm not sure this would have any performance advantage over sorting. Maybe we should go back to i. :
#@:] (e. < *./@:~:@:]) i.
That is, look up A in B and tell me whether all elements are unique and that there are no missing elements ((#A) e. A i. B).
-Dan
Please excuse typos; sent from a phone.
> On Jul 10, 2014, at 6:48 AM, Ben Gorte - CITG <B.G.H.Gorte at tudelft.nl> wrote:
>
> Now we should ask Jon what he wants in this case:
>
> ]A=.3 2$1 1 1 2 1 1
> 1 1
> 1 2
> 1 1
> ]B=.3 2$1 2 1 2 1 1
> 1 2
> 1 2
> 1 1
>
> Should the result be:
> A *./@:e. B
> 1
> or does he prefer:
> (/:~A)-:/:~B
> 0
> ?
>
> (I agree the first looks quicker)
>
> Ben
>
> _
> _______________________________________
> From: programming-bounces at forums.jsoftware.com [programming-bounces at forums.jsoftware.com] on behalf of Dan Bron [j at bron.us]
> Sent: Thursday, July 10, 2014 12:33
> To: programming at jsoftware.com
> Subject: Re: [Jprogramming] Comaring Arrays
>
> Sorting might be overkill (and/or a little expensive) for this situation.
>
> If A and B are the same shape (and they'd better be, or A is definitely not a permutation of B), then you really only need to know if all the items (rows) of A are also items (rows) of B.
>
> So let's just ask that:
>
> A e. B
> 1 1 1 1
> A *./@:e. B
> 1
>
> Now, if we needed slightly more information (and we're willing to pay for it), in particular, exactly how A is permuted from B, we could use i. instead of e. :
>
>
> A i. B
> 2 0 1 3
>
> And from here, we can figure out exactly how far Jon would have had to go in his quest to check every possible permutation:
>
> A A.@:i. B
> 12
> A C.@:i. B
> +-----+-+
> |2 1 0|3|
> +-----+-+
>
> Looks like about halfway ( (!#A)%2 ) . Not surprising.
>
> -Dan
>
> Please excuse typos; sent from a phone.
>
>> On Jul 10, 2014, at 4:17 AM, Ben Gorte - CITG <B.G.H.Gorte at tudelft.nl> wrote:
>>
>> B=:4 4$2 3 0 1 3 2 1 0 1 0 3 2 0 0 0 0
> ----------------------------------------------------------------------
> 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
More information about the Programming
mailing list