The R Project SVN R-packages

Rev

Rev 3802 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3802 Rev 4652
Line 1... Line 1...
1
### Testing the group methods
1
### Testing the group methods  --- some also happens in ./Class+Meth.R
2
 
2
 
3
library(Matrix)
3
library(Matrix)
4
set.seed(2001)
4
set.seed(2001)
5
 
5
 
6
mm <- Matrix(rnorm(50 * 7), nc = 7)
6
mm <- Matrix(rnorm(50 * 7), nc = 7)
Line 10... Line 10...
10
y <- rnorm(nrow(mm))
10
y <- rnorm(nrow(mm))
11
xpy <- crossprod(mm, y)
11
xpy <- crossprod(mm, y)
12
res <- solve(xpx, xpy)
12
res <- solve(xpx, xpy)
13
signif(res, 4) # 7 x 1 Matrix
13
signif(res, 4) # 7 x 1 Matrix
14
 
14
 
-
 
15
stopifnot(all(signif(res) == signif(res, 6)),
-
 
16
	  all(round (xpx) == round (xpx, 0)))
-
 
17
 
15
## exp(): component wise
18
## exp(): component wise
16
signif(dd <- (expm(xpx) - exp(xpx)) / 1e34, 3)# 7 x 7
19
signif(dd <- (expm(xpx) - exp(xpx)) / 1e34, 3)# 7 x 7
17
 
20
 
18
stopifnot(validObject(xpx),
21
stopifnot(validObject(xpx),
19
          validObject(xpy),
22
          validObject(xpy),