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

revision 1452, Sat Aug 26 18:24:13 2006 UTC revision 1453, Sun Aug 27 16:16:35 2006 UTC
# Line 195  Line 195 
195                new("dgeMatrix", Dim = c(nrx + nry, nc), Dimnames = dn,                new("dgeMatrix", Dim = c(nrx + nry, nc), Dimnames = dn,
196                    x = c(rbind2(as(x,"matrix"), as(y,"matrix"))))                    x = c(rbind2(as(x,"matrix"), as(y,"matrix"))))
197            })            })
198    ## NB: have extra tril(), triu() methods for symmetric ["dsy" and "dsp"] and
199    ##     for triangular ["dtr" and "dtp"]
200    setMethod("tril", "ddenseMatrix",
201              function(x, k = 0, ...) {
202                  k <- as.integer(k[1])
203                  dd <- dim(x); sqr <- dd[1] == dd[2]
204                  stopifnot(-dd[1] <= k, k <= dd[1]) # had k <= 0
205                  ## returns "lower triangular" if k <= 0 && sqr
206                  .Call(ddense_band, x, -dd[1], k)
207              })
208    
209    setMethod("triu", "ddenseMatrix",
210              function(x, k = 0, ...) {
211                  k <- as.integer(k[1])
212                  dd <- dim(x); sqr <- dd[1] == dd[2]
213                  stopifnot(-dd[1] <= k, k <= dd[1]) # had k >= 0
214                  ## returns "upper triangular" if k >= 0
215                  .Call(ddense_band, x, k, dd[2])
216              })
217    
218    setMethod("band", "ddenseMatrix",
219              function(x, k1, k2, ...) {
220                  k1 <- as.integer(k1[1])
221                  k2 <- as.integer(k2[1])
222                  dd <- dim(x); sqr <- dd[1] == dd[2]
223                  stopifnot(-dd[1] <= k1, k1 <= k2, k2 <= dd[1])
224                  r <- .Call(ddense_band, x, k1, k2)
225                  if (k1 < 0  &&  k1 == -k2  && isSymmetric(x)) ## symmetric
226                      as(r, paste(.M.kind(x), "syMatrix", sep=''))
227                  else
228                      r
229              })

Legend:
Removed from v.1452  
changed lines
  Added in v.1453

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