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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2507 - (download) (annotate)
Mon Nov 11 20:03:02 2013 UTC (5 years, 9 months ago) by cchiw
File size: 2616 byte(s)
add app-ein.sml to high-il
(* examples.sml
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

structure tApp = struct

    structure E = Ein
    structure P = Printer
    structure N=NormalizeEin
    structure A = App
    structure O=EinOp
    structure mk = mkOperators
 structure VarEin =  VarEin

val v=A.Var "V"
val f=A.Var "F"
val s=A.Var "s"
val b=A.Var "B"
val t=A.Var "T"
val g=A.Var "G"
val m=A.Var "M"
val I=A.Var "I"
val h=A.Var "h"

val Otrace=O.trace
val Oouter=O.outer
val Odiver=O.diver
val Ograd=O.grad
val Ocurl3d= mk.curl3d
val Ocross=O.cross
val Odot=O.dot
val OsTen=O.sTen
val OcrossA=O.crossA
val Ohessian=O.hessian
val Oconv=O.conv
val OaddF=O.addF
val OaddM=O.addM
val OaddT3=O.addT3

val trace=A.App1(Otrace,[m])
val outer=A.App1(Oouter,[t,g])
val diver=A.App1(Odiver,[v])
val grad= A.App1(Ograd,[f])

val curl3d= A.App1(Ocurl3d,[f])
val cross=A.App1(Ocross,[t,g])
val dot=A.App1(Odot,[t,g])
val sTen=A.App1(OsTen,[s,t])
val crossA=A.App1(OcrossA,[t,g])
val hessian=A.App1(Ohessian,[f])
val conv=A.App1(Oconv,[I,h])
val addF=A.App1(Oconv,[f,g])
val addF2=A.App1(Oconv,[s,v])
val addM=A.App1(OaddM,[f,g])

val S1a=A.App1(Odiver, [grad])
val S1b=A.App1(O.x, [b, grad,s])
val S1c=A.App1(Otrace,[hessian])

val S2=A.App1(Odiver,[curl3d])
val S3=A.App1(Ocurl3d,[ grad])
val S4=A.App1(Ocurl3d,[curl3d])

(*Trace of an OuterProduct*)
val S8a=A.App1(Otrace, [outer])
val S8b=A.App1(O.traceA,[ outer,v])
val S8c=A.App1(O.traceB,[b, outer,v])
val S9=A.App1(Otrace,[hessian])
(*cross product*)
val S10=A.App1(Ocross,[cross,v])
val S11=A.App1(Ocross, [b, cross])

(*inner products*)
val S15=A.App1(Odot,[v,cross])
val S16=A.App1(OsTen,[dot,v])
val id=A.App1(O.id, [])

val g=A.App1(OaddT3,[sTen,outer])

(*New Tests *)
val x1=A.App1(Ocross, [sTen,v])
val x2=A.App1(Ocross,[cross,v])
val x3=A.App1(Ocross,[b,sTen])
val x4=A.App1(Ocross,[v,cross])

val S17=A.App1(OaddF,[f,conv])
val S17b=A.App1(Ocurl3d, [conv])

val a=A.App1(OaddF, [ addF,grad])
val a2=A.App1(OaddM, [id,addM])

fun test e=let
    val line= "----------------------------------------------------------\n"
    val m = A.printStatement(e,"\t")
    val j=A.total(e)
    val l= A.printStatement(j,"\t")
    val A.App1(exp,_)=j
    val (n,_)=N.normalize(exp)
    val n'=P.printerE(n)
    in print (String.concat[line, m,"\n\n ==> \n", l,"\n","\n===>\n", n'])

val S1=[S1a, S1b, S1c]
val S=[S2,S3,S4, S10, S11, S15, S16]
val S8=[S8a, S8b, S8c,S9]
val x=[x1,x2,x3,x4]

val y= List.map test []
  end; (* local *)

    end (* local *)

ViewVC Help
Powered by ViewVC 1.0.0