SCM

SCM Repository

[matrix] View of /pkg/Matrix/R/lgCMatrix.R
ViewVC logotype

View of /pkg/Matrix/R/lgCMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2901 - (download) (annotate)
Tue Sep 10 10:45:25 2013 UTC (6 years ago) by mmaechler
File size: 1317 byte(s)
new  Csparse_to_vector() in C --> faster as(*, "vector") methods
#### Logical Sparse Matrices in Compressed column-oriented format

### contains = "lsparseMatrix"

## Can use CsparseMatrix methods for all of these

## setMethod("t", signature(x = "lgCMatrix"),
##           function(x) .Call(lgCMatrix_trans, x),
##           valueClass = "lgCMatrix")

## setMethod("diag", signature(x = "lgCMatrix"),
## 	  function(x, nrow, ncol) .Call(lgCMatrix_diag, x))


setAs("lgCMatrix", "dgCMatrix",
      function(from) new("dgCMatrix", i = from@i, p = from@p,
                         x = as.double(from@x),
                         Dim = from@Dim, Dimnames = from@Dimnames))

setAs("lgCMatrix", "lgTMatrix",
      function(from) new("lgTMatrix", i = from@i, x = from@x,
                         j = .Call(Matrix_expand_pointers, from@p),
                         Dim = from@Dim, Dimnames = from@Dimnames))

setAs("lgCMatrix", "lgeMatrix",
      function(from)
	  new("lgeMatrix", x = c(as(from, "matrix")), # is fast,
	      Dim = from@Dim, Dimnames = from@Dimnames))

setAs("lgCMatrix", "matrix", function(from) .Call(lgC_to_matrix, from))
## not this: .Call(Csparse_to_matrix, from)), since it goes via dense -> double precision


## TODO (maybe): write  matrix_to_lcsc()  in ../src/lgCMatrix.c
setAs("matrix", "lgCMatrix",
      function(from) as(as(from, "lgTMatrix"), "lgCMatrix"))

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