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

SCM Repository

[diderot] View of /branches/charisee/src/compiler/ein/hash-ein.sml
ViewVC logotype

View of /branches/charisee/src/compiler/ein/hash-ein.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2867 - (download) (annotate)
Tue Feb 10 06:52:58 2015 UTC (4 years, 5 months ago) by cchiw
File size: 1363 byte(s)
moved split around, added norm to typechecker, added sqrt to ein
(*hash Ein operator*)
structure hashEin = struct
    local
    structure E = Ein
    in

    (*hasfn:EIN->hash value
    *hash value of the expression
    *)
    fun hashfn(Ein.EIN{body,...})= let
        val changed =ref false
        fun hash body =let
            fun iter[e]=hash e
              | iter(e1::es)=hash e1+iter es
            in (case body
                of E.Const _ =>  0w3
                | E.Tensor _=>  0w5
                | E.Field _ =>  0w7
                | E.Krn _ =>  0w11
                | E.Delta _ =>  0w13
                | E.Value _ =>  0w17
                | E.Epsilon _=> 0w19
                | E.Eps2 _    => 0w71
                | E.Partial _ =>  0w23
                | E.Conv _=> 0w29
                | E.Sum(c,e)=> 0w31+ hash e
                | E.Neg e =>  0w37+ hash e
                | E.Lift e =>  0w71+ hash e
                | E.Sqrt e =>  0w73+ hash e
                | E.Add es =>0w41+iter es
                | E.Sub(e1,e2) =>  0w43+iter[e1,e2] 
                | E.Div(e1,e2)=>  0w47+iter[e1,e2] 
                | E.Apply(e1,e2)=>  0w53+iter[e1,e2] 
                | E.Probe(e1,e2)=>  0w5+iter[e1,e2] 
                | E.Img (fid,alpha,es) => 0w61+iter es
                | E.Prod es=> 0w67+iter es
                (*end case*))
            end
        in
            hash body
        end

end (* local *)

end 

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