SCM

SCM Repository

[matrix] Diff of /pkg/tests/dpoMatrix.Rout.save
ViewVC logotype

Diff of /pkg/tests/dpoMatrix.Rout.save

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

revision 656, Wed Mar 16 16:55:32 2005 UTC revision 657, Wed Mar 16 16:57:52 2005 UTC
# Line 1  Line 1 
1    
2  R : Copyright 2005, The R Foundation for Statistical Computing  R : Copyright 2005, The R Foundation for Statistical Computing
3  Version 2.1.0 Under development (unstable) (2005-03-14), ISBN 3-900051-07-0  Version 2.1.0 Under development (unstable) (2005-03-15), ISBN 3-900051-07-0
4    
5  R is free software and comes with ABSOLUTELY NO WARRANTY.  R is free software and comes with ABSOLUTELY NO WARRANTY.
6  You are welcome to redistribute it under certain conditions.  You are welcome to redistribute it under certain conditions.
7  Type 'license()' or 'licence()' for distribution details.  Type 'license()' or 'licence()' for distribution details.
8    
   Natural language support but running in an English locale  
   
9  R is a collaborative project with many contributors.  R is a collaborative project with many contributors.
10  Type 'contributors()' for more information and  Type 'contributors()' for more information and
11  'citation()' on how to cite R or R packages in publications.  'citation()' on how to cite R or R packages in publications.
# Line 20  Line 18 
18  >  >
19  > library(Matrix)  > library(Matrix)
20  >  >
 > stopifnot(c(0,0) == dim(Hilbert(0)))  
21  >  >
22  > h9 <- Hilbert(9)  > h9 <- Hilbert(9)
23    > stopifnot(c(0,0) == dim(Hilbert(0)),
24    +           c(9,9) == h9)
25  > str(h9)  > str(h9)
26  Formal class 'dpoMatrix' [package "Matrix"] with 6 slots  Formal class 'dpoMatrix' [package "Matrix"] with 6 slots
27    ..@ uplo    : chr "U"    ..@ uplo    : chr "U"
# Line 34  Line 33 
33    .. ..$ : NULL    .. ..$ : NULL
34    .. ..$ : NULL    .. ..$ : NULL
35  > all.equal(determinant(h9)$modulus, -96.7369450737858, tol= 1e-15)  > all.equal(determinant(h9)$modulus, -96.7369450737858, tol= 1e-15)
36  [1] TRUE  [1] "Mean relative  difference: 1.043917e-08"
37    > ##-> TRUE only on some platforms; seen relative difference of 10^-8
38  > stopifnot(0 == length(h9@factors))# nothing yet  > stopifnot(0 == length(h9@factors))# nothing yet
39  > str(f9 <- as(chol(h9), "dtrMatrix"))  > str(f9 <- as(chol(h9), "dtrMatrix"))
40  Formal class 'dtrMatrix' [package "Matrix"] with 7 slots  Formal class 'dtrMatrix' [package "Matrix"] with 7 slots
# Line 48  Line 48 
48    .. ..$ : NULL    .. ..$ : NULL
49    .. ..$ : NULL    .. ..$ : NULL
50  > ## h9 now has factorization  > ## h9 now has factorization
51  > stopifnot(names(h9@factors) == "Cholesky")  > stopifnot(names(h9@factors) == "Cholesky",
52  > stopifnot(all.equal(rcond(h9), 9.0938e-13))  +           all.equal(rcond(h9), 9.0938e-13),
53  > stopifnot(all.equal(rcond(f9), 9.1272e-7, tol = 1e-6))# more precision fails  +           all.equal(rcond(f9), 9.1272e-7, tol = 1e-6))# more precision fails
54  > str(h9)# has 'rcond' and 'factors'  > str(h9)# has 'rcond' and 'factors'
55  Formal class 'dpoMatrix' [package "Matrix"] with 6 slots  Formal class 'dpoMatrix' [package "Matrix"] with 6 slots
56    ..@ uplo    : chr "U"    ..@ uplo    : chr "U"
# Line 74  Line 74 
74    .. ..$ : NULL    .. ..$ : NULL
75  > options(digits=4)  > options(digits=4)
76  > (cf9 <- crossprod(f9))# looks the same as  h9 :  > (cf9 <- crossprod(f9))# looks the same as  h9 :
77  9 x 9 Matrix of class 'dpoMatrix'  9 x 9 Matrix of class "dpoMatrix"
78          [,1]   [,2]    [,3]    [,4]    [,5]    [,6]    [,7]    [,8]    [,9]          [,1]   [,2]    [,3]    [,4]    [,5]    [,6]    [,7]    [,8]    [,9]
79   [1,] 1.0000 0.5000 0.33333 0.25000 0.20000 0.16667 0.14286 0.12500 0.11111   [1,] 1.0000 0.5000 0.33333 0.25000 0.20000 0.16667 0.14286 0.12500 0.11111
80   [2,] 0.5000 0.3333 0.25000 0.20000 0.16667 0.14286 0.12500 0.11111 0.10000   [2,] 0.5000 0.3333 0.25000 0.20000 0.16667 0.14286 0.12500 0.11111 0.10000
# Line 88  Line 88 
88  > stopifnot(all.equal(as(h9, "matrix"),  > stopifnot(all.equal(as(h9, "matrix"),
89  +                     as(cf9,"matrix"), tol= 1e-15))  +                     as(cf9,"matrix"), tol= 1e-15))
90  >  >
91    > str(hp9 <- as(h9, "dppMatrix"))
92    Formal class 'dppMatrix' [package "Matrix"] with 6 slots
93      ..@ uplo    : chr "U"
94      ..@ rcond   : Named num 9.1e-13
95      .. ..- attr(*, "names")= chr "O"
96      ..@ factors :List of 1
97      .. ..$ pCholesky:Formal class 'pCholesky' [package "Matrix"] with 7 slots
98      .. .. .. ..@ uplo    : chr "U"
99      .. .. .. ..@ diag    : chr "N"
100      .. .. .. ..@ rcond   : num(0)
101      .. .. .. ..@ factors : list()
102      .. .. .. ..@ x       : num [1:45] 1.000 0.500 0.289 0.333 0.289 ...
103      .. .. .. ..@ Dim     : int [1:2] 9 9
104      .. .. .. ..@ Dimnames:List of 2
105      .. .. .. .. ..$ : NULL
106      .. .. .. .. ..$ : NULL
107      ..@ x       : num [1:45] 1.000 0.500 0.333 0.333 0.250 ...
108      ..@ Dim     : int [1:2] 9 9
109      ..@ Dimnames:List of 2
110      .. ..$ : NULL
111      .. ..$ : NULL
112    >
113    > (s9 <- solve(hp9, seq(nrow(hp9))))
114    9 x 1 Matrix of class "dgeMatrix"
115               [,1]
116     [1,]       729
117     [2,]    -57600
118     [3,]   1094938
119     [4,]  -8648622
120     [5,]  34684584
121     [6,] -76684473
122     [7,]  94594344
123     [8,] -60952225
124     [9,]  15971647
125    > hp9 %*% s9
126    9 x 1 Matrix of class "dgeMatrix"
127          [,1]
128     [1,]    1
129     [2,]    2
130     [3,]    3
131     [4,]    4
132     [5,]    5
133     [6,]    6
134     [7,]    7
135     [8,]    8
136     [9,]    9
137    >
138  >  >

Legend:
Removed from v.656  
changed lines
  Added in v.657

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge