SCM

SCM Repository

[matrix] Diff of /pkg/tests/matr-exp.R
ViewVC logotype

Diff of /pkg/tests/matr-exp.R

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

revision 524, Mon Feb 7 09:30:58 2005 UTC revision 532, Mon Feb 7 17:23:54 2005 UTC
# Line 12  Line 12 
12    
13  m2 <- Matrix(c(-49, -64, 24, 31), nc = 2)  m2 <- Matrix(c(-49, -64, 24, 31), nc = 2)
14  e2 <- expm(m2)  e2 <- expm(m2)
15  assert.EQ.mat(e2, rbind(c(-0.73575875814475, 0.55181909965810),  ## The true matrix exponential is 'te2':
16                          c(-1.47151759908826, 1.10363824071557)),  e_1 <-  exp(-1)
17                tol = 1e-13)  e_17 <- exp(-17)
18    te2 <- rbind(c(3*e_17 - 2*e_1, -3/2*e_17 + 3/2*e_1),
19                 c(4*e_17 - 4*e_1, -2  *e_17 + 3  *e_1))
20    assert.EQ.mat(e2, te2, tol = 1e-13)
21    ## See the (average relative) difference:
22    all.equal(as(e2,"matrix"), te2, tol = 0) # 1.48e-14 on "lynne"
23    
24  ## The ``surprising identity''      det(exp(A)) == exp( tr(A) )  ## The ``surprising identity''      det(exp(A)) == exp( tr(A) )
25  ## or                           log det(exp(A)) == tr(A) :  ## or                           log det(exp(A)) == tr(A) :
26  stopifnot(all.equal(determinant(e2)$modulus, sum(diag(m2))))  stopifnot(all.equal(determinant(e2)$modulus, sum(diag(m2))))

Legend:
Removed from v.524  
changed lines
  Added in v.532

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