Skip to content
Back to formatted view

Raw Message

Message-ID: <20120213223803.GA32301@cs.cas.cz>
Date: 2012-02-13T22:38:03Z
From: Petr Savicky
Subject: non-isomorphic sequences
In-Reply-To: <1329170691.50751.YahooMailNeo@web112505.mail.gq1.yahoo.com>

On Mon, Feb 13, 2012 at 02:04:51PM -0800, zheng wei wrote:
> Dear Petr,
> ?
> This is fantastic!
> ?
> I have one more question, when p=4, tt=4. We have 15 non-isomorphic sequences as you have generated. Among these 15, I selected?2 sequences. How do I recover all the members of the equivalent classes corresponding to these?2 sequences? For example, corresponding to the sequence of?1111, I would like to recover 1111,2222,3333,4444 from this sequence.

Dear Wei:

Try the following.

  getEquivalent <- function(a, tt)
  {
      b <- as.matrix(rev(expand.grid(rep(list(1:tt), times=max(a)))))
      ok <- apply(b, 1, function(x) length(unique(x))) == ncol(b)
      b <- b[ok, , drop=FALSE]
      dimnames(b) <- NULL
      t(apply(b, 1, function(x) x[a]))
  }

  getEquivalent(c(1, 1, 1, 1), 4)

       [,1] [,2] [,3] [,4]
  [1,]    1    1    1    1
  [2,]    2    2    2    2
  [3,]    3    3    3    3
  [4,]    4    4    4    4

  getEquivalent(c(1, 1, 1, 2), 4)

        [,1] [,2] [,3] [,4]
   [1,]    1    1    1    2
   [2,]    1    1    1    3
   [3,]    1    1    1    4
   [4,]    2    2    2    1
   [5,]    2    2    2    3
   [6,]    2    2    2    4
   [7,]    3    3    3    1
   [8,]    3    3    3    2
   [9,]    3    3    3    4
  [10,]    4    4    4    1
  [11,]    4    4    4    2
  [12,]    4    4    4    3

Hope this helps.

Petr.