diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-05-21 10:30:55 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-05-21 10:30:55 +0200 |
commit | 197e88c3b56d28840217010a2871c6ea3a4dd1a4 (patch) | |
tree | 825be9d6c9d87d23f7e5497c0133d11d52c63535 /packages/hmatrix/examples/lie.hs | |
parent | e07c3dee7235496b71a89233106d93f6cc94ada1 (diff) |
update dependencies, move examples etc
Diffstat (limited to 'packages/hmatrix/examples/lie.hs')
-rw-r--r-- | packages/hmatrix/examples/lie.hs | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/packages/hmatrix/examples/lie.hs b/packages/hmatrix/examples/lie.hs deleted file mode 100644 index db21ea8..0000000 --- a/packages/hmatrix/examples/lie.hs +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | -- The magic of Lie Algebra | ||
2 | |||
3 | import Numeric.LinearAlgebra | ||
4 | |||
5 | disp = putStrLn . dispf 5 | ||
6 | |||
7 | rot1 :: Double -> Matrix Double | ||
8 | rot1 a = (3><3) | ||
9 | [ 1, 0, 0 | ||
10 | , 0, c, s | ||
11 | , 0,-s, c ] | ||
12 | where c = cos a | ||
13 | s = sin a | ||
14 | |||
15 | g1,g2,g3 :: Matrix Double | ||
16 | |||
17 | g1 = (3><3) [0, 0,0 | ||
18 | ,0, 0,1 | ||
19 | ,0,-1,0] | ||
20 | |||
21 | rot2 :: Double -> Matrix Double | ||
22 | rot2 a = (3><3) | ||
23 | [ c, 0, s | ||
24 | , 0, 1, 0 | ||
25 | ,-s, 0, c ] | ||
26 | where c = cos a | ||
27 | s = sin a | ||
28 | |||
29 | g2 = (3><3) [ 0,0,1 | ||
30 | , 0,0,0 | ||
31 | ,-1,0,0] | ||
32 | |||
33 | rot3 :: Double -> Matrix Double | ||
34 | rot3 a = (3><3) | ||
35 | [ c, s, 0 | ||
36 | ,-s, c, 0 | ||
37 | , 0, 0, 1 ] | ||
38 | where c = cos a | ||
39 | s = sin a | ||
40 | |||
41 | g3 = (3><3) [ 0,1,0 | ||
42 | ,-1,0,0 | ||
43 | , 0,0,0] | ||
44 | |||
45 | deg=pi/180 | ||
46 | |||
47 | -- commutator | ||
48 | infix 8 & | ||
49 | a & b = a <> b - b <> a | ||
50 | |||
51 | infixl 6 |+| | ||
52 | a |+| b = a + b + a&b /2 + (a-b)&(a & b) /12 | ||
53 | |||
54 | main = do | ||
55 | let a = 45*deg | ||
56 | b = 50*deg | ||
57 | c = -30*deg | ||
58 | exact = rot3 a <> rot1 b <> rot2 c | ||
59 | lie = scalar a * g3 |+| scalar b * g1 |+| scalar c * g2 | ||
60 | putStrLn "position in the tangent space:" | ||
61 | disp lie | ||
62 | putStrLn "exponential map back to the group (2 terms):" | ||
63 | disp (expm lie) | ||
64 | putStrLn "exact position:" | ||
65 | disp exact | ||