On Wed, Aug 21, 2019 at 2:08 AM Nollaig MacKenzie <[email protected]> wrote: > > And, here's a test to see if an n-dimensional truth table is degenerate: > > degenerate=: 1 e. (1 ]\. i.@#@$) -:/@|: ] > > I will have to puzzle out 'degenerate' - it seems faster than > the brute force routine I use.
An array is degenerate if there's some axis which (if it were the leading axis) has identical elements |: is a routine which we can use to rearrange the axes of an array. |: moves the numbered axes to the end of the dimension list, which if you list all but one axis, the omitted one will be come the leading axis. 1 ].\ list generates copies of the list with one element removed from each copy. So... I can generate a list of axis numbers, make copies of it with one element removed from each, and use each of those to transpose the original array. After each transpose, I can use -:/ to test if the [new] leading items are identical. > A quick way to get the dual of some N-axis array is: > > nudu=: $ $ -.@:|.@, > > nudu 2 2$0 0 0 1 (and) > > 0 1 > 1 1 (or) Hmm... Ok, I think I see this -- it's https://en.wikipedia.org/wiki/De_Morgan%27s_laws#Generalising_De_Morgan_duality -- and the inverting the logical arguments corresponds to reversing their position in the truth table. So: dual=: $ $ -.@|.@, isSelfDual=: -: dual (Which is basically what you said, here, but, ... I guess I'm not sure what 'nudu' signified.) Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
