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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2521 - (download) (annotate)
Thu Jan 9 02:17:07 2014 UTC (5 years, 7 months ago) by cchiw
File size: 4775 byte(s)
Added type Checker
(* examples.sml
 *
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)

structure EinOp = struct

    local
   
    structure E = Ein
    in
 
 

val id=E.EIN{
params = [],
index = [3,3],
body = E.Delta(E.V(0), E.V(1))
}

val outer=E.EIN{
         params = [E.TEN 1, E.TEN 1], index =[3,3],
         body = E.Prod[E.Tensor(0, [E.V 0]), E.Tensor(1, [E.V 1])]
         }

val cross=E.EIN{
    params = [E.TEN 1, E.TEN 1], index =[3],
    body = E.Sum([(E.V 1,0,3), (E.V 2,0,3)],E.Prod[ E.Epsilon(0,1,2),E.Tensor(0, [E.V 1]), E.Tensor(1, [E.V 2])  ])
}

val dot=E.EIN{
    params = [E.TEN 1,E.TEN 1], index =[],
    body = E.Sum([(E.V 0, 0, 3)],E.Prod[E.Tensor(0, [E.V 0]),E.Tensor(1, [E.V 0])])
}

val sTen=E.EIN{
        params = [E.TEN 1,E.TEN 1], index =[3],
        body = E.Prod[E.Tensor(0, []),E.Tensor(1, [E.V 0])]
}


val trace=E.EIN{
         params = [E.TEN 1], index =[],
         body = E.Sum([(E.V 0, 0, 3)],E.Tensor(0, [E.V 0, E.V 0]))
         }

         
val traceA=E.EIN{
         params = [E.TEN 1,E.TEN 1], index =[],
         body = E.Add[E.Sum([(E.V 0, 0, 3)],E.Tensor(0, [E.V 0, E.V 0])),
            E.Tensor(1,[])]
         }
         
val traceB=E.EIN{
         params = [E.TEN 1,E.TEN 1,E.TEN 1], index =[],
         body = E.Add[E.Tensor(0,[]),E.Sum([(E.V 0, 0, 3)],E.Tensor(1, [E.V 0, E.V 0])),
         E.Tensor(2,[])]
         }
        

val grad=E.EIN{
         params = [E.FLD(3)], index =[3],
         body = E.Apply(E.Partial [E.V 0],E.Field(0, []))
         }

val conv=E.EIN{
        params = [E.FLD(3),E.TEN 1], index =[2],
        body = E.Conv(0,[E.V 0],1,[])
}

val addF=E.EIN{
params = [E.FLD(3),E.FLD(3)], index =[2],
body = E.Add[E.Field(0,[E.V 0]), E.Field(1,[E.V 0])]
}

val addT3=E.EIN{
    params = [E.TEN 1,E.TEN 1], index =[2,3],
    body = E.Add[E.Prod[E.Tensor(1,[E.V 0,E.V 1]),E.Tensor(0,[E.V 1])], E.Tensor(0,[E.V 0])]
}

val addM=E.EIN{
params = [E.FLD(3),E.FLD(3)], index =[3,3],
body = E.Add[E.Field(0,[E.V 0,E.V 1]), E.Field(1,[E.V 0,E.V 1])]
}

val diver = E.EIN{
         params = [E.FLD(3)], index =[3],
         body = E.Sum([(E.V 0,0,3)],E.Apply(E.Partial [E.V 0],E.Field(0, [E.V 0])))
         }
         
val x=E.EIN{
         params = [E.TEN 1,E.FLD(3),E.TEN 1], index =[3],
         body = E.Add[E.Tensor(0,[]),
            E.Sum([(E.V 0,0,3)],E.Apply(E.Partial [E.V 0],E.Field(1, [E.V 0]))),E.Tensor(2,[])]
         }
 
val hessian = E.EIN{
         params = [E.FLD(2)], index =[2,2],
         body = E.Apply(E.Partial [E.V 1,E.V 0],E.Field(0, []))
}

val zero = E.EIN{
params = [], index =[],
body = E.Const(0.0)
}

val y=E.EIN{
        params = [E.TEN 1,E.FLD(3),E.TEN 1,E.TEN 1,E.TEN 1], index =[3],
        body = E.Add[E.Tensor(0,[]),
                E.Sum([(E.V 1,0,3)],E.Apply(E.Partial [E.V 1],E.Field(1, [E.V 1]))),
                E.Sum([(E.V 1, 0, 3)], E.Prod[E.Tensor(2,[E.V 1]),E.Tensor(3,[E.V 1])]),
                E.Tensor(4,[E.V 0])]
        }

val z=E.EIN{
    params = [E.TEN 1,E.TEN 1], index =[],
    body = E.Add[E.Prod[E.Tensor(0, []),E.Tensor(1, [E.V 0])]]
    }

val b=E.EIN{
    params = [E.TEN 1,E.TEN 1,E.TEN 1,E.TEN 1], index =[3],
    body = E.Add[
        E.Sum([(E.V 1,0,3),(E.V 2,0,3)],E.Prod[E.Tensor(0, [E.V 1,E.V 2]),E.Tensor(1, [E.V 1,E.V 2,E.V 0])]),
     E.Sum([(E.V 1,0,3)],E.Prod[E.Tensor(2, [E.V 1]),E.Tensor(3, [E.V 1])])
        ]
}

(*inner>outer*)

val z=E.EIN{
    params = [E.TEN 1,E.TEN 1], index =[3],
    body = E.Sum([(E.V 1,0,3),(E.V 2,0,3)],E.Prod[E.Tensor(0, [E.V 1,E.V 2]),E.Tensor(1, [E.V 1,E.V 2,E.V 0])])
}


val c=E.EIN{
    params = [E.TEN 1,E.TEN 1,E.TEN 1,E.TEN 1,E.TEN 1], index =[],
    body =E.Prod[
        E.Sum([(E.V 1 ,0, 3),(E.V 2, 0, 3)],
        E.Prod[E.Epsilon(0,1,2),E.Tensor(0,[E.V 1]),E.Tensor(1,[E.V 2])]),
        E.Sum([(E.V 1 ,0, 3),(E.V 2, 0, 3),(E.V 3, 0,3)],
        E.Prod[E.Epsilon(0,1,2),E.Tensor(2,[E.V 1]),E.Tensor(3,[E.V 2]),E.Tensor(4,[E.V 3])])]
}

val x1=E.EIN{
    params = [E.TEN 1,E.TEN 1], index =[3],
    body = E.Prod[E.Tensor(0, [E.V 0]),E.Tensor(1, [])]
}


val crossA=E.EIN{
params = [E.TEN 1, E.TEN 1,E.TEN 1], index =[3],
body = E.Add[E.Tensor(0,[E.V 0]),E.Sum([(E.V 1,0,3), (E.V 2,0,3)],E.Prod[ E.Epsilon(0,1,2),E.Tensor(0, [E.V 1]), E.Tensor(1, [E.V 2])  ]),E.Tensor(2,[E.V 0])]
}


(*Straightforward examples with summation in outer expression*)

(*    Sig_12 EpS_012 T0_1 T1_2   cross*)
(*Sub in position 0*)
(*0a--No Summation Phase   cross,sten*)
(*0b--Summation Phase    cross, cross*)
(*Sub in position 1*)
(*1a--No Summation Phase...    cross, sten*)
(*1b--Summation Phase, cross,cross*)

(*More complicated terms *)
(*Add terms before and after previous examples to tests summation binding*)

  end; (* local *)

    end (* local *)

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