SCM

SCM Repository

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

Diff of /pkg/R/dtTMatrix.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 1  Line 1 
1  ### Coercion and Methods for Triangular Triplet Matrices  ### Coercion and Methods for Triangular Triplet Matrices
2    
3    gt2tT <- function(x, uplo, diag) {
4        ## coerce *gTMatrix to *tTMatrix {general -> triangular}
5        i <- x@i
6        j <- x@j
7        sel <-
8            if(uplo == "U") {
9                if(diag == "U") i < j else i <= j
10            } else {
11                if(diag == "U") i > j else i >= j
12            }
13        i <- i[sel]
14        j <- j[sel]
15        if(is(x, "lMatrix"))
16            new("ltTMatrix", i = i, j = j, uplo = uplo, diag = diag,
17                Dim = x@Dim, Dimnames = x@Dimnames) # no 'x' slot
18        else
19            new(paste(substr(class(x), 1,1), # "d", "l", "i" or "z"
20                      "tTMatrix", sep=''),
21                i = i, j = j, uplo = uplo, diag = diag,
22                x = x@x[sel], Dim = x@Dim, Dimnames = x@Dimnames)
23    }
24    
25  setAs("dtTMatrix", "dtCMatrix",  setAs("dtTMatrix", "dtCMatrix",
26        function(from) {        function(from) {
27            gC <- .Call("dtTMatrix_as_dgCMatrix", from, PACKAGE = "Matrix")            gC <- .Call("dtTMatrix_as_dgCMatrix", from, PACKAGE = "Matrix")

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