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 2414, Mon Aug 19 05:02:14 2013 UTC revision 2496, Tue Oct 29 05:29:46 2013 UTC
# Line 11  Line 11 
11    
12      fun intList l = String.concat[String.concatWith "," (List.map Int.toString l)]      fun intList l = String.concat[String.concatWith "," (List.map Int.toString l)]
13    
14      fun printerE (Ein.EIN{params, index, body}) = let      fun printIndex e= (case e
15            fun printer2 term = (case term          of E.C(cx)=> String.concat["'",Int.toString(cx),"'"]
16                   of E.Tensor(id, [])  => String.concat[" S",Int.toString(id)]          |  E.V(ix)=> Int.toString(ix)
17                    | E.Tensor(id, mx) =>  String.concat[" T",Int.toString(id),"_",intList(mx)]      )
18                    | E.Const e => Real.toString(e)  
19        fun printAlpha alpha= String.concat[String.concatWith "," (List.map printIndex alpha)]
20    
21    
22        fun handleBeta(a,b)=String.concat["Delta_(",printIndex a, ",", printIndex b,")"]
23    
24    
25              fun printbody term = (case term
26                of E.Const r => Real.toString(r)
27                | E.Tensor(id, []) =>String.concat[" S",Int.toString(id)]
28                | E.Tensor(id, alpha) =>String.concat[" T",Int.toString(id),"_",printAlpha alpha]
29                    | E.Field(id, []) => String.concat ["F",Int.toString(id)]                    | E.Field(id, []) => String.concat ["F",Int.toString(id)]
30                    | E.Field(id, mx) => String.concat ["F",Int.toString(id),"_",intList(mx)]              | E.Field(id, alpha) =>String.concat[" F",Int.toString(id),"_",printAlpha alpha]
31                    | E.Add e        => String.concat["(",String.concatWith "+" (List.map printer2 e),")"]  
32                    | E.Sub(a,b)      => String.concat ["(",printer2(a),"- ",printer2(b), ")"]  
33                    | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]              | E.Krn(tid,[],pos) =>String.concat["h ",Int.toString(tid),"[",  (printbody pos),"]"]
34                    | E.Prod e       => String.concatWith "*" (List.map printer2 e)  
35                    | E.Delta(i,j)    => String.concat [" Delta_",Int.toString(i),Int.toString(j)]              | E.Krn(tid,betas,pos) =>String.concat["h",Int.toString(tid),"^{",String.concat(List.map handleBeta betas),"} [",
36                    | E.Epsilon(i,j,k)=> String.concat ["E_",Int.toString(i),Int.toString(j),Int.toString(k) ]                  (printbody pos),"]"]
37                    | E.Conv(k,deltas) => let  
38                        val n= length(deltas)  
39                        fun imp([])=""              | E.Delta(ix) =>  handleBeta ix
40                        | imp([(i,j)])=  String.concat [" Delta_",Int.toString(i),Int.toString(j)]              | E.Value(ix)=> String.concat["_",Int.toString(ix),"_"]
41                        | imp((i,j)::es)= String.concat[" Delta_",Int.toString(i),Int.toString(j)," ",imp(es)]              | E.Epsilon(ix, jx, kx) => String.concat["E_",Int.toString(ix), Int.toString(jx), Int.toString(kx)]
42                        in              | E.Sum (alpha,e1)=> String.concat["\n \t Sigma:", printAlpha alpha," (", printbody e1,")"]
43                          String.concat ["V (*)",printer2(k),"{",imp(deltas),"}_",Int.toString(n)]              | E.Neg e1 => String.concat["-", printbody e1]
44                        end              | E.Add el => String.concat["(",String.concatWith "+" (List.map printbody el),")"]
45                    | E.Partial e  => String.concat ["d^",Int.toString(length(e)),"/dx_",intList(e)]              | E.Sub(e1, e2) => String.concat ["(",printbody(e1),"- ",printbody(e2), ")"]
46                    | E.Probe(a,b) => String.concat ["",printer2(a), "","@(", printer2(b),")"]              | E.Prod el => String.concat["{{",String.concatWith "* " (List.map printbody el),"}}"]
47                    | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]              | E.Div(e1,e2) => String.concat ["(",printbody(e1),"/ ",printbody (e2), ")"]
48                    | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]              | E.Partial alpha => String.concat["d/dx_",printAlpha alpha]
49                    | _ =>("newbie")              | E.Apply(e1, e2)=> String.concat [ printbody(e1),"@{", printbody(e2),"} "]
50    
51                | E.Conv(fid,alpha, tid ,[])=> String.concat["|V",Int.toString(fid),"_{",printAlpha alpha, "}★h|"]
52                | E.Conv(fid,alpha, tid, beta)=> String.concat["|V",Int.toString(fid),"_{",printAlpha alpha, "}★d/dx_{",printAlpha beta,"}h|"]
53    
54                | E.Probe (e1,e2)=> String.concat ["",printbody(e1), "","[", printbody(e2),"]"]
55                | E.Img (fid,alpha,pos)=> String.concat ["V", Int.toString(fid),"_",printAlpha alpha,"[",
56                    (String.concatWith "," (List.map printbody pos)),"]"]
57    
58    
59    
60                  (* end case *))                  (* end case *))
61            fun printerE (Ein.EIN{params, index, body}) = let
62            fun Index ((E.IX(dim))::i, count) = String.concat["(", Int.toString count,            fun Index ((E.IX(dim))::i, count) = String.concat["(", Int.toString count,
63                  " DIM:", Int.toString dim, ")", Index(i,count+1)]                  " DIM:", Int.toString dim, ")", Index(i,count+1)]
64              | Index ((E.SX(dim))::i, count) = String.concat[ "} {Summation:(",Int.toString(count),              | Index ((E.SX(lb,ub))::i, count) = String.concat[ "} {Summation:(",Int.toString(count),
65                  " DIM:",Int.toString(dim),")", Index(i,count+1)]                  " DIM:",Int.toString(lb),",", Int.toString(ub),")", Index(i,count+1)]
66              | Index (_, count) = ""              | Index (_, count) = ""
67          fun Param(E.TEN::param, i)=String.concat[Int.toString(i), ":TEN ", Param(param, i+1)]          fun Param(E.TEN::param, i)=String.concat[Int.toString(i), ":TEN ", Param(param, i+1)]
68              | Param(E.FLD(d)::param, i)= String.concat[Int.toString(i), ":FLD-", intList d," ",Param(param, i+1)]              | Param(E.FLD(d)::param, i)= String.concat[Int.toString(i), ":FLD-", Int.toString d," ",Param(param, i+1)]
69              | Param(_,_)=""              | Param(_,_)=""
70    
71            val str=String.concat ["\n\t" ,Param(params, 0)," \n \t <",printbody(body),">","\n \t _{",Index(index,0),"} \n "]
72              in              in
73                  String.concat ["\n",Param(params, 0),"\n<",printer2(body),">","_{",Index(index,0),"}\n"]              str
74              end              end
75    
76         (* fun printerApp(R.App(e,l))= printerE(e)         (* fun printerApp(R.App(e,l))= printerE(e)

Legend:
Removed from v.2414  
changed lines
  Added in v.2496

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