SCM

SCM Repository

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

Diff of /pkg/R/sparseMatrix.R

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

revision 1314, Mon Jul 10 15:23:48 2006 UTC revision 1315, Mon Jul 10 16:08:05 2006 UTC
# Line 195  Line 195 
195  {  {
196      stopifnot(is(object, "sparseMatrix"))      stopifnot(is(object, "sparseMatrix"))
197      m <- as(object, "matrix")      m <- as(object, "matrix")
198        logi <- is(object,"lsparseMatrix")
199        if(logi)
200            x <- array(character(length(m)), dim(m), dimnames=dimnames(m))
201        else {
202      x <- apply(m, 2, format)      x <- apply(m, 2, format)
203      if(is.null(dim(x))) {# e.g. in  1 x 1 case      if(is.null(dim(x))) {# e.g. in  1 x 1 case
204          dim(x) <- dim(m)          dim(x) <- dim(m)
205          dimnames(x) <- dimnames(m)          dimnames(x) <- dimnames(m)
206      }      }
207        }
208      x <- emptyColnames(x)      x <- emptyColnames(x)
209      if(is.logical(zero.print))      if(is.logical(zero.print))
210          zero.print <- if(zero.print) "0" else " "          zero.print <- if(zero.print) "0" else " "
211      ## FIXME: show only "structural" zeros as 'zero.print', not all of them..      if(logi) {
212      x[m == 0.] <- zero.print          x[!m] <- zero.print
     if(is(object,"lsparseMatrix"))  
213          x[m] <- "|"          x[m] <- "|"
214        } else { # non logical
215            ## show only "structural" zeros as 'zero.print', not all of them..
216            ## -> cannot use 'm'
217            iN0 <- 1:1 + encodeInd(non0ind(object), nr = nrow(x))
218            x[-iN0] <- zero.print
219        }
220      print(noquote(x))      print(noquote(x))
221      invisible(object)      invisible(object)
222  }  }
# Line 262  Line 272 
272            })            })
273    
274    
275  ## .as.dgT.Fun is in ./Tsparse.R  ## .as.dgT.Fun
276  setMethod("colSums",  signature(x = "sparseMatrix"), .as.dgT.Fun)  setMethod("colSums",  signature(x = "sparseMatrix"), .as.dgT.Fun)
277  setMethod("colMeans", signature(x = "sparseMatrix"), .as.dgT.Fun)  setMethod("colMeans", signature(x = "sparseMatrix"), .as.dgT.Fun)
278  ## .as.dgC.Fun is in ./Csparse.R  ## .as.dgC.Fun
279  setMethod("rowSums", signature(x = "sparseMatrix"), .as.dgC.Fun)  setMethod("rowSums", signature(x = "sparseMatrix"), .as.dgC.Fun)
280  setMethod("rowMeans", signature(x = "sparseMatrix"),.as.dgC.Fun)  setMethod("rowMeans", signature(x = "sparseMatrix"),.as.dgC.Fun)
281    

Legend:
Removed from v.1314  
changed lines
  Added in v.1315

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