File: dsTMatrix.R

package info (click to toggle)
rmatrix 1.3-2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,024 kB
  • sloc: ansic: 42,435; makefile: 330; sh: 180
file content (36 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
### Coercion and Methods for Symmetric Triplet Matrices

## Now in ./Tsparse.R
## setAs("dsTMatrix", "dsCMatrix",
##       function(from) .Call(Tsparse_to_Csparse, from, FALSE))

setAs("dsTMatrix", "dgTMatrix",
      function(from) .Call(dsTMatrix_as_dgTMatrix, from))

setAs("dsTMatrix", "lsTMatrix",
      function(from) new("lsTMatrix", i = from@i, j = from@j, uplo = from@uplo,
                         Dim = from@Dim, Dimnames = from@Dimnames))


## Conversion <--> dense storage is via dsyMatrix :
setAs("dsTMatrix", "dsyMatrix",
      function(from) .Call(dsTMatrix_as_dsyMatrix, from))

setAs("dsTMatrix", "dgeMatrix",
      function(from) as(as(from, "dsyMatrix"), "dgeMatrix"))
setAs("dsTMatrix", "matrix",
      function(from) as(as(from, "dsyMatrix"), "matrix"))

to_dsT <- function(from) as(as(from, "dsyMatrix"), "dsTMatrix")
setAs("dgeMatrix", "dsTMatrix", to_dsT)
setAs("matrix",    "dsTMatrix", to_dsT)

setMethod("t", "dsTMatrix",
	  function(x)
	  new("dsTMatrix", Dim = x@Dim, Dimnames = x@Dimnames[2:1],
	      i = x@j, j = x@i, x = x@x,
	      uplo = if (x@uplo == "U") "L" else "U"))


## setMethod("writeHB", signature(obj = "dsTMatrix"),
##           function(obj, file, ...) callGeneric(as(obj, "CsparseMatrix"), file, ...))