Dear R users, I have a problem i want to check some patrices and check them if they are identical when from the one i change the order of the rows (the first row goes third etc) or/and change the order of the columns or/and if i change the signs of the one or more columns isomorphic <- 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) } the programme works perfectly when it check the rows, columns and signs seperatly but it doesnt work when i have the combination from the rows, column and signs i have these example 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) only the a2 is False all the others must be True but a5 ( the combination) is actualy true but the programme shows that it false any suggestions will be welcome [[alternative HTML version deleted]]