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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/basis/math-funs.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/basis/math-funs.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/vis12/src/compiler/IL/il-basis.sml revision 1921, Fri Jun 8 13:22:03 2012 UTC branches/vis12/src/compiler/basis/math-funs.sml revision 1922, Sat Jun 23 11:25:39 2012 UTC
# Line 1  Line 1 
1  (* il-basis.sml  (* math-funs.sml
2   *   *
3   * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)   * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *   *
6   * These are functions that the various IL optimization passes treat as   * These are a subset of the C math functions, which the various IL optimization passes
7   * "black boxes", so we do not need to have a separate operator constructor   * treat as "black boxes", so we do not need to have a separate operator constructor
8   * for each.   * for each.
9   *)   *)
10    
11  structure ILBasis :> sig  structure MathFuns :> sig
12    
13      type name      type name
14    
15        val toAtom : name -> Atom.atom
16      val toString : name -> string      val toString : name -> string
17      val same : name * name -> bool      val same : name * name -> bool
18      val hash : name -> word      val hash : name -> word
19    
20    (* Basis function *)    (* number of arguments; all args are real and result is a real *)
21      val atan2 : name      val arity : name -> int
     val cos : name  
     val fmod : name  
     val log10 : name  
     val ln : name  
     val pow : name  
     val sin : name  
     val sqrt : name  
     val tan : name  
22    
23      (* Basis functions *)
24        val pow : name
25      val allFuns : name list      val allFuns : name list
26    
     structure Set : ORD_SET where type Key.ord_key = name  
     structure Map : ORD_MAP where type Key.ord_key = name  
27      structure Tbl : MONO_HASH_TABLE where type Key.hash_key = name      structure Tbl : MONO_HASH_TABLE where type Key.hash_key = name
28    
29    end = struct    end = struct
30    
31      type name = Atom.atom      datatype name = N of Atom.atom * int
32    
33      val toString = Atom.toString      fun toAtom (N(f, _)) = f
34      val same = Atom.same      fun toString (N(f, _)) = Atom.toString f
35      val hash = Atom.hash      fun same (N(f1, _), N(f2, _)) = Atom.same(f1, f2)
36        fun hash (N(f, _)) = Atom.hash f
37    
38    (* Basis functions (in alphabetical order). The names used here are from the C math.h      fun arity (N(_, n)) = n
    * API, so they may differ from the Diderot names.  
    *)  
     val atan2 = Atom.atom "atan2"  
     val cos = Atom.atom "cos"  
     val fmod = Atom.atom "fmod"  
     val log10 = Atom.atom "log10"  
     val ln = Atom.atom "log"            (* Diderot name is "ln", C name is "log" *)  
     val pow = Atom.atom "pow"  
     val sin = Atom.atom "sin"  
     val sqrt = Atom.atom "sqrt"  
     val tan = Atom.atom "tan"  
39    
40      (* Basis functions (in alphabetical order). The names used here are from the C math.h API *)
41        val pow = N(Atom.atom "pow", 2)
42      val allFuns = [      val allFuns = [
43              atan2, cos, fmod, log10, ln, pow, sin, sqrt, tan              N(Atom.atom "acos", 1),
44                N(Atom.atom "asin", 1),
45                N(Atom.atom "atan", 1),
46                N(Atom.atom "atan2", 2),
47                N(Atom.atom "cos", 1),
48                N(Atom.atom "fmod", 2),
49                N(Atom.atom "log", 1),
50                N(Atom.atom "log10", 1),
51                pow,                        (* also used to implement ^ operator *)
52                N(Atom.atom "sin", 1),
53                N(Atom.atom "sqrt", 1),
54                N(Atom.atom "tan", 1)
55            ]            ]
56    
57      structure Set = AtomSet      structure Tbl = HashTableFn (
58      structure Map = AtomMap        struct
59      structure Tbl = AtomTable          type hash_key = name
60            val hashVal = hash
61            val sameKey = same
62          end)
63    
64    end    end

Legend:
Removed from v.1921  
changed lines
  Added in v.1922

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