File: lsTMatrix.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 (30 lines) | stat: -rw-r--r-- 925 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
#### Logical Sparse Symmetric Matrices in Triplet format

### contains = "lsparseMatrix"

setAs("lsTMatrix", "matrix",
      function(from) as(as(from, "lgTMatrix"), "matrix"))

setAs("lsTMatrix", "lgCMatrix", # for diag
      function(from) as(as(from, "lsCMatrix"), "lgCMatrix"))

setAs("lsTMatrix", "lgTMatrix",
      function(from) .Call(lsTMatrix_as_lgTMatrix, from))


if(FALSE) # should use  as(., "dMatrix")
setAs("lsTMatrix", "dsTMatrix",
      function(from)
      new("dsTMatrix", i = from@i, j = from@j, uplo = from@uplo,
	  x = as.double(from@x), # *not* just 1; from@x *can* have FALSE
	  Dim = from@Dim, Dimnames = from@Dimnames))

setAs("lsTMatrix", "lsyMatrix",
      function(from) .Call(lsTMatrix_as_lsyMatrix, from))


setMethod("t", "lsTMatrix",
	  function(x)
	  new("lsTMatrix", 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"))