The R Project SVN R

Rev

Rev 69213 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 69213 Rev 84489
Line 4... Line 4...
4
if(!require(Matrix)) q()
4
if(!require(Matrix)) q()
5
 
5
 
6
## from: example(chol)
6
## from: example(chol)
7
sy2 <- new("dsyMatrix", Dim = as.integer(c(2,2)), x = c(14, NA,32,77))
7
sy2 <- new("dsyMatrix", Dim = as.integer(c(2,2)), x = c(14, NA,32,77))
8
c2 <- chol(sy2)
8
c2 <- chol(sy2)
-
 
9
stopifnot(is(c2, "dtrMatrix"),
-
 
10
          all.equal(as.matrix(c2), tol = 7e-7, # see 2.7e-7
-
 
11
                    matrix(c(3.74166, 0, 8.55236, 1.96396), 2))
9
 
12
          )
10
clM <- getClass("Cholesky")
13
clM <- getClass("Cholesky")
-
 
14
cM <- new(clM)
11
 
15
 
-
 
16
## an*other* "Cholesky" class:
12
setClass("Cholesky", contains = "numeric", representation(size = "integer"))
17
setClass("Cholesky", contains = "numeric", representation(size = "integer"))
13
 
18
 
14
clG <- getClass("Cholesky", where = .GlobalEnv)
19
clG <- getClass("Cholesky", where = .GlobalEnv)
15
 
20
 
16
stopifnot(identical(getClass("Cholesky", where = asNamespace("Matrix")),
-
 
17
                    clM))
21
stopifnot(exprs = {
18
 
-
 
19
stopifnot(identical(getClass(class(c2)), clM))
22
    identical(clM, getClass("Cholesky", where = asNamespace("Matrix")))
20
 
-
 
21
stopifnot(identical(evalq(getClass("Cholesky"), asNamespace("Matrix")),
23
    identical(evalq(getClass("Cholesky"), asNamespace("Matrix")), clM)
22
                    clM))
24
    identical(getClass(class(cM)),  clM)
23
stopifnot(identical(getClass("Cholesky"), clG))
25
    identical(getClass("Cholesky"), clG)
-
 
26
})
24
 
27
 
25
## Second:  tests of methods defined for the same generic
28
## Second:  tests of methods defined for the same generic
26
## (NOT YET!)
29
## (NOT YET!)
27
 
30
 
-
 
31
 
28
## Related: retaining package slots in methods signatures (reported by Martin Morgan)
32
## Related: retaining package slots in methods signatures (reported by Martin Morgan)
29
setClass("A")
33
setClass("A")
30
setGeneric("bar", function(x, y) standardGeneric("bar"))
34
setGeneric("bar", function(x, y) standardGeneric("bar"))
31
setMethod(bar, signature(x="A", y="A"), function(x, y) {})
35
setMethod(bar, signature(x="A", y="A"), function(x, y) {})
32
setMethod(bar, signature(x="A", y="ANY"), function(x, y) {})
36
setMethod(bar, signature(x="A", y="ANY"), function(x, y) {})