diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-22 10:21:15 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-22 10:21:15 +0000 |
commit | 989bdf7e88c13500bd1986dcde36f6cc4f467efb (patch) | |
tree | b30ff0dd52e2b6c2adb1dfe8759d03234f65c684 /examples/pru.hs | |
parent | aa14e6615533e7bd5e2b15acdc3ec76afbe1aac4 (diff) |
reverting to the old signatures for aux C functions
Diffstat (limited to 'examples/pru.hs')
-rw-r--r-- | examples/pru.hs | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/examples/pru.hs b/examples/pru.hs index 4a5104b..fb33962 100644 --- a/examples/pru.hs +++ b/examples/pru.hs | |||
@@ -164,7 +164,7 @@ contractionF t1 t2 = contraction t1 n1 t2 n2 | |||
164 | fn = snd . snd . head . dims | 164 | fn = snd . snd . head . dims |
165 | 165 | ||
166 | 166 | ||
167 | dual vs = foldl' contractionF (leviCivita n) vs | 167 | dualV vs = foldl' contractionF (leviCivita n) vs |
168 | where n = fst . head . dims . head $ vs | 168 | where n = fst . head . dims . head $ vs |
169 | 169 | ||
170 | 170 | ||
@@ -175,4 +175,53 @@ dual2 = foldl' contractionF (leviCivita 3) [u,v,w] | |||
175 | contract1b t (n1,n2) = contract1 t n1 n2 | 175 | contract1b t (n1,n2) = contract1 t n1 n2 |
176 | 176 | ||
177 | dual1' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v)) [("1","p'"),("2'","q''")]) (scalar (recip $ fact 2)) | 177 | dual1' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v)) [("1","p'"),("2'","q''")]) (scalar (recip $ fact 2)) |
178 | dual2' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v /\ w)) [("1","p'"),("2'","q''"),("3'","r''")]) (scalar (recip $ fact 3)) \ No newline at end of file | 178 | dual2' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v /\ w)) [("1","p'"),("2'","q''"),("3'","r''")]) (scalar (recip $ fact 3)) |
179 | |||
180 | |||
181 | x1 = vector "p" [0,0,1] | ||
182 | x2 = vector "q" [2,2,2] | ||
183 | x3 = vector "r" [-3,-1,-1] | ||
184 | x4 = vector "s" [12,0,3] | ||
185 | |||
186 | raise (T d v) = T (map raise' d) v | ||
187 | where raise' (n,(Covariant,s)) = (n,(Contravariant,s)) | ||
188 | raise' (n,(Contravariant,s)) = (n,(Covariant,s)) | ||
189 | |||
190 | dualMV t = prod (foldl' contract1b (lc <*> t) ds) (scalar (recip $ fromIntegral $ fact (length ds))) | ||
191 | where | ||
192 | lc = leviCivita n | ||
193 | nms1 = map (snd.snd) (dims lc) | ||
194 | nms2 = map ((++"'").snd.snd) (dims t) | ||
195 | ds = zip nms1 nms2 | ||
196 | n = fst . head . dims $ t | ||
197 | |||
198 | -- intersection of two lines :-) | ||
199 | -- > raise $ dualMV $ raise $ dualMV (x1/\x2) /\ dualV [x3,x4] | ||
200 | --(3'^[3]) [24.0,24.0,12.0] | ||
201 | |||
202 | y1 = vector "p" [0,0,0,1] | ||
203 | y2 = vector "q" [2,2,0,2] | ||
204 | y3 = vector "r" [-3,-1,0,-1] | ||
205 | y4 = vector "s" [12,0,0,3] | ||
206 | |||
207 | -- why not in R^4? | ||
208 | -- > raise $ dualMV $ raise $ dualMV (y1/\y2) /\ dualV [y3,y4] | ||
209 | -- scalar 0.0 | ||
210 | -- it seems that the sum of ranks must be greater than n :( | ||
211 | |||
212 | asBase r n = filter (\x-> (x==nub x && x==sort x)) $ sequence $ replicate r [1..n] | ||
213 | |||
214 | partF t i = part t (name,i) where name = snd . snd . head . dims $ t | ||
215 | |||
216 | --partL = foldl' partF | ||
217 | |||
218 | niceAS t = filter ((/=0.0).fst) $ zip vals base | ||
219 | where vals = map ((`at` 0).ten.foldl' partF t) (map (map pred) base) | ||
220 | base = asBase r n | ||
221 | r = length (dims t) | ||
222 | n = fst . head . dims $ t | ||
223 | |||
224 | z1 = vector "p" [0,0,0,1] | ||
225 | z2 = vector "q" [1,0,0,1] | ||
226 | z3 = vector "r" [0,1,0,1] | ||
227 | z4 = vector "s" [0,0,1,1] | ||