Hello,

Why don't you keep it on the list? I'm Ccing R Help.
If you put print statements just before the any(),

print(ind.c)
print(ind.r)
print(ind.sgn)


you'll see that all values are FALSE. So the problem is _not_ with any(). You must look somewhere else on the function.


Hope this helps,

Rui Barradas
Em 17-11-2012 19:18, Haris Rhrlp escreveu:
i have this matrices
a<-matrix(c(1,1,1,1,-1,-1,-1,-1,-1,1,1,1),ncol=4,byrow=T)
a1<-matrix(c(-1,-1,-1,-1,1,1,1,1,-1,1,1,1),ncol=4,byrow=T)
a2<-matrix(c(1,1,1,1,-1,-1,-1,-1,1,1,1,1),ncol=4,byrow=T)
a3<-matrix(c(1,1,1,1,-1,-1,-1,-1,1,1,1,-1),ncol=4,byrow=T)
a4<-matrix(c(1,1,1,-1,-1,-1,-1,1,-1,1,1,-1),ncol=4,byrow=T)
a5<-matrix(c(1,1,1,-1,-1,-1,-1,1,1,-1,1,-1),ncol=4,byrow=T)
a6<-matrix(c(1,1,1,1,-1,-1,-1,-1,1,-1,1,1),ncol=4,byrow=T)
a7<-matrix(c(1,1,-1,-1,-1,-1,1,1,-1,1,-1,-1),ncol=4,byrow=T)

and this programme

isomorphic1 <- function (m1, m2) {
     combs.c <- combn(ncol(m1), 2)
     nc <- ncol(combs.c)
     ind.c <- vector("logical", nc)
     for (i in 1:nc) {
         m <- m1
         m[, combs.c[, i]] <- m[, rev(combs.c[, i])]
         ind.c[i] <- all(m == m2)
     }
     combs.r <- combn(nrow(m1), 2)
     nr <- ncol(combs.r)
     ind.r <- vector("logical", nr)
     for (i in 1:nr) {
         m <- m1
         m[combs.r[, i], ] <- m[rev(combs.r[, i]), ]
         ind.r[i] <- all(m == m2)
     }
     ind.sgn <- lapply(1:ncol(m1), combn, x = ncol(m1))
     ind.sgn <- unlist(lapply(ind.sgn, function (ind) {
         ncc <- ncol(ind)
         out <- vector("logical", ncc)
         for (l in 1:ncc) {
             m <- m1
             m[, ind[, l]] <- -m[, ind[, l]]
             out[l] <- all(m == m2)
         }
         out
     }))
     any(ind.c, ind.r, ind.sgn)
}


in the above matrices only a2 is trully false
all the others must be true

it cant check simultaneously the ind.c, ind.r ind.sgn
as a5 has ind.c and ind.sgn simultaneously TRUE
ind.c & ind.sgn are  False & false

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to