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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/einTest/testNormalize.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/einTest/testNormalize.sml

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

revision 2457, Tue Oct 8 19:14:09 2013 UTC revision 2458, Tue Oct 8 19:42:58 2013 UTC
# Line 5  Line 5 
5      structure E = Ein      structure E = Ein
6      structure P= Printer      structure P= Printer
7          structure N = NormalizeEin          structure N = NormalizeEin
8    (* structure ExN =ExamplesN*)      structure X =ExamplesN
9       structure equal=equal
10      in      in
11    
12    
13    
14  fun test(e)=   (print"------------------ " ; P.printerE(e); let val n=N.normalize(e) in (*P.printerE*) n end ;print" \n ------------------------")  (*
15    using product
16    F@(x)=> V*h @(x)
17    
18    (nabla F)@(x)=> (nabla conv) @(x)
19    (nabla conv) @(x)=> (v * nabla h )@ (x)
20    Probe(Conv...,x)
21    
22    using apply
23    (Apply(nabla, F))@(x)=>Apply(nabla, conv), (x)
24    Apply(nabla, conv ), (x)=> (v nabla h ),(x)
25    *)
26    
27    
28    
29    
30    
31    
32    
33    fun isEinEqual(E.EIN{params, index, body},body2)=equal.isEqual(body,body2)
34    
35    
36    
37    
38    fun test(e)=   (print"------------------ " ; P.printerE(e);
39        let val n=N.normalize(e) in n end )
40    
41    
42  fun create(b)= E.EIN{params=[], index=[], body=b}  fun create(b)= E.EIN{params=[], index=[], body=b}
43    
44    
 (*-----Test more complicated terms in Normalize Function:normalize.sml---------------*)  
 val R10=(E.Sum([E.V 0, E.V 1, E.V 2, E.V 3, E.V 4],E.Prod[E.Epsilon(0,1,2),E.Epsilon(0,3,4),E.Tensor(0,[E.V 3]), E.Tensor(1,[E.V 4]),E.Tensor(2,[E.V 1]), E.Tensor(3,[E.V 2]) ]))  
45    
 val R10b=(E.Sum([E.V 9, E.V 8, E.V 0, E.V 1, E.V 2, E.V 3, E.V 4],E.Prod[E.Epsilon(9,8,7),E.Epsilon(0,1,2),E.Epsilon(0,3,4),E.Tensor(0,[E.V 3]), E.Tensor(1,[E.V 4]),E.Tensor(2,[E.V 1]), E.Tensor(3,[E.V 2]) ]))  
46    
47  val R10c=(E.Sum([E.V 0, E.V 1, E.V 2, E.V 3, E.V 4],E.Prod[E.Epsilon(0,1,2),E.Epsilon(8,9,11),E.Epsilon(0,3,4),E.Tensor(0,[E.V 3]), E.Tensor(1,[E.V 4]),E.Tensor(2,[E.V 1]), E.Tensor(3,[E.V 2]) ]))  fun tester(e)=  List.map (fn(e1)=>
48        let val norm=test(create e1) in print" \n ------------------------"   end )    e
49    
 val R10d=(E.Sum([E.V 0, E.V 1, E.V 2, E.V 3, E.V 4],E.Prod[E.Epsilon(0,1,2),E.Epsilon(8,9,11),E.Epsilon(0,3,4),E.Tensor(0,[E.V 3]),E.Prod[E.Tensor(1,[E.V 4]),E.Add[E.Tensor(2,[E.V 1]), E.Tensor(3,[E.V 2]) ]] ]  ))  
50    
51    
 val R10e=E.Apply(E.Partial[E.V 1],E.Prod[E.Tensor(0,[E.V 3]), E.Tensor(1,[E.V 4]),E.Tensor(2,[E.V 1]), E.Tensor(3,[E.V 2]) ])  
52    
 val R10f=E.Sum([E.V 1],E.Apply(E.Partial[E.V 1],E.Prod[E.Delta(E.V 3,E.V 1),E.Tensor(0,[E.V 3]) ]))  
53    
54    
55  (*partial eps *)  fun testerEqual(e)=
56  val R10g=E.Sum([E.V 0, E.V 1, E.V 2, E.V 3],E.Apply(E.Partial[E.V 3,E.V 1,E.V 2],E.Prod[E.Epsilon(0,1,2),E.Delta(E.V 4,E.V 3),E.Tensor(0,[E.V 0]) ]))      List.map (fn(e1,e2)=>
57            let val einexp=(create e1)
58            val line="\n ------------------ "
59            val linep=(print line; P.printerE einexp)
60            val norm=N.normalize(einexp)
61            val seq=isEinEqual(norm,e2)
62            in (if(seq>0) then print "FAIL \n" else print "PASS \n")
63            end) e
64    
 val R10h=E.Sum([E.V 0, E.V 1, E.V 2, E.V 3],E.Apply(E.Partial[E.V 3,E.V 1,E.V 5],E.Prod[E.Epsilon(0,1,2),E.Delta(E.V 4,E.V 3),E.Tensor(0,[E.V 0]) ]))  
65    
66  fun run set=  
67    
68    
69    (*Test einexp *)
70    fun run (set)=
71       let       let
72          val base=[]          val base=[]
73    
74          val r0=List.map create[R10,R10b, R10c,R10d,R10e,R10f,R10g,R10h]      val r3=[X.R3b,X.R3c,X.R3d]
75  (*        val r1= List.map create [ExN.R1,ExN.R2,ExN.R3, ExN.R4,ExN.R5,ExN.R7, ExN.R8, ExN.R9]      val r1=[X.R1,X.R1b,X.R1c,X.R1d,X.R1e]
76                  (*Test R5 change eps to delts*)      val r2=[X.R2,X.R2b,X.R2c,X.R2d,X.R2e,X.R2f]
77          val r2= List.map create [ExN.R10, ExN.R10b,ExN.R10c,ExN.R10d, ExN.R10e, ExN.R10f]      val r4=[X.R4,X.R4b,X.R4c,X.R4d,X.R4e,X.R4f,X.R4g, X.R4h]
78                  (*dels*)      val r5=[X.R5,X.R5b]
79          val r3=List.map create [ExN.R11, ExN.R11b, ExN.R11c, ExN.R11d, ExN.R11e, ExN.R11f, ExN.R11g, ExN.R11h, ExN.R11i, ExN.R11j, ExN.R11k ,ExN.R11l, ExN.R11m, ExN.R11n, ExN.R11o ,ExN.R11p, ExN.R11q, ExN.R11r]      val r6=[X.R6,X.R6b,X.R6c,X.R6d,X.R6e]
80          val r4=List.map create [ExN.sR12,ExN.sR13,ExN.sR14, ExN.sR14b, ExN.sR14c]      val r7=[X.R7,X.R7b,X.R7c,X.R7d,X.R7e]
81        val r8=[X.R8,X.R8b,X.R8c,X.R8d,X.R8e]
82          val s1=  [ExN.dotGrad, ExN.dotCross,ExN.crossGrad,ExN.curlCurl]      val r9=[X.R9,X.R9b,X.R9c,X.R9d]
83          val s2=[ ExN.S6, ExN.S7]      val r10=[X.R10, X.R10b, X.R10c,X.R10d, X.R10e, X.R10f]
84          val s3=[ExN.S8,ExN.S9, ExN.S10,ExN.S11, ExN.S12]*)      val r13=[X.R13, X.R13b, X.R13c]
85    
86        val r=   if(set=1) then r1
87            else if(set=2) then r2
88            else if(set=3) then r3
89            else if(set=4) then r4
90            else if(set=5) then r5
91            else if(set=6) then r6
92            else if(set=7) then r7
93            else if(set=8) then r8
94            else if(set=9) then r9
95            else if(set=10) then r10
96            else if(set=13) then r13
97            else  base
98        in
99            tester r
100        end
101    
102    
103    
104    
105    (*Test Nnormalize, against should be answer*)
106    fun runEqual (set)=
107         let
108            val base=[]
109            val r3=[X.R3]
110            val r=if(set=3) then r3
111                else base
112    
113      in      in
114          List.map test r0        testerEqual r
        (* if(set=0) then List.map test base  
         else if(set=1) then List.map test r1  
         else if(set=2) then List.map test r2  
         else if(set=3) then List.map test r3  
         else if(set=4) then List.map test r4  
   
         else if(set=5) then List.map test s1  
         else if(set=6) then List.map test s2  
         else if(set=7) then List.map test s3  
         else List.map test base*)  
115      end      end
116    
117  val r=run 2  
118    (*Run test on normalzie*)
119    val r1=run 10
120    val r2=run 13
121    val r3=runEqual 0
122    
123    
124    

Legend:
Removed from v.2457  
changed lines
  Added in v.2458

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