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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2414 - (download) (annotate)
Mon Aug 19 05:02:14 2013 UTC (6 years, 1 month ago) by cchiw
File size: 3913 byte(s)
(*Test Specialize transform function *)
structure  tSpecialize = struct

    structure G = GenericEin
    structure E = Ein
    structure S = Specialize
    structure EinOp = Operators
    structure P= Printer

val current=true
(* Change to true if to test this function*)

fun test e=  print (P.printerE e)

                (* Tensor Operations *)

val addition1T = S.transform(EinOp.addTensor, [[2]],[])

val additionT = S.transform(EinOp.addTensor, [[3]],[])
val addition2T = S.transform(EinOp.subTensor, [[3,4]],[])

val subtractionT = S.transform(EinOp.subTensor, [[3]],[])
val identityT=S.transform(EinOp.identity,[[3],[3]], [])

val traceT=S.transform(EinOp.trace,[[3]],[])
val scaleT=S.transform(EinOp.scaleTensor,[[3,3]],[])

val divideT=S.transform(EinOp.divideTensor,[[2,3]],[])
val transposeT=S.transform(EinOp.transpose,[[3],[4]],[])
val outerProductT=S.transform(EinOp.outerProduct,[[3],[3]],[])

                (*Inner Product*)

val dotProduct = S.transform(EinOp.innerProduct, [[],[],[3]],[])

val innerProduct1 = S.transform(EinOp.innerProduct, [[],[],[4]],[])

(*M2x3* Vec3  *)
val mxv = S.transform(EinOp.innerProduct, [[2],[],[3]],[])
(* Vec4 * Mat 4x2  *)

val vxm = S.transform(EinOp.innerProduct, [[],[2],[4]],[])
(*Mat 4*5 x Mat 5*6*)
val mxm = S.transform(EinOp.innerProduct, [[4],[6],[5]],[])
val m3xv = S.transform(EinOp.innerProduct,[[4,2],[],[3]],[])
val m3xm4= S.transform(EinOp.innerProduct,[[4,2],[5,6,7],[3]],[])

                (*Double Dot*)
(*Second rank tensor Ts:[5,6], and third rank tensor Tt:[7,8,9]*)
(* Tt:[5,6,9] Ts:[6,9] *)
val ddTtTs = S.transform(EinOp.doubleDot,[[5],[],[6],[9]],[])
(* Tt:[6,9] Ts:[6,9,8] *)
val ddTsTt = S.transform(EinOp.doubleDot,[[],[8],[6],[9]],[])
(* Tt:[7,6,9] Ts:[6,9,8] *)
val ddTtTt = S.transform(EinOp.doubleDot,[[7],[8],[6],[9]],[]);
(* Tt:[7,2,6,9] Ts:[6,9,8] *)
val ddTfTt=  S.transform(EinOp.doubleDot,[[7,2],[8],[6],[9]],[])

            (* Tensor Operations-- test Zeros *)
val additionT0 = S.transform(EinOp.addTensor, [[]],[])
val subtractionT0 = S.transform(EinOp.subTensor, [[]],[])
val scaleT0=S.transform(EinOp.scaleTensor,[[]],[])
val divideT0=S.transform(EinOp.divideTensor,[[]],[])

(*Still to do, convolution, probe, posimagespace, tenworldspace*)

(*Field Operations*)

val additionF= S.transform(EinOp.addField,[[2]],[[2],[2]])
val additionF1= S.transform(EinOp.addField,[[3]],[[3],[3]])
val additionF2= S.transform(EinOp.addField,[[]],[[],[]])
val additionF3= S.transform(EinOp.addField,[[]],[[5],[5]])

val subtractionF=S.transform(EinOp.subField,[[3]],[[3],[3]])
val scaleF= S.transform(EinOp.scaleField,[[3,4]],[[0],[3]])
val divideF=S.transform(EinOp.divideField,[[2]],[[3],[3]])

val gradientF=S.transform(EinOp.Grad,[[2]],[[3]])
val hessianF=S.transform(EinOp.Grad,[[3,3]],[[3]])
val divergenceF=S.transform(EinOp.Divergence,[[3]],[[3]])
val curlF= S.transform(EinOp.Curl,[[3],[3],[3]],[[3]])
val curl2F=S.transform(EinOp.Curl,[[0],[2],[2]],[[3]])

fun run tester=
        val t9=  [additionT,subtractionT,identityT,scaleT, divideT, transposeT,outerProductT,traceT]
        val t1=[scaleT]
        val zeros=[additionT0, subtractionT0, scaleT0, divideT0]
        val t2= [dotProduct,  mxv, vxm, mxm]
        val t3=[ddTtTs, ddTsTt, ddTtTt, ddTfTt]
        val f1=[additionF, subtractionF,scaleF,divideF]
        val f2=[gradientF,hessianF,divergenceF,curlF,curl2F]
        val addField=[additionF, additionF2, additionF3]
        val r=[additionT]
        if (tester=1) then List.map test t1
        else if (tester=2) then List.map test t2
        else if (tester=3) then List.map test t3
        else if(tester=0) then List.map test zeros
        else if(tester=4) then List.map test f1
        else if (tester=5) then List.map test f2
        else List.map test addField

val r=run 6

  end; (* local *)

    end (* local *)

ViewVC Help
Powered by ViewVC 1.0.0