-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRootSystem.hs
More file actions
62 lines (46 loc) · 1.76 KB
/
RootSystem.hs
File metadata and controls
62 lines (46 loc) · 1.76 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
module RootSystem (
RootSystem,
simpleRoots,
rootSystem,
orbit,
roots,
action,
generate,
RootSystem.intersect
) where
import Root
import Data.List(group,sort,intersperse)
import Test.QuickCheck
import Control.Monad
import SortedLists
newtype RootSystem = RootSystem [Root]
deriving (Eq,Ord)
remdup a = map head $ group $ sort a
rootSystem :: [Root] -> [Root] -> RootSystem
rootSystem rs res = RootSystem $ remdup $ map (restrict res) rs
roots :: RootSystem -> [Root]
roots (RootSystem rs) = rs
action :: Root -> RootSystem -> RootSystem
action r (RootSystem rs) = RootSystem $ sort $ map (reflect r) rs
orbit :: [Root] -> RootSystem -> [RootSystem]
orbit roots rs = map (`action` rs) roots
simpleRoots :: RootSystem -> [Root]
simpleRoots (RootSystem rs) = filter (`notElem` sums) rs
where sums = remdup [rootSum a b | a<-rs,b<-rs]
generate' :: [Root] -> [Root] -> [Root] -> [Root]
generate' rs cur [] = cur
generate' rs cur add = generate' rs union added
where new = remdup [reflect p r | p<-rs,r<-add]
(union,added) = mergeSplit new cur
generate :: [Root] -> RootSystem
generate rs = RootSystem $ generate' rs [] rs
intersect :: RootSystem -> RootSystem -> RootSystem
intersect (RootSystem xs) (RootSystem ys) = RootSystem $ SortedLists.intersect rxs rys
where rxs = remdup $ map (restrict sxs) xs
sxs = orthcomp xs
rys = remdup $ map (restrict sys) ys
sys = orthcomp ys
instance Arbitrary RootSystem where
arbitrary = liftM2 rootSystem arbitrary arbitrary
instance Show RootSystem where
show (RootSystem rs) = concat $ intersperse "\n" (map show rs)