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

SCM Repository

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

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

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

revision 2405, Sun Jul 28 11:19:13 2013 UTC revision 2406, Wed Jul 31 04:52:12 2013 UTC
# Line 14  Line 14 
14  val current=true  val current=true
15  (* Change to true if to test this function*)  (* Change to true if to test this function*)
16    
17  fun test e= if (current=true) then print (P.printerE e)  fun test e=  print (P.printerE e)
             else print ("")  
18    
19    
 val addVec = S.transform(EinOp.addTensor, [(1,[3])])  
 val subVec = S.transform(EinOp.subTensor, [(1,[3])])  
20    
 val x= List.map test [addVec, subVec]  
21    
22                    (* Tensor Operations *)
23    val additionT = S.transform(EinOp.addTensor, [[3]])
24    val additionT0 = S.transform(EinOp.addTensor, [[0]])
25    val addition2T = S.transform(EinOp.subTensor, [[3,4]])
26    val subtractionT = S.transform(EinOp.subTensor, [[3]])
27    val identityT=S.transform(EinOp.identity,[[2],[2]])
28    val scaleT=S.transform(EinOp.scaleTensor,[[3,4]])
29    val scaleT0=S.transform(EinOp.scaleTensor,[[0,0]])
30    val divideT=S.transform(EinOp.divideTensor,[[2,3]])
31    val transposeT=S.transform(EinOp.transpose,[[3],[4]])
32    
33                    (*Inner Product*)
34  (*Vec3*Vec3*)  (*Vec3*Vec3*)
35  val dotProduct = S.transform(EinOp.innerProduct, [(0,[]),(0,[]),(0,[3])])  val dotProduct = S.transform(EinOp.innerProduct, [[],[],[3]])
36  val dotProduct4 = S.transform(EinOp.innerProduct, [(0,[]),(0,[]),(0,[4])])  val innerProduct1 = S.transform(EinOp.innerProduct, [[],[],[4]])
37    
38  (*M2x3* Vec3  *)  (*M2x3* Vec3  *)
39  val mxv = S.transform(EinOp.innerProduct, [(1,[2]),(0,[]),(0,[3])])  val mxv = S.transform(EinOp.innerProduct, [[2],[],[3]])
   
40  (* Vec4 * Mat 4x2  *)  (* Vec4 * Mat 4x2  *)
41  val vxm = S.transform(EinOp.innerProduct, [(0,[]),(1,[2]),(0,[4])])  val vxm = S.transform(EinOp.innerProduct, [[],[2],[4]])
   
42  (*Mat 4*5 x Mat 5*6*)  (*Mat 4*5 x Mat 5*6*)
43  val mxm = S.transform(EinOp.innerProduct, [(1,[4]),(1,[6]),(0,[5])])  val mxm = S.transform(EinOp.innerProduct, [[4],[6],[5]])
44    val m3xv = S.transform(EinOp.innerProduct,[[4,2],[],[3]])
45    val m3xm4= S.transform(EinOp.innerProduct,[[4,2],[5,6,7],[3]])
46    
47    
48                    (*Double Dot*)
49    (*Second rank tensor Ts:[5,6], and third rank tensor Tt:[7,8,9]*)
50    (* Tt:[5,6,9] Ts:[6,9] *)
51    val ddTtTs = S.transform(EinOp.doubleDot,[[5],[],[6],[9]])
52    (* Tt:[6,9] Ts:[6,9,8] *)
53    val ddTsTt = S.transform(EinOp.doubleDot,[[],[8],[6],[9]])
54    (* Tt:[7,6,9] Ts:[6,9,8] *)
55    val ddTtTt = S.transform(EinOp.doubleDot,[[7],[8],[6],[9]]);
56    (* Tt:[7,2,6,9] Ts:[6,9,8] *)
57    val ddTfTt=  S.transform(EinOp.doubleDot,[[7,2],[8],[6],[9]])
58    
 val m3xv = S.transform(EinOp.innerProduct,[(2,[4,2]),(0,[]),(0,[3])])  
 val m3xm4= S.transform(EinOp.innerProduct,[(2,[4,2]),(3,[5,6,7]),(0,[3])])  
59    
60    (*Didn't inclded*)
61    (* Outerproduct, dyadic proudtc*)
62    (*Still to do, convolution, probe*)
63    
 val sxv = S.transform(EinOp.scaleTensor, [(1,[3])])  
     (* scalar times vector *)  
64    
 val sxm = S.transform(EinOp.scaleTensor, [(2,[3,4])])  
     (* scalar times matrix *)  
65    
 (*Second rank tensor Ts:[5,6], and third rank tensor Tt:[7,8,9]*)  
66    
 (* Tt:[5,6,9] Ts:[6,9] *)  
 val ddTtTs = S.transform(EinOp.doubleDot,[(1,[5]),(0,[]),(0,[6]),(0,[9])])      (* T_0,1,2  T'_1,2 *)  
67    
68  (* Tt:[6,9] Ts:[6,9,8] *)  (*Field Operations*)
 val ddTsTt = S.transform(EinOp.doubleDot,[(0,[]),(1,[8]),(0,[6]),(0,[9])])  
     (* T_1,2      T'_1,2,0 *)  
69    
70  (* Tt:[7,6,9] Ts:[6,9,8] *)  val additionF= S.transform(EinOp.addField,[[4]])
71  val ddTtTt = S.transform(EinOp.doubleDot,[(1,[7]),(1,[8]),(0,[6]),(0,[9])]);     (*T_0,2,3     T'_2,3,1*)  val subtractionF=S.transform(EinOp.subField,[[3]])
72    val scaleF= S.transform(EinOp.scaleField,[[3,4]])
73    val divideF=S.transform(EinOp.divideField,[[2]])
74    
75  (* Tt:[7,2,6,9] Ts:[6,9,8] *)  val gradientF=S.transform(EinOp.Grad,[[2]])
76  val ddTfTt=  S.transform(EinOp.doubleDot,[(2,[7,2]),(1,[8]),(0,[6]),(0,[9])])  val hessianF=S.transform(EinOp.Grad,[[3,3]])
77    val divergenceF=S.transform(EinOp.Divergence,[[3]])
78    val curlF= S.transform(EinOp.Curl,[[3],[3],[3]])
79    val curl2F=S.transform(EinOp.Curl,[[0],[2],[2]])
80    
81    
82    fun run tester=
83        let
84            val t1=  [additionT,subtractionT,identityT,scaleT, divideT, transposeT]
85            val zeros=[additionT0,scaleT0]
86            val t2= [dotProduct,  mxv, vxm, mxm]
87            val t3=[ddTtTs, ddTsTt, ddTtTt, ddTfTt]
88            val f1=[additionF, subtractionF,scaleF,divideF]
89            val f2=[gradientF,hessianF,divergenceF,curlF,curl2F]
90        in
91    
92  val af= S.transform(EinOp.addField,[(1,[4])])          if (tester=1) then List.map test t1
93  val tc= S.transform(EinOp.trace, [(1,[3])])          else if (tester=2) then List.map test t2
94            else if (tester=3) then List.map test t3
95            else if(tester=0) then List.map test zeros
96            else if(tester=4) then List.map test f1
97            else List.map test f2
98    
99  val id2=S.transform(EinOp.identity,[(1,[3]),(1,[3])])      end
100    
101  (*val outerproductE= S.transform(EinOp.outerProduct,[(2,[3]),(1,[3])])  val r=run 5
 *)  
102    
 val gradE= S.transform(EinOp.Grad,[(1,[3])])  
 val divergenceE=S.transform(EinOp.Divergence,[(2, [4])])  
 (*  
 val traceE= S.transform(EinOp.trace, [(1,[3])])  
103    
104    
105    
106    
 val opS=S.transform(outerProduct, [])  
 val traceT=S.transform(trace,[])  
 val GradS=S.transform(Grad,[])  
 val DivergenceS=S.transform(Divergence,[])  
 val CurlS= S.transform(Curl,[])  
 *)  
107    
108    end; (* local *)    end; (* local *)
109    

Legend:
Removed from v.2405  
changed lines
  Added in v.2406

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