File: compareValues.r

package info (click to toggle)
libhmsbeagle 4.0.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 46,436 kB
  • sloc: xml: 133,356; cpp: 36,477; ansic: 5,842; java: 2,400; python: 643; sh: 338; makefile: 50
file content (47 lines) | stat: -rw-r--r-- 1,467 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
evec = matrix(
  c(			 -0.5,  0.6906786606674509,   0.15153543380548623, 0.5,
			  0.5, -0.15153543380548576,  0.6906786606674498,  0.5,
			 -0.5, -0.6906786606674498,  -0.15153543380548617, 0.5,
			  0.5,  0.15153543380548554, -0.6906786606674503,  0.5),
  nrow=4,ncol=4,byrow=T)

ievc = matrix(
  c(			 -0.5,  0.5, -0.5,  0.5,
			  0.6906786606674505, -0.15153543380548617, -0.6906786606674507,   0.15153543380548645,
			  0.15153543380548568, 0.6906786606674509,  -0.15153543380548584, -0.6906786606674509,
			  0.5,  0.5,  0.5,  0.5),
  nrow=4,ncol=4,byrow=T)

make.expDt = function(t) {
  matrix(
  c(exp(-2*t),                   0,                   0,  0,
            0,  exp(-1*t)*cos(1*t),  exp(-1*t)*sin(1*t),  0,
            0, -exp(-1*t)*sin(1*t),  exp(-1*t)*cos(1*t),  0,
            0,                   0,                   0,  1),
  nrow=4,ncol=4,byrow=T)
}

q.circulant = matrix(
  c(-1,  1,  0,  0,
     0, -1,  1,  0,
     0,  0, -1,  1,
     1,  0,  0, -1),
  nrow=4,ncol=4,byrow=T)

test.1 = evec %*% make.expDt(0.1) %*% ievc # Schur decomposition (method used in BEAGLE)

Evec = eigen(q.circulant)$vectors # Complex eigendecomposition
Ievc = solve(Evec)
make2.expDt = function(t) {
  diag(exp(eigen(q.circulant)$values * t))
}

test.2 = Evec %*% make2.expDt(0.1) %*% Ievc  # Should (and does) equal test.1

out.1 = t(make.expDt(0.1)) %*% t(evec) # Should be intermediate result

out.2 = t(ievc) %*% out.1 # Should (and does) equal t(test.1)