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 2424, Mon Sep 16 14:57:35 2013 UTC revision 2426, Mon Sep 16 20:16:19 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 printIndex e= (case e
15            of E.c(cx)=> String.concat["c-",Int.toString(cx)]
16            |  E.m([ix])=> Int.toString(ix)
17            |  E.m(mx)=> intList(mx)
18        )
19        fun imp([])=""
20        | imp([(i,j)])=  String.concat [" Delta_",printIndex(i),printIndex(j)]
21        | imp((i,j)::es)= String.concat[" Delta_",printIndex(i),printIndex(j)," ",imp(es)]
22    
23    
24      fun printerE (Ein.EIN{params, index, body}) = let      fun printerE (Ein.EIN{params, index, body}) = let
25            fun printer2 term = (case term            fun printer2 term = (case term
26                   of E.Value(id)=> String.concat[" CI-",Int.toString(id)]                   of E.Value(id)=> String.concat[" CI-",Int.toString(id)]
27                      | E.Tensor(id, E.m([])) =>String.concat[" S",Int.toString(id)]
28                    | E.Tensor(id, E.c mx) =>  String.concat[" T",Int.toString(id),"_",Int.toString(mx)]                    | E.Tensor(id, ix) =>String.concat[" T",Int.toString(id),"_",printIndex ix]
                   | E.Tensor(id, E.m [])  => String.concat[" S",Int.toString(id)]  
                   | E.Tensor(id, E.m mx) =>  String.concat[" T",Int.toString(id),"_",intList(mx)]  
29                    | E.Pair e => String.concat["(",String.concatWith "," (List.map printer2 e),")"]                    | E.Pair e => String.concat["(",String.concatWith "," (List.map printer2 e),")"]
30                    | E.Const e => Real.toString(e)                    | E.Const e => Real.toString(e)
31                    | E.Field(id, [],[]) => String.concat ["F",Int.toString(id)]                    | E.Field(id, E.m [],E.m []) => String.concat ["F",Int.toString(id)]
32                    | E.Field(id, mx,[]) => String.concat ["F",Int.toString(id),"_",intList(mx)]                    | E.Field(id, mx,dx) => String.concat ["F",Int.toString(id),"_",printIndex(mx),",",printIndex(dx)]
                   | E.Field(id, [],dx) => String.concat ["F,",Int.toString(id),",",intList(dx)]  
                   | E.Field(id, mx,dx) => String.concat ["F",Int.toString(id),"_",intList(mx),",",intList(dx)]  
33    
34                    | E.Add e        => String.concat["(",String.concatWith "+" (List.map printer2 e),")"]                    | E.Add e        => String.concat["(",String.concatWith "+" (List.map printer2 e),")"]
35                    | E.Sub(a,b)      => String.concat ["(",printer2(a),"-",printer2(b), ")"]                    | E.Sub(a,b)      => String.concat ["(",printer2(a),"-",printer2(b), ")"]
36                    | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]                    | E.Div(a,b)      => String.concat ["(",printer2(a),"/ ",printer2(b), ")"]
37                    | E.Prod [e1,e2,e3]       => String.concatWith "*" (List.map printer2 [e1,e2,e3])                    | E.Prod [e1,e2,e3]       => String.concatWith "*" (List.map printer2 [e1,e2,e3])
38                    | E.Prod e       => String.concatWith "^^" (List.map printer2 e)                    | E.Prod e       => String.concatWith "^^" (List.map printer2 e)
39                    | E.Delta(i,j)    => String.concat [" Delta_",Int.toString(i),Int.toString(j)]                    | E.Delta(dels)  => imp(dels)
40                    | E.Epsilon(i,j,k)=> String.concat ["E_",Int.toString(i),Int.toString(j),Int.toString(k) ]                    | E.Epsilon(i,j,k)=> String.concat ["E_",Int.toString(i),Int.toString(j),Int.toString(k) ]
41                    | E.Conv(k,deltas) => let                    | E.Conv(k,[]) => String.concat ["V (*)",printer2(k)]
42                        val n= length(deltas)                    | E.Conv(k,[E.Delta(dels)]) => let
43                        fun imp([])=""                         val n= length(dels)
                       | imp([(i,j)])=  String.concat [" Delta_",Int.toString(i),Int.toString(j)]  
                       | imp((i,j)::es)= String.concat[" Delta_",Int.toString(i),Int.toString(j)," ",imp(es)]  
44                        in                        in
45                          String.concat ["V (*)",printer2(k),"{",imp(deltas),"}_",Int.toString(n)]                          String.concat ["V (*)",printer2(k),"^",Int.toString(n),"{",imp(dels),"}"]
46                        end                        end
47                    | E.Partial e  => String.concat ["d^",Int.toString(length(e)),"/dx_",intList(e)]                    | E.Conv(k,_) => "Incorrect convolution argument"
48                      | E.Partial(E.c(ix)) => String.concat ["d^1","/dx_",Int.toString(ix)]
49                      | E.Partial(E.m(mx))  => String.concat ["d^",Int.toString(length(mx)),"/dx_",intList(mx)]
50                    | E.Probe(a,b) => String.concat ["",printer2(a), "","@", printer2(b)]                    | E.Probe(a,b) => String.concat ["",printer2(a), "","@", printer2(b)]
51                    | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]                    | E.Apply(a,b) => String.concat [ printer2(a)," ", printer2(b)," "]
52                    | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]                    | E.Sum (id,a) => String.concat [" Sigma:", Int.toString(id), " ",printer2(a)]

Legend:
Removed from v.2424  
changed lines
  Added in v.2426

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