SCM

SCM Repository

[matrix] Diff of /pkg/Matrix/R/ddenseMatrix.R
ViewVC logotype

Diff of /pkg/Matrix/R/ddenseMatrix.R

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

pkg/R/ddenseMatrix.R revision 2551, Sat Jun 19 20:45:45 2010 UTC pkg/Matrix/R/ddenseMatrix.R revision 3000, Tue Aug 12 10:29:50 2014 UTC
# Line 76  Line 76 
76  ## setMethod("t", signature(x = "ddenseMatrix"),  ## setMethod("t", signature(x = "ddenseMatrix"),
77  ##        function(x) callGeneric(as(x, "dgeMatrix")))  ##        function(x) callGeneric(as(x, "dgeMatrix")))
78    
79  setMethod("diag", signature(x = "ddenseMatrix"),  ## "diag" --> specific methods for dge, dtr,dtp, dsy,dsp
           function(x, nrow, ncol) diag(as(x, "dgeMatrix")))  
80    
81  setMethod("solve", signature(a = "ddenseMatrix", b = "missing"),  setMethod("solve", signature(a = "ddenseMatrix", b = "missing"),
82            function(a, b, ...) solve(as(a, "dgeMatrix")))            function(a, b, ...) solve(as(a, "dgeMatrix")))
# Line 88  Line 87 
87  for(.b in c("matrix","numeric")) ## << against ambiguity notes  for(.b in c("matrix","numeric")) ## << against ambiguity notes
88  setMethod("solve", signature(a = "ddenseMatrix", b = .b),  setMethod("solve", signature(a = "ddenseMatrix", b = .b),
89            function(a, b, ...) solve(as(a, "dgeMatrix"), Matrix(b)))            function(a, b, ...) solve(as(a, "dgeMatrix"), Matrix(b)))
90    rm(.b)
91    
92  setMethod("lu", signature(x = "ddenseMatrix"),  setMethod("lu", signature(x = "ddenseMatrix"),
93            function(x, ...) lu(as(x, "dgeMatrix"), ...))            function(x, ...)
94              .set.factors(x, "LU", lu(as(x, "dgeMatrix"), ...)))
95    
96  setMethod("chol", signature(x = "ddenseMatrix"), cholMat)  setMethod("chol", signature(x = "ddenseMatrix"), cholMat)
97    
# Line 105  Line 106 
106  ## setMethod("expm", signature(x = "ddenseMatrix"),  ## setMethod("expm", signature(x = "ddenseMatrix"),
107  ##           function(x) callGeneric(as(x, "dgeMatrix")))  ##           function(x) callGeneric(as(x, "dgeMatrix")))
108    
 setMethod("Math",  
           signature(x = "ddenseMatrix"),  
           function(x) callGeneric(as(x, "dgeMatrix")))  
   
   
109    
110  .trilDense <- function(x, k = 0, ...) {  .trilDense <- function(x, k = 0, ...) {
111      k <- as.integer(k[1])      k <- as.integer(k[1])
# Line 154  Line 150 
150  setMethod("skewpart", signature(x = "ddenseMatrix"),  setMethod("skewpart", signature(x = "ddenseMatrix"),
151            function(x) .Call(ddense_skewpart, x))            function(x) .Call(ddense_skewpart, x))
152    
153    
154    setMethod("is.finite", signature(x = "dgeMatrix"),
155              function(x) {
156                  if(all(ifin <- is.finite(x@x)))
157                      allTrueMat(x)
158                  else if(any(ifin)) {
159                      r <- as(x, "lMatrix") #-> logical x-slot
160                      r@x <- ifin
161                      as(r, "nMatrix")
162                  }
163                  else is.na_nsp(x)
164              })
165    
166    ## TODO? -- rather methods for specific subclasses of ddenseMatrix
167    setMethod("is.finite", signature(x = "ddenseMatrix"),
168              function(x) {
169                  if(all(ifin <- is.finite(x@x))) return(allTrueMat(x))
170                  ## *NOT* dge, i.e., either triangular or symmetric
171                  ## (possibly packed): has finite 0-triangle
172                  cdx <- getClassDef(class(x))
173    
174                  r <- new(if(extends(cdx,"symmetricMatrix"))"nsyMatrix" else "ngeMatrix")
175                  r@Dim <- (d <- x@Dim)
176                  r@Dimnames <- x@Dimnames
177                  isPacked <- (le <- prod(d)) > length(ifin)
178                  r@x <- rep.int(TRUE, le)
179                  iTr <- indTri(d[1], upper= x@uplo == "U", diag= TRUE)
180                  if(isPacked) { ## x@x is "usable"
181                      r@x[iTr] <- ifin
182                  } else {
183                      r@x[iTr] <- ifin[iTr]
184                  }
185                  r
186              })
187    
188    setMethod("is.infinite", signature(x = "ddenseMatrix"),
189              function(x) {
190                  if(any((isInf <- is.infinite(x@x)))) {
191                      r <- as(x, "lMatrix")#-> logical x-slot; 0 |--> FALSE
192                      r@x <- isInf
193                      as(r, "nMatrix")# often sparse .. better way?
194                  }
195                  else is.na_nsp(x)
196              })

Legend:
Removed from v.2551  
changed lines
  Added in v.3000

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge