File: ntCMatrix.R

package info (click to toggle)
rmatrix 0.999375-43-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,068 kB
  • ctags: 2,395
  • sloc: ansic: 37,941; makefile: 216; sh: 128
file content (44 lines) | stat: -rw-r--r-- 1,523 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
43
44
#### Logical Sparse Triangular Matrices in Compressed column-oriented format

setAs("ntCMatrix", "matrix",
      function(from) as(as(from, "denseMatrix"), "matrix"))
setAs("matrix", "ntCMatrix",
      function(from) as(as(from, "dtCMatrix"), "ntCMatrix"))

setAs("ntCMatrix", "TsparseMatrix",
      function(from) .Call(Csparse_to_Tsparse, from, TRUE))

setAs("ntCMatrix", "ngCMatrix",
      function(from) copyClass(diagU2N(from), "ngCMatrix"))


.ntC2d <- function(from)
    new("dtCMatrix", i = from@i, p = from@p,
	x = rep.int(1, length(from@i)), uplo = from@uplo,
	diag = from@diag, Dim = from@Dim, Dimnames = from@Dimnames)

.ntC2l <- function(from)
    new("ltCMatrix", i = from@i, p = from@p,
	x = rep.int(TRUE, length(from@i)), uplo = from@uplo,
	diag = from@diag, Dim = from@Dim, Dimnames = from@Dimnames)

setAs("ntCMatrix", "dMatrix", .ntC2d)# < instead of "dtCMatrix"
setAs("ntCMatrix", "dsparseMatrix", .ntC2d)
setAs("ntCMatrix", "dtCMatrix", .ntC2d)

setAs("ntCMatrix", "lMatrix", .ntC2l)
setAs("ntCMatrix", "lsparseMatrix", .ntC2l)
setAs("ntCMatrix", "ltCMatrix", .ntC2l)

rm(.ntC2d,.ntC2l) # don't even keep "hidden"

setAs("ngCMatrix", "ntCMatrix", # to triangular, needed for triu,..
      function(from) as(as(as(from, "TsparseMatrix"),
                           "ntTMatrix"), "ntCMatrix"))

## setAs("ntCMatrix", "generalMatrix",
##       function(from) ......)

## setMethod("t", signature(x = "ntCMatrix"),
##           function(x) .Call(ntCMatrix_trans, x),
##           valueClass = "ntCMatrix")