Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/ein/order-ein.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/ein/order-ein.sml

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

revision 2604, Fri Apr 25 18:23:44 2014 UTC revision 2605, Wed Apr 30 01:46:09 2014 UTC
# Line 8  Line 8 
8    
9      in      in
10    
11  fun pushApply (del,p)= let  fun rewriteProd A=(case A
12      val _=print "In push Apply"      of [A]=> A
13      val(pre,post)=F.filterField p      | A => E.Prod A
14      in (case (pre,post)      (*end case*))
15    
16    fun rewriteApply(c,p)= E.Apply(c, rewriteProd p)
17    
18    
19    fun pushApply (del,p)=(case F.filterField p
20          of ([],[])    => raise Fail"No Field in Apply expression"          of ([],[])    => raise Fail"No Field in Apply expression"
21          | ([],[keep]) => (0,E.Apply(del,keep))      | ([],post) => (0,rewriteApply(del,post))
22          | ([],keep)   => (0,E.Apply(del,E.Prod(keep)))      | (pre,post)=> (1,rewriteProd(pre@[rewriteApply(del,post)]))
         | (_,[keep])  => (1,E.Prod(pre@[E.Apply(del,keep)]))  
         |  _          => (1,E.Prod(pre@[E.Apply(del,E.Prod(post))]))  
23          (*end case*))          (*end case*))
     end  
24    
25    
26  (*Orders the expression correctly.*)  (*Orders the expression correctly.*)
27  fun orderfn(Ein.EIN{params, index, body})= let  fun orderfn(Ein.EIN{params, index, body})= let
   (* val _ = print "\n IN ORDER \n"*)  
28     val changed =ref false     val changed =ref false
29     fun order(body)=(case body     fun order(body)=(case body
30          of E.Const _ => body          of E.Const _ => body
31          | E.Tensor _=> body          | E.Tensor _=> body
32          | E.Field _ => body          | E.Field _ => body
33          | E.Krn _ => body          | E.Krn _ => body
34            | E.Img _ => body
35          | E.Delta _ => body          | E.Delta _ => body
36          | E.Value _ => body          | E.Value _ => body
37          | E.Epsilon _=>body          | E.Epsilon _=>body
38          | E.Partial _ => body          | E.Partial _ => body
39          | E.Conv _=>body          | E.Conv _=>body
40          | E.Sum(c1,E.Sum(c2, e))=>(changed:=true;E.Sum(c1@c2,order e))          | E.Sum(c1,E.Sum(c2, e))=>(changed:=true;E.Sum(c1@c2,order e))
41          | E.Sum([c1],E.Prod p)=> let              (*   | E.Sum([c1],E.Prod p)=> let
42              val _ =print "\n Sum prod"              val _ =print "\n Sum prod"
43              val p'=order(E.Prod p)              val p'=order(E.Prod p)
44              val (change,e')= (case p'              val (change,e')= (case p'
# Line 44  Line 46 
46                  | _=> (1,E.Sum([c1],p'))                  | _=> (1,E.Sum([c1],p'))
47                  (*end case *))                  (*end case *))
48              in (case change of 1=>(changed:=true; e') |_=> e')              in (case change of 1=>(changed:=true; e') |_=> e')
49              end              end*)
50          | E.Sum(c,e)=>(print "\n other sum"; E.Sum(c, order e))          | E.Sum(c,e)=>(print "\n other sum"; E.Sum(c, order e))
51          | E.Lift e => E.Lift(order e)          | E.Lift e => E.Lift(order e)
52          | E.Neg e => E.Neg(order e)          | E.Neg e => E.Neg(order e)
# Line 55  Line 57 
57              val(change,e')=pushApply (e1,e2)              val(change,e')=pushApply (e1,e2)
58              in (case change of 1=>(changed:=true; e') |_=> e')              in (case change of 1=>(changed:=true; e') |_=> e')
59              end              end
60          |E.Apply(e1,E.Add[e2,e3]) => E.Add[E.Apply(e1,e2),E.Apply(e1,e3)]          | E.Apply(e1,e2)=> E.Apply(e1, order e2)
         | E.Apply(e1,e2)=> (print "\n Found apply"; E.Apply(e1, order e2))  
61          | E.Probe(e1,e2)=>  E.Probe(order e1,order e2)          | E.Probe(e1,e2)=>  E.Probe(order e1,order e2)
         | E.Img _ => body  
62          | E.Prod [e1]=>e1          | E.Prod [e1]=>e1
63          | E.Prod e=> let          | E.Prod e=> let
64              val(s,eps,dels,p)= F.filterGreek e              val(s,eps,dels,p)= F.filterGreek e

Legend:
Removed from v.2604  
changed lines
  Added in v.2605

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0