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 1348, Mon Aug 7 09:05:00 2006 UTC revision 1349, Mon Aug 7 09:05:42 2006 UTC
# Line 349  Line 349 
349                       "s" = "sy",                       "s" = "sy",
350                       "g" = "ge")                       "g" = "ge")
351    
352  .Csparse.prefix <- function(ch) {  .sparse.prefixes <- c("d" = "t", ## map diagonal to triangular
353      switch(ch,                        "t" = "t",
354             "d" =, "t" = "tC",                        "s" = "s",
355             "s" = "sC",                        "g" = "g")
            "g" = "gC",  
            stop("invalid Matrix shape: ", ch))  
 }  
356    
357  ## Used, e.g. after subsetting: Try to use specific class -- if feasible :  ## Used, e.g. after subsetting: Try to use specific class -- if feasible :
358  as_dense <- function(x) {  as_dense <- function(x) {
# Line 363  Line 360 
360  }  }
361    
362  as_Csparse <- function(x) {  as_Csparse <- function(x) {
363      as(x, paste(.M.kind(x), .Csparse.prefix(.M.shape(x)), "Matrix", sep=''))      as(x, paste(.M.kind(x), .sparse.prefixes[.M.shape(x)], "CMatrix", sep=''))
364    }
365    as_Rsparse <- function(x) {
366        as(x, paste(.M.kind(x), .sparse.prefixes[.M.shape(x)], "RMatrix", sep=''))
367    }
368    as_Tsparse <- function(x) {
369        as(x, paste(.M.kind(x), .sparse.prefixes[.M.shape(x)], "TMatrix", sep=''))
370  }  }
371    
372  as_geClass <- function(x, cl) {  as_geClass <- function(x, cl) {
# Line 477  Line 480 
480          Dimnames = x@Dimnames, uplo = x@uplo, diag = "N")          Dimnames = x@Dimnames, uplo = x@uplo, diag = "N")
481  }  }
482    
483    ## FIXME: this should probably be dropped / replaced by as_Csparse
484  .as.dgC.Fun <- function(x, na.rm = FALSE, dims = 1) {  .as.dgC.Fun <- function(x, na.rm = FALSE, dims = 1) {
485      x <- as(x, "dgCMatrix")      x <- as(x, "dgCMatrix")
486      callGeneric()      callGeneric()
487  }  }
488    
489  .as.dgT.Fun <- function(x, na.rm = FALSE, dims = 1) {  .as.dgT.Fun <- function(x, na.rm = FALSE, dims = 1) {
490        ## used e.g. inside colSums() etc methods
491      x <- as(x, "dgTMatrix")      x <- as(x, "dgTMatrix")
492      callGeneric()      callGeneric()
493  }  }

Legend:
Removed from v.1348  
changed lines
  Added in v.1349

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