SCM

SCM Repository

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

Diff of /pkg/Matrix/R/diagMatrix.R

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

revision 2096, Fri Dec 7 17:44:44 2007 UTC revision 2157, Tue Mar 25 15:00:01 2008 UTC
# Line 16  Line 16 
16      if(missing(x)) ## unit diagonal matrix      if(missing(x)) ## unit diagonal matrix
17          new("ddiMatrix", Dim = c(n,n), diag = "U")          new("ddiMatrix", Dim = c(n,n), diag = "U")
18      else {      else {
19          stopifnot(length(x) == n)          lx <- length(x)
20            stopifnot(lx == 1 || lx == n) # but keep 'x' short for now
21          if(is.logical(x))          if(is.logical(x))
22              cl <- "ldiMatrix"              cl <- "ldiMatrix"
23          else if(is.numeric(x)) {          else if(is.numeric(x)) {
# Line 26  Line 27 
27          else if(is.complex(x)) {          else if(is.complex(x)) {
28              cl <- "zdiMatrix"  # will not yet work              cl <- "zdiMatrix"  # will not yet work
29          } else stop("'x' has invalid data type")          } else stop("'x' has invalid data type")
30          new(cl, Dim = c(n,n), diag = "N", x = x)          new(cl, Dim = c(n,n), diag = "N",
31                x = if(lx == 1) rep.int(x,n) else x)
32      }      }
33  }  }
34    
35    ## Pkg 'spdep' had (relatively slow) versions of this as_dsCMatrix_I()
36    .symDiagonal <- function(n, x = rep.int(1,n), uplo = "U") {
37        stopifnot(n == (n. <- as.integer(n)), (n <- n.) >= 0)
38        if((lx <- length(x)) == 1) x <- rep.int(x, n)
39        else if(lx != n) stop("length(x) must be 1 or n")
40        cls <-
41            if(is.double(x)) "dsCMatrix"
42            else if(is.logical(x)) "lsCMatrix"
43            else { ## for now
44                storage.mode(x) <- "double"
45                "dsCMatrix"
46            }
47        new(cls, Dim = c(n,n), x = x, uplo = uplo,
48            i = if(n) 0:(n - 1L) else integer(0), p = 0:n)
49    }
50    
51  ### This is modified from a post of Bert Gunter to R-help on  1 Sep 2005.  ### This is modified from a post of Bert Gunter to R-help on  1 Sep 2005.
52  ### Bert's code built on a post by Andy Liaw who most probably was influenced  ### Bert's code built on a post by Andy Liaw who most probably was influenced
53  ### by earlier posts, notably one by Scott Chasalow on S-news, 16 Jan 2002  ### by earlier posts, notably one by Scott Chasalow on S-news, 16 Jan 2002
# Line 58  Line 76 
76      as(ret, "CsparseMatrix")      as(ret, "CsparseMatrix")
77  }  }
78    
79  diag2tT <- function(from) {  
80    .diag2tT <- function(from, uplo = "U", kind = .M.kind(from)) {
81        ## to triangular Tsparse
82      i <- if(from@diag == "U") integer(0) else seq_len(from@Dim[1]) - 1L      i <- if(from@diag == "U") integer(0) else seq_len(from@Dim[1]) - 1L
83      new(paste(.M.kind(from), "tTMatrix", sep=''),      new(paste(kind, "tTMatrix", sep=''),
84          diag = from@diag, Dim = from@Dim, Dimnames = from@Dimnames,          diag = from@diag, Dim = from@Dim, Dimnames = from@Dimnames,
85            uplo = uplo,
86          x = from@x, # <- ok for diag = "U" and "N" (!)          x = from@x, # <- ok for diag = "U" and "N" (!)
87          i = i, j = i)          i = i, j = i)
88  }  }
89    
90  diag2sT <- function(from) { # to symmetric Tsparse  .diag2sT <- function(from, uplo = "U", kind = .M.kind(from)) {
91      i <- if(from@diag == "U") integer(0) else seq_len(from@Dim[1]) - 1L      ## to symmetric Tsparse
92      new(paste(.M.kind(from), "sTMatrix", sep=''),      n <- from@Dim[1]
93        i <- seq_len(n) - 1L
94        new(paste(kind, "sTMatrix", sep=''),
95          Dim = from@Dim, Dimnames = from@Dimnames,          Dim = from@Dim, Dimnames = from@Dimnames,
96          x = from@x, i = i, j = i)          i = i, j = i, uplo = uplo,
97  }          x = if(from@diag == "N") from@x else ## "U"-diag
98            rep.int(switch(kind,
99  setAs("diagonalMatrix", "triangularMatrix", diag2tT)                         "d" = 1.,
100  setAs("diagonalMatrix", "sparseMatrix", diag2tT)                         "l" =,
101                           "n" = TRUE,
102                           ## otherwise
103                           stop("'", kind,"' kind not yet implemented")), n))
104    }
105    
106    ## diagonal -> triangular,  upper / lower depending on "partner":
107    diag2tT.u <- function(d, x, kind = .M.kind(d))
108        .diag2tT(d, uplo = if(is(x,"triangularMatrix")) x@uplo else "U", kind)
109    
110    
111    ## In order to evade method dispatch ambiguity warnings,
112    ## and because we can save a .M.kind() call, we use this explicit
113    ## "hack"  instead of signature  x = "diagonalMatrix" :
114    ##
115    ## ddi*:
116    diag2tT <- function(from) .diag2tT(from, "U", "d")
117    setAs("ddiMatrix", "triangularMatrix", diag2tT)
118    setAs("ddiMatrix", "sparseMatrix", diag2tT)
119    ## needed too (otherwise <dense> -> Tsparse is taken):
120    setAs("ddiMatrix", "TsparseMatrix", diag2tT)
121    setAs("ddiMatrix", "CsparseMatrix",
122          function(from) as(.diag2tT(from, "U", "d"), "CsparseMatrix"))
123    setAs("ddiMatrix", "symmetricMatrix",
124          function(from) .diag2sT(from, "U", "d"))
125    ##
126    ## ldi*:
127    diag2tT <- function(from) .diag2tT(from, "U", "l")
128    setAs("ldiMatrix", "triangularMatrix", diag2tT)
129    setAs("ldiMatrix", "sparseMatrix", diag2tT)
130  ## needed too (otherwise <dense> -> Tsparse is taken):  ## needed too (otherwise <dense> -> Tsparse is taken):
131  setAs("diagonalMatrix", "TsparseMatrix", diag2tT)  setAs("ldiMatrix", "TsparseMatrix", diag2tT)
132  ## is better than this:  setAs("ldiMatrix", "CsparseMatrix",
133  ## setAs("diagonalMatrix", "sparseMatrix",        function(from) as(.diag2tT(from, "U", "l"), "CsparseMatrix"))
134  ##       function(from)  setAs("ldiMatrix", "symmetricMatrix",
135  ##        as(from, if(is(from, "dMatrix")) "dgCMatrix" else "lgCMatrix"))        function(from) .diag2sT(from, "U", "l"))
136  setAs("diagonalMatrix", "CsparseMatrix",  
137        function(from) as(diag2tT(from), "CsparseMatrix"))  
138    setAs("diagonalMatrix", "nMatrix",
139          function(from) {
140              n <- from@Dim[1]
141              i <- if(from@diag == "U") integer(0) else which(isN0(from@x)) - 1L
142              new("ntTMatrix", i = i, j = i, diag = from@diag,
143                  Dim = from@Dim, Dimnames = from@Dimnames)
144          })
145    
 setAs("diagonalMatrix", "symmetricMatrix", diag2sT)  
146    
147  setAs("diagonalMatrix", "matrix",  setAs("diagonalMatrix", "matrix",
148        function(from) {        function(from) {
# Line 94  Line 152 
152                 nrow = n, ncol = n)                 nrow = n, ncol = n)
153        })        })
154    
155    setMethod("as.vector", signature(x = "diagonalMatrix", mode="missing"),
156              function(x, mode) {
157                  n <- x@Dim[1]
158                  mod <- mode(x@x)
159                  r <- vector(mod, length = n^2)
160                  if(n)
161                      r[1 + 0:(n - 1) * (n + 1)] <-
162                          if(x@diag == "U")
163                              switch(mod, "integer"= 1L,
164                                     "numeric"= 1, "logical"= TRUE)
165                          else x@x
166                  r
167              })
168    
169  setAs("diagonalMatrix", "generalMatrix", # prefer sparse:  setAs("diagonalMatrix", "generalMatrix", # prefer sparse:
170        function(from) as(from, paste(.M.kind(from), "gCMatrix", sep='')))        function(from) as(as(from, "CsparseMatrix"), "generalMatrix"))
171    
172  .diag.x <- function(m) {  .diag.x <- function(m) {
173      if(m@diag == "U")      if(m@diag == "U")
174          rep.int(if(is.numeric(m@x)) 1. else TRUE,          rep.int(if(is.numeric(m@x)) 1. else TRUE, m@Dim[1])
                 m@Dim[1])  
175      else m@x      else m@x
176  }  }
177    
# Line 109  Line 180 
180      m      m
181  }  }
182    
183    if(FALSE) {
184  ## given the above, the following  4  coercions should be all unneeded;  ## given the above, the following  4  coercions should be all unneeded;
185  ## we prefer triangular to general:  ## we prefer triangular to general:
186  setAs("ddiMatrix", "dgTMatrix",  setAs("ddiMatrix", "dgTMatrix",
# Line 139  Line 211 
211    
212  setAs("ldiMatrix", "lgCMatrix",  setAs("ldiMatrix", "lgCMatrix",
213        function(from) as(as(from, "lgTMatrix"), "lgCMatrix"))        function(from) as(as(from, "lgTMatrix"), "lgCMatrix"))
214    }
215    
216    
217  if(FALSE) # now have faster  "ddense" -> "dge"  if(FALSE) # now have faster  "ddense" -> "dge"
# Line 185  Line 258 
258        })        })
259    
260    
261  setMethod("diag", signature(x = "diagonalMatrix"),  ## In order to evade method dispatch ambiguity warnings,
262    ## we use this hack instead of signature  x = "diagonalMatrix" :
263    diCls <- names(getClass("diagonalMatrix")@subclasses)
264    for(cls in diCls) {
265        setMethod("diag", signature(x = cls),
266            function(x = 1, nrow, ncol) .diag.x(x))            function(x = 1, nrow, ncol) .diag.x(x))
267    }
268    
269    
270  subDiag <- function(x, i, j, drop) {  subDiag <- function(x, i, j, ..., drop) {
271      x <- as(x, "sparseMatrix")      x <- as(x, "sparseMatrix")
272      x <- if(missing(i))      x <- if(missing(i))
273          x[, j, drop=drop]          x[, j, drop=drop]
# Line 197  Line 275 
275          x[i, , drop=drop]          x[i, , drop=drop]
276      else      else
277          x[i,j, drop=drop]          x[i,j, drop=drop]
278      if(isDiagonal(x)) as(x, "diagonalMatrix") else x      if(isS4(x) && isDiagonal(x)) as(x, "diagonalMatrix") else x
279  }  }
280    
281  setMethod("[", signature(x = "diagonalMatrix", i = "index",  setMethod("[", signature(x = "diagonalMatrix", i = "index",
282                           j = "index", drop = "logical"), subDiag)                           j = "index", drop = "logical"), subDiag)
283  setMethod("[", signature(x = "diagonalMatrix", i = "index",  setMethod("[", signature(x = "diagonalMatrix", i = "index",
284                          j = "missing", drop = "logical"),                          j = "missing", drop = "logical"),
285            function(x, i, drop) subDiag(x, i=i, drop=drop))            function(x, i, j, ..., drop) subDiag(x, i=i, drop=drop))
286  setMethod("[", signature(x = "diagonalMatrix", i = "missing",  setMethod("[", signature(x = "diagonalMatrix", i = "missing",
287                           j = "index", drop = "logical"),                           j = "index", drop = "logical"),
288            function(x, j, drop) subDiag(x, j=j, drop=drop))            function(x, i, j, ..., drop) subDiag(x, j=j, drop=drop))
289    
290  ## When you assign to a diagonalMatrix, the result should be  ## When you assign to a diagonalMatrix, the result should be
291  ## diagonal or sparse ---  ## diagonal or sparse ---
292  ## FIXME: this now fails because the "denseMatrix" methods come first in dispatch  ## FIXME: this now fails because the "denseMatrix" methods come first in dispatch
293  replDiag <- function(x, i, j, value) {  ## Only(?) current bug:  x[i] <- value  is wrong when  i is *vector*
294    replDiag <- function(x, i, j, ..., value) {
295      x <- as(x, "sparseMatrix")      x <- as(x, "sparseMatrix")
     message(sprintf("diagnosing replDiag() -- nargs() = %d\n", nargs()))  
296      if(missing(i))      if(missing(i))
297          x[, j] <- value          x[, j] <- value
298      else if(missing(j))      else if(missing(j)) { ##  x[i , ] <- v  *OR*   x[i] <- v
299            na <- nargs()
300    ##         message("diagnosing replDiag() -- nargs()= ", na)
301            if(na == 4)
302          x[i, ] <- value          x[i, ] <- value
303      else          else if(na == 3)
304                x[i] <- value
305            else stop("Internal bug: nargs()=",na,"; please report")
306        } else
307          x[i,j] <- value          x[i,j] <- value
308      if(isDiagonal(x)) as(x, "diagonalMatrix") else x      if(isDiagonal(x)) as(x, "diagonalMatrix") else x
309  }  }
310    
311  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "index",  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "index",
312                                  j = "index", value = "replValue"), replDiag)                                  j = "index", value = "replValue"), replDiag)
313    
314  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "index",  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "index",
315                                  j = "missing", value = "replValue"),                                  j = "missing", value = "replValue"),
316                   function(x, i, value) replDiag(x, i=i, value=value))                   function(x,i,j, ..., value) {
317                         ## message("before replDiag() -- nargs()= ", nargs())
318                         if(nargs() == 3)
319                             replDiag(x, i=i, value=value)
320                         else ## nargs() == 4 :
321                             replDiag(x, i=i, , value=value)
322                     })
323    
324  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "matrix", # 2-col.matrix  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "matrix", # 2-col.matrix
325                                  j = "missing", value = "replValue"),                                  j = "missing", value = "replValue"),
326                   function(x, i, value) {                   function(x,i,j, ..., value) {
327                       if(ncol(i) == 2) {                       if(ncol(i) == 2) {
328                           if(all((ii <- i[,1]) == i[,2])) { # replace in diagonal only                           if(all((ii <- i[,1]) == i[,2])) { # replace in diagonal only
329                               x@x[ii] <- value                               x@x[ii] <- value
# Line 251  Line 343 
343    
344  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "missing",  setReplaceMethod("[", signature(x = "diagonalMatrix", i = "missing",
345                                  j = "index", value = "replValue"),                                  j = "index", value = "replValue"),
346                   function(x, j, value) replDiag(x, j=j, value=value))                   function(x,i,j, ..., value) replDiag(x, j=j, value=value))
347    
348    
349  setMethod("t", signature(x = "diagonalMatrix"),  setMethod("t", signature(x = "diagonalMatrix"),
# Line 262  Line 354 
354  setMethod("isTriangular", signature(object = "diagonalMatrix"),  setMethod("isTriangular", signature(object = "diagonalMatrix"),
355            function(object) TRUE)            function(object) TRUE)
356  setMethod("isSymmetric", signature(object = "diagonalMatrix"),  setMethod("isSymmetric", signature(object = "diagonalMatrix"),
357            function(object) TRUE)            function(object, ...) TRUE)
358    
359    setMethod("symmpart", signature(x = "diagonalMatrix"), function(x) x)
360    setMethod("skewpart", signature(x = "diagonalMatrix"), setZero)
361    
362  setMethod("chol", signature(x = "ddiMatrix"),# pivot = "ANY"  setMethod("chol", signature(x = "ddiMatrix"),
363            function(x, pivot) {            function(x, pivot, ...) {
364                if(any(x@x < 0)) stop("chol() is undefined for diagonal matrix with negative entries")                if(any(x@x < 0))
365                      stop("chol() is undefined for diagonal matrix with negative entries")
366                x@x <- sqrt(x@x)                x@x <- sqrt(x@x)
367                x                x
368            })            })
369  ## chol(L) is L for logical diagonal:  ## chol(L) is L for logical diagonal:
370  setMethod("chol", signature(x = "ldiMatrix"), function(x, pivot) x)  setMethod("chol", signature(x = "ldiMatrix"), function(x, pivot, ...) x)
371    
372  ## Basic Matrix Multiplication {many more to add}  ## Basic Matrix Multiplication {many more to add}
373  ##       ---------------------  ##       ---------------------
# Line 366  Line 462 
462  ##           })  ##           })
463    
464  setMethod("crossprod", signature(x = "diagonalMatrix", y = "sparseMatrix"),  setMethod("crossprod", signature(x = "diagonalMatrix", y = "sparseMatrix"),
465            function(x, y = NULL) { x <- as(x, "sparseMatrix"); callGeneric() })            function(x, y = NULL) crossprod(as(x, "sparseMatrix"), y))
466    
467  setMethod("crossprod", signature(x = "sparseMatrix", y = "diagonalMatrix"),  setMethod("crossprod", signature(x = "sparseMatrix", y = "diagonalMatrix"),
468            function(x, y = NULL) { y <- as(y, "sparseMatrix"); callGeneric() })            function(x, y = NULL) crossprod(x, as(y, "sparseMatrix")))
469    
470  setMethod("tcrossprod", signature(x = "diagonalMatrix", y = "sparseMatrix"),  setMethod("tcrossprod", signature(x = "diagonalMatrix", y = "sparseMatrix"),
471            function(x, y = NULL) { x <- as(x, "sparseMatrix"); callGeneric() })            function(x, y = NULL) tcrossprod(as(x, "sparseMatrix"), y))
472    
473  setMethod("tcrossprod", signature(x = "sparseMatrix", y = "diagonalMatrix"),  setMethod("tcrossprod", signature(x = "sparseMatrix", y = "diagonalMatrix"),
474            function(x, y = NULL) { y <- as(y, "sparseMatrix"); callGeneric() })            function(x, y = NULL) tcrossprod(x, as(y, "sparseMatrix")))
475    
476    
477  ## FIXME?: In theory, this can be done *FASTER*, in some cases, via tapply1()  ## FIXME?: In theory, this can be done *FASTER*, in some cases, via tapply1()
# Line 416  Line 512 
512  setMethod("solve", signature(a = "diagonalMatrix", b = "Matrix"),  setMethod("solve", signature(a = "diagonalMatrix", b = "Matrix"),
513            solveDiag)            solveDiag)
514    
515    ## Schur()  ---> ./eigen.R
516    
517    
518    
# Line 456  Line 553 
553  ## For almost everything else, diag* shall be treated "as sparse" :  ## For almost everything else, diag* shall be treated "as sparse" :
554  ## These are cheap implementations via coercion  ## These are cheap implementations via coercion
555    
556  ## for disambiguation  ## For disambiguation --- define this for "sparseMatrix" , then for "ANY";
557  setMethod("Ops", signature(e1 = "diagonalMatrix", e2 = "sparseMatrix"),  ## and because we can save an .M.kind() call, we use this explicit
558            function(e1,e2) callGeneric(as(e1, "sparseMatrix"), e2))  ## "hack" for all diagonalMatrix *subclasses* instead of just "diagonalMatrix" :
559  setMethod("Ops", signature(e1 = "sparseMatrix", e2 = "diagonalMatrix"),  ##
560            function(e1,e2) callGeneric(e1, as(e2, "sparseMatrix")))  ## ddi*:
561  ## in general:  setMethod("Ops", signature(e1 = "ddiMatrix", e2 = "sparseMatrix"),
562  setMethod("Ops", signature(e1 = "diagonalMatrix", e2 = "ANY"),            function(e1,e2) callGeneric(diag2tT.u(e1,e2, "d"), e2))
563            function(e1,e2) callGeneric(as(e1,"sparseMatrix"), e2))  setMethod("Ops", signature(e1 = "sparseMatrix", e2 = "ddiMatrix"),
564  setMethod("Ops", signature(e1 = "ANY", e2 = "diagonalMatrix"),            function(e1,e2) callGeneric(e1, diag2tT.u(e2,e1, "d")))
565            function(e1,e2) callGeneric(e1, as(e2,"sparseMatrix")))  ## ldi*
566    setMethod("Ops", signature(e1 = "ldiMatrix", e2 = "sparseMatrix"),
567              function(e1,e2) callGeneric(diag2tT.u(e1,e2, "l"), e2))
568    setMethod("Ops", signature(e1 = "sparseMatrix", e2 = "ldiMatrix"),
569              function(e1,e2) callGeneric(e1, diag2tT.u(e2,e1, "l")))
570    
571    ##  other = "numeric" : stay diagonal if possible
572    ## ddi*:
573    setMethod("Ops", signature(e1 = "ddiMatrix", e2 = "numeric"),
574              function(e1,e2) {
575                  n <- e1@Dim[1]; nsq <- n*n
576                  f0 <- callGeneric(0, e2)
577                  if(all(is0(f0))) { # remain diagonal
578                      L1 <- (le <- length(e2)) == 1L
579                      if(!L1 && le != nsq) e2 <- rep(e2, length.out = nsq)
580                      if(e1@diag == "U" && any((r <- callGeneric(1, e2)) != 1)) {
581                          e1@diag <- "N"
582                          if(L1) r <- rep.int(r, n)
583                      } else
584                          r <- callGeneric(e1@x, e2)
585                      e1@x <- if(L1) r else r[1L + n*(0:(n-1L))]
586                      return(e1)
587                  }
588                  callGeneric(diag2tT.u(e1,e2, "d"), e2)
589              })
590    
591    setMethod("Ops", signature(e1 = "numeric", e2 = "ddiMatrix"),
592              function(e1,e2) {
593                  n <- e2@Dim[1]; nsq <- n*n
594                  f0 <- callGeneric(e1, 0)
595                  if(all(is0(f0))) { # remain diagonal
596                      L1 <- (le <- length(e1)) == 1L
597                      if(!L1 && le != nsq) e1 <- rep(e1, length.out = nsq)
598                      if(e2@diag == "U" && any((r <- callGeneric(e1, 1)) != 1)) {
599                          e2@diag <- "N"
600                          if(L1) r <- rep.int(r, n)
601                      } else
602                          r <- callGeneric(e1, e2@x)
603                      e2@x <- if(L1) r else r[1L + n*(0:(n-1L))]
604                      return(e2)
605                  }
606                  callGeneric(e1, diag2tT.u(e2,e1, "d"))
607              })
608    ## ldi*:
609    setMethod("Ops", signature(e1 = "ldiMatrix", e2 = "numeric"),
610              function(e1,e2) {
611                  n <- e1@Dim[1]; nsq <- n*n
612                  f0 <- callGeneric(FALSE, e2)
613                  if(all(is0(f0))) { # remain diagonal
614                      L1 <- (le <- length(e2)) == 1L
615                      if(!L1 && le != nsq) e2 <- rep(e2, length.out = nsq)
616                      if(e1@diag == "U" && any((r <- callGeneric(TRUE, e2)) != 1)) {
617                          e1@diag <- "N"
618                          if(L1) r <- rep.int(r, n)
619                      } else
620                          r <- callGeneric(e1@x, e2)
621                      e1@x <- if(L1) r else r[1L + n*(0:(n-1L))]
622                      return(e1)
623                  }
624                  callGeneric(diag2tT.u(e1,e2, "l"), e2)
625              })
626    
627    setMethod("Ops", signature(e1 = "numeric", e2 = "ldiMatrix"),
628              function(e1,e2) {
629                  n <- e2@Dim[1]; nsq <- n*n
630                  f0 <- callGeneric(e1, FALSE)
631                  if(all(is0(f0))) { # remain diagonal
632                      L1 <- (le <- length(e1)) == 1L
633                      if(!L1 && le != nsq) e1 <- rep(e1, length.out = nsq)
634                      if(e2@diag == "U" && any((r <- callGeneric(e1, TRUE)) != 1)) {
635                          e2@diag <- "N"
636                          if(L1) r <- rep.int(r, n)
637                      } else
638                          r <- callGeneric(e1, e2@x)
639                      e2@x <- if(L1) r else r[1L + n*(0:(n-1L))]
640                      return(e2)
641                  }
642                  callGeneric(e1, diag2tT.u(e2,e1, "l"))
643              })
644    
645    
646    
647    ## Not {"sparseMatrix", "numeric} :  {"denseMatrix", "matrix", ... }
648    ## ddi*:
649    setMethod("Ops", signature(e1 = "ddiMatrix", e2 = "ANY"),
650              function(e1,e2) callGeneric(diag2tT.u(e1,e2, "d"), e2))
651    setMethod("Ops", signature(e1 = "ANY", e2 = "ddiMatrix"),
652              function(e1,e2) callGeneric(e1, diag2tT.u(e2,e1, "d")))
653    ## ldi*:
654    setMethod("Ops", signature(e1 = "ldiMatrix", e2 = "ANY"),
655              function(e1,e2) callGeneric(diag2tT.u(e1,e2, "l"), e2))
656    setMethod("Ops", signature(e1 = "ANY", e2 = "ldiMatrix"),
657              function(e1,e2) callGeneric(e1, diag2tT.u(e2,e1, "l")))
658    
659    
660    

Legend:
Removed from v.2096  
changed lines
  Added in v.2157

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