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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2488 - (download) (annotate)
Mon Oct 21 19:20:12 2013 UTC (5 years, 10 months ago) by cchiw
File size: 3075 byte(s)
changes to expand Conv
(* examples.sml
 *
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

structure tExpandConv = struct

    local
    structure G = GenericEin
    structure E = Ein
    structure S = Specialize
    structure P = Printer
    structure ExpandConv=ExpandConv
    in
 


(*3-d Scalar Field*)
val s0 = ("3-d scalar Field ",E.EIN{
    params = [E.FLD 3,E.TEN],
    index = [E.IX 3],
    body= E.Probe(E.Conv(E.Field(0,[]),[]),E.Tensor(1,[E.V 0]))
})


(*3-d Vector Field*)
val v0 = ("3-d Vector Field ",E.EIN{
    params = [E.FLD 3],
    index = [E.IX 2, E.IX 3],
    body= E.Probe(E.Conv(E.Field(0,[E.V 0]),[]),E.Tensor(1,[E.V 1]))
})


(*grad  2-d Vector Field*)
val v1 = ("grad  3-d Vector Field ",E.EIN{
    params = [E.FLD 3],
    index = [E.IX 2,E.IX 3,E.IX 3],
    body= E.Probe(E.Conv(E.Field(0,[E.V 0]),[E.V 1]),E.Tensor(1,[E.V 2]))
})

(*grad  2-d Scalar Field*)
val s1 = ("grad  2-d Scalar Field ",E.EIN{
    params = [E.FLD 2, E.TEN],
    index = [E.IX 2,E.IX 2],
    body= E.Probe(E.Conv(E.Field(0,[]),[E.V 0]),E.Tensor(1,[E.V 1]))
})

(*Hessian 3-d Vector Field*)
val v2 = ("Hessian 3-d Vector Field",E.EIN{
    params = [E.FLD 3],
    index = [E.IX 2,E.IX 3, E.IX 3,E.IX 3],
    body= E.Probe(E.Conv(E.Field(0,[E.V 0]),[E.V 1,E.V 2]),E.Tensor(1,[E.V 3]))
    })

(*Hessian 3-d Scalar Field*)
val s2 = ("Hessian 3-d Scalar Field",E.EIN{
    params = [E.FLD 3,E.TEN ],
    index = [E.IX 3, E.IX 3,E.IX 3],
    body= E.Probe(E.Conv(E.Field(0,[]),[E.V 0,E.V 1]), E.Tensor(1,[E.V 2]))
})


(*
fun test(a,e)=(print a; (P.printerE e); print "=> \t"; (P.printerE(ExpandConv.expand(e)));print"\n")

(*)val u=List.map test[v0,v1,v2]*)
*)

val s = E.EIN{
    params = [E.FLD 3, E.TEN,E.FLD 3],
    index = [E.IX 3,E.IX 3],
    body= E.Sub(E.Probe(E.Conv(E.Field(0,[E.V 0]),[]),E.Tensor(1,[E.V 1])),
            E.Probe(E.Conv(E.Field(2,[E.V 0]),[]),E.Tensor(1,[E.V 1])))
}


val s2 = E.EIN{
    params = [E.FLD 2, E.TEN,E.FLD 2,E.FLD 2],
    index = [E.IX 3,E.IX 2],
    body= E.Sub(E.Probe(E.Conv(E.Field(3,[E.V 0]),[]),E.Tensor(1,[E.V 1])),
        E.Sub(E.Probe(E.Conv(E.Field(0,[E.V 0]),[]),E.Tensor(1,[E.V 1])),
        E.Probe(E.Conv(E.Field(2,[E.V 0]),[]),E.Tensor(1,[E.V 1])))
    )
}


val s3 = E.EIN{
    params = [E.FLD 2, E.TEN,E.FLD 2,E.FLD 2,E.TEN],
    index = [E.IX 3,E.IX 2],
    body= E.Sub(E.Probe(E.Conv(E.Field(3,[E.V 0]),[]),E.Tensor(4,[E.V 1])),
        E.Sub(E.Probe(E.Conv(E.Field(0,[E.V 0]),[]),E.Tensor(1,[E.V 1])),
        E.Probe(E.Conv(E.Field(2,[E.V 0]),[]),E.Tensor(1,[E.V 1]))))
    }


val s4 = E.EIN{
    params = [E.FLD 2, E.TEN,E.FLD 2,E.FLD 2,E.TEN],
    index = [E.IX 3,E.IX 2],
    body= E.Add[E.Probe(E.Conv(E.Field(3,[E.V 0]),[]),E.Tensor(4,[E.V 1])),
        E.Add[E.Probe(E.Conv(E.Field(0,[E.V 0]),[]),E.Tensor(1,[E.V 1])),
        E.Probe(E.Conv(E.Field(2,[E.V 0]),[]),E.Tensor(1,[E.V 1]))]]
}


fun test2(e)=((P.printerE e); print "=> \t"; (P.printerE(ExpandConv.expandEinOp(e,[])));print"\n")


val u1=List.map test2[s2,s3,s4]



  end; (* local *)

    end (* local *)

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