SCM

SCM Repository

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

Diff of /pkg/R/dtpMatrix.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 16  Line 16 
16                gt2tT(as(x, "dgTMatrix"), uplo = from@uplo, diag = from@diag)                gt2tT(as(x, "dgTMatrix"), uplo = from@uplo, diag = from@diag)
17        })        })
18    
 gt2tT <- function(x, uplo, diag) {  
     ## coerce *gtMatrix to *tTMatrix {general -> triangular}  
     i <- x@i  
     j <- x@j  
     sel <-  
         if(uplo == "U") {  
             if(diag == "U") i < j else i <= j  
         } else {  
             if(diag == "U") i > j else i >= j  
         }  
     i <- i[sel]  
     j <- j[sel]  
     if(is(x, "lMatrix"))  
         new("ltTMatrix", i = i, j = j, uplo = uplo, diag = diag,  
             Dim = x@Dim, Dimnames = x@Dimnames) # no 'x' slot  
     else  
         new(paste(substr(class(x), 1,1), # "d", "l", "i" or "z"  
                   "tTMatrix", sep=''),  
             i = i, j = j, uplo = uplo, diag = diag,  
             x = x@x[sel], Dim = x@Dim, Dimnames = x@Dimnames)  
 }  
   
19  setAs("dtpMatrix", "matrix",  setAs("dtpMatrix", "matrix",
20        function(from) as(as(from, "dtrMatrix"), "matrix"))        function(from) as(as(from, "dtrMatrix"), "matrix"))
21  setAs("matrix", "dtpMatrix",  setAs("matrix", "dtpMatrix",

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