If B really are "all possible permutations" then it is better to convert A from a base (m_1,m_2,...,m_n) number into a single integer, and then compare integers. e.g.
] a=: _2]\ 2 1 2 2 1 3 2 1 2 1 1 2 1 1 2 1 2 2 1 3 2 1 2 1 1 2 1 1 (2 3 #. a-1)=/i.*/2 3 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 Unless */m_1,m_2,...,m_n is small, the integer-value representation of A is much more efficient than the boolean matrix representation. ----- Original Message ----- From: Christopher Hansen <[EMAIL PROTECTED]> Date: Thursday, September 13, 2007 17:14 Subject: [Jprogramming] a simple problem? To: [email protected] > Okay, bear with me - I'm 2 days into J programming... > > I have a (large) dataset, A, which contains n columns, the > first a number > in {1,2,...,m_1}, the > second a number in {1,2,...,m_2}, and so on. I then have a > second dataset, > B, which contains > all the possible permutations. As a simple example, set > n=2, m_1=2 and > m_2=3. Then B is > > 1 1 > 1 2 > 1 3 > 2 1 > 2 2 > 2 3 > > Let's also say that A is > > 2 1 > 2 2 > 1 3 > 2 1 > 2 1 > 1 2 > 1 1 > > (but, again, I will typically have many more rows than this for > A). I was > hoping I could do > something like A = tr(B), or: > > 2 1 = (1 1) (1 2) (1 3) (2 1) (2 2) (2 3) > 2 2 = (1 1) (1 2) (1 3) (2 1) (2 2) (2 3) > 1 3 = (1 1) (1 2) (1 3) (2 1) (2 2) (2 3) > 2 1 = (1 1) (1 2) (1 3) (2 1) (2 2) (2 3) > 2 1 = (1 1) (1 2) (1 3) (2 1) (2 2) (2 3) > 1 2 = (1 1) (1 2) (1 3) (2 1) (2 2) (2 3) > 1 1 = (1 1) (1 2) (1 3) (2 1) (2 2) (2 3) > > which would give: > > 0 0 0 1 0 0 > 0 0 0 0 1 0 > 0 0 1 0 0 0 > 0 0 0 1 0 0 > 0 0 0 1 0 0 > 0 1 0 0 0 0 > 1 0 0 0 0 0 > > I have tried several approaches, but can't quite get > there. Any suggestions > would be much > appreciated... ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
