SCM

SCM Repository

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

Diff of /pkg/R/denseMatrix.R

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

revision 1672, Mon Nov 6 20:25:10 2006 UTC revision 1673, Mon Nov 6 20:54:26 2006 UTC
# Line 64  Line 64 
64                           drop = "logical"),                           drop = "logical"),
65            function (x, i, j, drop) {            function (x, i, j, drop) {
66                r <- callGeneric(x = as(x, "matrix"), i=i, j=j, drop=drop)                r <- callGeneric(x = as(x, "matrix"), i=i, j=j, drop=drop)
67                if(is.null(dim(r))) r else as_geClass(r, class(x))                if(is.null(dim(r)))
68                      r
69                  else {
70                      cl <- class(x)
71                      if(extends(cl, "symmetricMatrix") &&
72                         length(i) == length(j) && all(i == j))
73                          as(r, cl) ## keep original symmetric class
74                      else as_geClass(r, cl)
75                  }
76            })            })
77    
78  ## Now the "[<-" ones --- see also those in ./Matrix.R  ## Now the "[<-" ones --- see also those in ./Matrix.R
# Line 74  Line 82 
82  ## FIXME: 1) These are far from efficient  ## FIXME: 1) These are far from efficient
83  ## -----  2) value = "numeric" is only ok for "ddense*"  ## -----  2) value = "numeric" is only ok for "ddense*"
84  setReplaceMethod("[", signature(x = "denseMatrix", i = "index", j = "missing",  setReplaceMethod("[", signature(x = "denseMatrix", i = "index", j = "missing",
85                                  value = "numeric"),                                  value = "replValue"),
86                   function (x, i, value) {                   function (x, i, value) {
87                       r <- as(x, "matrix")                       r <- as(x, "matrix")
88                       r[i, ] <- value                       r[i, ] <- value
# Line 82  Line 90 
90                   })                   })
91    
92  setReplaceMethod("[", signature(x = "denseMatrix", i = "missing", j = "index",  setReplaceMethod("[", signature(x = "denseMatrix", i = "missing", j = "index",
93                                  value = "numeric"),                                  value = "replValue"),
94                   function (x, j, value) {                   function (x, j, value) {
95                       r <- as(x, "matrix")                       r <- as(x, "matrix")
96                       r[, j] <- value                       r[, j] <- value
# Line 90  Line 98 
98                   })                   })
99    
100  setReplaceMethod("[", signature(x = "denseMatrix", i = "index", j = "index",  setReplaceMethod("[", signature(x = "denseMatrix", i = "index", j = "index",
101                                  value = "numeric"),                                  value = "replValue"),
102                   function (x, i, j, value) {                   function (x, i, j, value) {
103                       r <- as(x, "matrix")                       r <- as(x, "matrix")
104                       r[i, j] <- value                       r[i, j] <- value

Legend:
Removed from v.1672  
changed lines
  Added in v.1673

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