SCM

SCM Repository

[matrix] Diff of /pkg/R/Auxiliaries.R
ViewVC logotype

Diff of /pkg/R/Auxiliaries.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1318, Mon Jul 17 13:06:55 2006 UTC revision 1319, Mon Jul 17 13:08:04 2006 UTC
# Line 146  Line 146 
146      stopifnot(is(x, "sparseMatrix"))      stopifnot(is(x, "sparseMatrix"))
147      ## return a 2-column (i,j) matrix of      ## return a 2-column (i,j) matrix of
148      ## 0-based indices of non-zero entries  :      ## 0-based indices of non-zero entries  :
149      if(is(x, "TsparseMatrix"))      non0.i <- function(M) {
150          return(unique(cbind(x@i,x@j)))          if(is(M, "TsparseMatrix"))
151      if(is(x, "pMatrix"))              return(unique(cbind(M@i,M@j)))
152          return(cbind(seq(length=nrow(x)), x@perm) - 1:1)          if(is(M, "pMatrix"))
153                return(cbind(seq(length=nrow(M)), M@perm) - 1:1)
154      ## else:      ## else:
155      isC <- any("i" == slotNames(x))# is Csparse (not Rsparse)          isC <- any("i" == slotNames(M)) # is Csparse (not Rsparse)
156      .Call(compressed_non_0_ij, x, isC)          .Call(compressed_non_0_ij, M, isC)
157        }
158    
159        if(is(x, "symmetricMatrix")) { # also get "other" triangle
160            ij <- non0.i(x)
161            notdiag <- ij[,1] != ij[,2]# but not the diagonals again
162            rbind(ij, ij[notdiag, 2:1])
163        }
164        else
165            non0.i(x)
166  }  }
167    
168  ## nr= nrow: since  i in {0,1,.., nrow-1}  these are 1:1 "decimal" encodings:  ## nr= nrow: since  i in {0,1,.., nrow-1}  these are 1:1 "decimal" encodings:

Legend:
Removed from v.1318  
changed lines
  Added in v.1319

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge