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

SCM Repository

[diderot] Diff of /branches/charisee_dev/src/compiler/ein/printer.sml
ViewVC logotype

Diff of /branches/charisee_dev/src/compiler/ein/printer.sml

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

revision 3324, Tue Oct 20 05:22:52 2015 UTC revision 3472, Tue Dec 1 18:45:25 2015 UTC
# Line 10  Line 10 
10      fun iTos e=Int.toString e      fun iTos e=Int.toString e
11      fun intList l = String.concatWith "," (List.map iTos l)      fun intList l = String.concatWith "," (List.map iTos l)
12      fun handleIndex e= (case e      fun handleIndex e= (case e
13          of E.C(cx)=> String.concat["'",iTos(cx),"'"]          of E.C(cx,true)=> String.concat["'",iTos(cx),"'"]
14            | E.C(cx,false)=> String.concat["S",iTos(cx),"'"]
15          |  E.V(ix)=> iTos(ix)          |  E.V(ix)=> iTos(ix)
16      (*end case*))      (*end case*))
17      fun handleAlpha alpha= String.concat[String.concatWith "," (List.map handleIndex alpha)]      fun handleAlpha alpha= String.concat[String.concatWith "," (List.map handleIndex alpha)]
18      fun handleBeta(a,b)=String.concat["δ_(",handleIndex a, ",", handleIndex b,")"]      fun handleBeta(a,b)=String.concat["δ_(",handleIndex a, ",", handleIndex b,")"]
19      fun handleSumRange (mu,lb,ub)= String.concat[(handleIndex mu),"[",iTos(lb),"-",iTos(ub),"]"]      fun handleSumRange (mu,lb,ub)= String.concat[(handleIndex mu),"[",iTos(lb),"-",iTos(ub),"]"]
20        fun printbody b= (case b
21            of E.B(E.Const r) => iTos(r)
22      fun printbody term = (case term          | E.B(E.ConstR r) =>RationalEin.toString r
         of E.Const r => iTos(r)  
         | E.ConstR r =>RationalEin.toString r  
23          | E.Tensor(id, []) =>String.concat[" S",iTos(id)]          | E.Tensor(id, []) =>String.concat[" S",iTos(id)]
24          | E.Tensor(id, alpha) =>String.concat[" T",iTos(id),"_",handleAlpha alpha]          | E.Tensor(id, alpha) =>String.concat[" T",iTos(id),"_",handleAlpha alpha]
25            | E.G(E.Delta(ix)) =>  handleBeta ix
26            | E.G(E.Epsilon(ix, jx, kx)) => String.concat["ϵ_",iTos(ix), iTos(jx), iTos(kx)]
27            | E.G(E.Eps2(ix, jx)) => String.concat["ϵ_",iTos(ix), iTos(jx)]
28    
29          | E.Field(id, []) =>String.concat[" F",iTos(id)]          | E.Field(id, []) =>String.concat[" F",iTos(id)]
30          | E.Field(id, alpha) =>String.concat[" F",iTos(id),"_",handleAlpha alpha]          | E.Field(id, alpha) =>String.concat[" F",iTos(id),"_",handleAlpha alpha]
         | E.Krn(tid,[],pos) =>String.concat[" H ",iTos(tid)(*,"[",  (printbody pos),"]"*)]  
         | E.Krn(tid,betas,pos) => String.concat[" H",iTos(tid),"^{", String.concat (List.map handleBeta betas)(*,"} [",(printbody pos),"]"*)]  
         | E.Delta(ix) =>  handleBeta ix  
         | E.Value(ix)=> String.concat["_",iTos(ix),"_"]  
         | E.Epsilon(ix, jx, kx) => String.concat["ϵ_",iTos(ix), iTos(jx), iTos(kx)]  
         | E.Eps2(ix, jx) => String.concat["ϵ_",iTos(ix), iTos(jx)]  
         | E.Sum ([(v,_,_)],e1)=>String.concat[" Σ_",handleIndex v,"⋐" ,printbody e1,"⋑",handleIndex v]  
         | E.Sum (sumindex,e1)=>String.concat[" Σ_", String.concatWith ","(List.map handleSumRange sumindex),"⋐" ,printbody e1,"⋑"]  
         | E.Neg e1 => String.concat["-NEG-", printbody e1]  
31          | E.Lift e1 => String.concat["LIFT ⊢", printbody e1,"⊣"]          | E.Lift e1 => String.concat["LIFT ⊢", printbody e1,"⊣"]
32          | E.Add el => String.concat["(",String.concatWith "+" (List.map printbody el),")"]  
33          | E.Sub(e1, e2) => String.concat ["(",printbody(e1),"---- ",printbody(e2)]          | E.Conv(fid,alpha, tid ,[])=> String.concat["|v",iTos(fid),"_{",handleAlpha alpha, "}★h(",iTos(tid),")|"]
34   | E.Prod el => String.concat["{*{",String.concatWith "* " (List.map printbody el),"}*}"]          | E.Conv(fid,alpha, tid, beta)=> String.concat["|v",iTos(fid),"_{",handleAlpha alpha, "}★h(",iTos(tid),")dx_",handleAlpha beta,"}|"]
35          | E.Div(e1,e2) => String.concat ["(",printbody(e1),")/( ",printbody (e2),")"]   (*
36            | E.Conv _ => "F"
37     *)
38          | E.Partial alpha => String.concat["d/dx_",handleAlpha alpha]          | E.Partial alpha => String.concat["d/dx_",handleAlpha alpha]
39          | E.Apply(e1, e2)=> String.concat [ printbody(e1),"@{", printbody(e2),"} "]          | E.Apply(e1, e2)=> String.concat [ printbody(e1),"@{", printbody(e2),"} "]
40   (*   (*
41          | E.Conv(fid,alpha, tid ,[])=> String.concat["|v",iTos(fid),"_{",handleAlpha alpha, "}★h(",iTos(tid),")|"]          | E.Probe (e1,e2)=> String.concat [printbody(e1),"[", printbody(e2),"]"]
                 | E.Conv(fid,alpha, tid, [b0,b1])=> String.concat["|v",iTos(fid),"_{",handleAlpha alpha, "}★h2(",iTos(tid),")dx_",handleAlpha [b0,b1],"}|"]  
         | E.Conv(fid,alpha, tid, beta)=> String.concat["|v",iTos(fid),"_{",handleAlpha alpha, "}★h(",iTos(tid),")dx_",handleAlpha beta,"}|"]  
42   *)   *)
43           | E.Conv(fid,alpha, tid,[])=> String.concat["F_",handleAlpha alpha]           | E.Probe (e1,e2)=> String.concat ["Probe(",printbody(e1),")"]
44           | E.Conv(fid,alpha, tid, beta)=> String.concat["F_",handleAlpha alpha,"∇",handleAlpha beta]          | E.Value(ix)=> String.concat["_",iTos(ix),"_"]
45          | E.Probe (e1,e2)=> String.concat [printbody(e1)(*,"[", printbody(e2),"]"*)]          | E.Img (fid,alpha,pos)=> String.concat [" V", iTos(fid),"_",handleAlpha alpha,"[", (String.concatWith "," (List.map printbody pos)),"]"]
46          | E.Img (fid,alpha,pos)=> String.concat [" V", iTos(fid),"_",handleAlpha alpha,"["(*,          | E.Krn(tid,[],pos) =>String.concat[" H ",iTos(tid),"[",  (printbody pos),"]"]
47                  (String.concatWith "," (List.map printbody pos)),"]"*)]          | E.Krn(tid,betas,pos) => String.concat[" H",iTos(tid),"^{", String.concat (List.map handleBeta betas),"} [",(printbody pos),"]"]
48          | E.Sqrt e => String.concat[ "√(", printbody e ,")"]  
49          | E.PowInt(e,n1) => String.concat[  "(",printbody e ,")^",iTos n1]          | E.Sum ([(v,_,_)],e1)=>String.concat[" Σ_",handleIndex v,"⋐" ,printbody e1,"⋑",handleIndex v]
50          | E.PowReal(e,n1) => String.concat[ "(", printbody e ,")^",RationalEin.toString n1]          | E.Sum (sumindex,e1)=>String.concat[" Σ_", String.concatWith ","(List.map handleSumRange sumindex),"⋐" ,printbody e1,"⋑"]
51          | E.Cosine e=>  String.concat["Cosine(",printbody e ,")"]   (*
52          | E.ArcCosine e=> String.concat["ArcCosine(",printbody e ,")"]           | E.Sum (sumindex,e1)=>String.concat[" Σ",printbody e1,"⋑"]
53          | E.Sine e => String.concat["Sine(",printbody e ,")"]   *)
54          | E.ArcSine e => String.concat["ArcSine(",printbody e ,")"]          | E.Op1(E.Neg, e1) => String.concat["-NEG-", printbody e1]
55            | E.Op1(E.Sqrt ,e )=> String.concat[ "√(", printbody e ,")"]
56            | E.Op1(E.PowInt n1,e) => String.concat[  "(",printbody e ,")^",Int.toString n1]
57            | E.Op1(E.PowReal n1,e) => String.concat[ "(", printbody e ,")^",RationalEin.toString n1]
58            | E.Op1(E.PowEmb (sx,n),e)=>String.concat["POW(",printbody e,"^", iTos n,")"]
59            | E.Op1(E.Exp, e1)=> String.concat["E^(",printbody e1,")"]
60            | E.Op1(t,e)=>(case t
61                of  E.Cosine =>  String.concat["Cosine(",printbody e ,")"]
62                | E.ArcCosine => String.concat["ArcCosine(",printbody e ,")"]
63                | E.Sine  => String.concat["Sine(",printbody e ,")"]
64                | E.ArcSine  => String.concat["ArcSine(",printbody e ,")"]
65                | E.Tangent  => String.concat["Tangent(",printbody e ,")"]
66                | E.ArcTangent => String.concat["ArcTangent(",printbody e ,")"]
67                (*end case*))
68            | E.Op2(E.Sub,e1, e2) => String.concat ["(",printbody(e1),"---- ",printbody(e2)]
69            | E.Op2(E.Div,e1,e2) => String.concat ["(",printbody(e1),")/( ",printbody (e2),")"]
70     (*
71            | E.Opn(E.Add, el) => String.concat["(",String.concatWith "+" (List.map printbody el),")"]
72            | E.Opn(E.Prod, el) => String.concat["{*{",String.concatWith "* " (List.map printbody el),"}*}"]*)
73     | E.Opn(E.Add, el) => String.concat["Add(",String.concatWith "+" (List.map printbody el),")"]
74     | E.Opn(E.Prod, el) => String.concat["Prod<",String.concatWith "* " (List.map printbody el),">"]
75    
76          (* end case *))          (* end case *))
77    
78      (*printerE:EIN ->string*)      (*printerE:EIN ->string*)
# Line 74  Line 89 
89              | Param(_,_)=""              | Param(_,_)=""
90    
91          in          in
92             String.concat["-EIN-" (*,Param(params, 0)*)," <",printbody(body),">"," _{",Index(index,0),"} "]             String.concat["-EIN-" ,Param(params, 0)," <",printbody(body),">"," _{",Index(index,0),"} "]
93    
94          end          end
95    

Legend:
Removed from v.3324  
changed lines
  Added in v.3472

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