SCM

SCM Repository

[matrix] Diff of /pkg/R/dgTMatrix.R
ViewVC logotype

Diff of /pkg/R/dgTMatrix.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1237, Thu Mar 30 15:23:47 2006 UTC revision 1238, Thu Mar 30 19:56:09 2006 UTC
# Line 18  Line 18 
18            if (!isSymmetric(from))            if (!isSymmetric(from))
19                stop("cannot coerce non-symmetric dgTMatrix to dsCMatrix class")                stop("cannot coerce non-symmetric dgTMatrix to dsCMatrix class")
20            upper <- from@i <= from@j            upper <- from@i <= from@j
21            uC <- as(new("dgTMatrix", Dim = from@Dim, i = from@i[upper],            uC <- as(new("dgTMatrix", Dim = from@Dim,  Dimnames = from@Dimnames,
22                           i = from@i[upper],
23                         j = from@j[upper], x = from@x[upper]), "dgCMatrix")                         j = from@j[upper], x = from@x[upper]), "dgCMatrix")
24            new("dsCMatrix", Dim = uC@Dim, p = uC@p, i = uC@i, x = uC@x, uplo = "U")            new("dsCMatrix", Dim = uC@Dim, p = uC@p, i = uC@i, x = uC@x, uplo = "U")
25        })        })
26    
27    setAs("dgTMatrix", "dsTMatrix",
28          function(from) {
29              if(isSymmetric(from)) {
30                  upper <- from@i <= from@j
31                  new("dsTMatrix", Dim = from@Dim, Dimnames = from@Dimnames,
32                      i = from@i[upper],
33                      j = from@j[upper], x = from@x[upper], uplo = "U")
34              }
35              else stop("not a symmetric matrix")})
36    
37  setAs("dgTMatrix", "dtTMatrix",  setAs("dgTMatrix", "dtTMatrix",
38        function(from) gt2tT(from, uplo = from@uplo, diag = from@diag))        function(from) {
39              if(isTr <- isTriangular(from))
40                  gt2tT(from, uplo = attr(isTr, "kind"),
41                        diag = "N") ## improve: also test for unit diagonal
42              else stop("not a triangular matrix")})
43    
44  setAs("matrix", "dgTMatrix",  setAs("matrix", "dgTMatrix",
45        function(from) {        function(from) {

Legend:
Removed from v.1237  
changed lines
  Added in v.1238

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