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 2406 - (download) (annotate)
Wed Jul 31 04:52:12 2013 UTC (6 years, 1 month ago) by cchiw
File size: 3106 byte(s)
FIx printing
(*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 additionT = S.transform(EinOp.addTensor, [[3]])
val additionT0 = S.transform(EinOp.addTensor, [[0]])
val addition2T = S.transform(EinOp.subTensor, [[3,4]])
val subtractionT = S.transform(EinOp.subTensor, [[3]])
val identityT=S.transform(EinOp.identity,[[2],[2]])
val scaleT=S.transform(EinOp.scaleTensor,[[3,4]])
val scaleT0=S.transform(EinOp.scaleTensor,[[0,0]])
val divideT=S.transform(EinOp.divideTensor,[[2,3]])
val transposeT=S.transform(EinOp.transpose,[[3],[4]])

                (*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]])

(*Didn't inclded*)
(* Outerproduct, dyadic proudtc*)
(*Still to do, convolution, probe*)

(*Field Operations*)

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

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

fun run tester=
        val t1=  [additionT,subtractionT,identityT,scaleT, divideT, transposeT]
        val zeros=[additionT0,scaleT0]
        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]
        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 List.map test f2

val r=run 5

  end; (* local *)

    end (* local *)

ViewVC Help
Powered by ViewVC 1.0.0