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

SCM Repository

[diderot] Diff of /trunk/src/compiler/basis/basis-vars.sml
ViewVC logotype

Diff of /trunk/src/compiler/basis/basis-vars.sml

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

revision 2355, Sun Apr 7 11:35:08 2013 UTC revision 2356, Sun Apr 7 14:45:25 2013 UTC
# Line 70  Line 70 
70              in              in
71                [t, t] --> t                [t, t] --> t
72              end))              end))
73        val add_fr = polyVar(N.op_add, all([DK,NK], (* field + scalar *)
74              fn [Ty.DIFF k, Ty.DIM d] => let
75                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
76                in
77                  [t, Ty.realTy] --> t
78                end))
79        val add_rf = polyVar(N.op_add, all([DK,NK], (* scalar + field *)
80              fn [Ty.DIFF k, Ty.DIM d] => let
81                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
82                in
83                  [Ty.realTy, t] --> t
84                end))
85    
86      val sub_ii = monoVar(N.op_sub, [Ty.T_Int, Ty.T_Int] --> Ty.T_Int)      val sub_ii = monoVar(N.op_sub, [Ty.T_Int, Ty.T_Int] --> Ty.T_Int)
87      val sub_tt = polyVar(N.op_sub, all([SK], fn [Ty.SHAPE dd] => let      val sub_tt = polyVar(N.op_sub, all([SK], fn [Ty.SHAPE dd] => let
# Line 83  Line 95 
95              in              in
96                [t, t] --> t                [t, t] --> t
97              end))              end))
98        val sub_fr = polyVar(N.op_sub, all([DK,NK], (* field - scalar *)
99              fn [Ty.DIFF k, Ty.DIM d] => let
100                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
101                in
102                  [t, Ty.realTy] --> t
103                end))
104        val sub_rf = polyVar(N.op_sub, all([DK,NK], (* scalar - field *)
105              fn [Ty.DIFF k, Ty.DIM d] => let
106                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape[]}
107                in
108                  [Ty.realTy, t] --> t
109                end))
110    
111    (* note that we assume that operators are tested in the order defined here, so that mul_rr    (* note that we assume that operators are tested in the order defined here, so that mul_rr
112     * takes precedence over mul_rt and mul_tr!     * takes precedence over mul_rt and mul_tr!
# Line 151  Line 175 
175                      --> field(k, d, dd)                      --> field(k, d, dd)
176                  end))                  end))
177    
178      (* curl on 2d and 3d vector fields *)
179        local
180          val diff0 = Ty.DiffConst 0
181          fun field' (k, d, dd) = field(k, Ty.DimConst d, Ty.Shape(List.map Ty.DimConst dd))
182        in
183    (* FIXME: we want to be able to require that k > 0, but we don't have a way to do that! *)
184        val curl2D = polyVar (N.op_curl, all([DK],
185              fn [Ty.DIFF k] =>
186                [field' (Ty.DiffVar(k, 0), 2, [2])] --> field' (diff0, 2, [])))
187        val curl3D = polyVar (N.op_curl, all([DK],
188              fn [Ty.DIFF k] =>
189                [field' (Ty.DiffVar(k, 0), 3, [3])] --> field' (diff0, 2, [3])))
190        end (* local *)
191    
192      val lt_ii = monoVar(N.op_lt, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)      val lt_ii = monoVar(N.op_lt, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)
193      val lt_rr = monoVar(N.op_lt, [Ty.realTy, Ty.realTy] --> Ty.T_Bool)      val lt_rr = monoVar(N.op_lt, [Ty.realTy, Ty.realTy] --> Ty.T_Bool)
194      val lte_ii = monoVar(N.op_lte, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)      val lte_ii = monoVar(N.op_lte, [Ty.T_Int, Ty.T_Int] --> Ty.T_Bool)
# Line 290  Line 328 
328                  [Ty.T_Tensor(Ty.ShapeVar s1), Ty.T_Tensor(Ty.ShapeVar s2)]                  [Ty.T_Tensor(Ty.ShapeVar s1), Ty.T_Tensor(Ty.ShapeVar s2)]
329                    --> Ty.T_Tensor(Ty.ShapeVar s3)))                    --> Ty.T_Tensor(Ty.ShapeVar s3)))
330    
331      (* the colon (or double-dot) product operator is treated as a special case in the
332       * typechecker.  It is not included in the basis environment, but we define its type
333       * schemehere.  There is an implicit constraint on its type to have the following scheme:
334       *
335       *     ALL[sigma1, d1, d2, sigma2] .
336       *       tensor[sigma1, d1, d2] * tensor[d1, d2, sigma2] -> tensor[sigma1, sigma2]
337       *)
338        val op_colon = polyVar (N.op_colon, all([SK, SK, SK],
339                fn [Ty.SHAPE s1, Ty.SHAPE s2, Ty.SHAPE s3] =>
340                    [Ty.T_Tensor(Ty.ShapeVar s1), Ty.T_Tensor(Ty.ShapeVar s2)]
341                      --> Ty.T_Tensor(Ty.ShapeVar s3)))
342    
343      val fn_inside = polyVar (N.fn_inside, all([DK, NK, SK],      val fn_inside = polyVar (N.fn_inside, all([DK, NK, SK],
344              fn [Ty.DIFF k, Ty.DIM d, Ty.SHAPE dd] => let              fn [Ty.DIFF k, Ty.DIM d, Ty.SHAPE dd] => let
345                  val k = Ty.DiffVar(k, 0)                  val k = Ty.DiffVar(k, 0)
# Line 348  Line 398 
398      val fn_trace = polyVar (N.fn_trace, all([NK],      val fn_trace = polyVar (N.fn_trace, all([NK],
399              fn [Ty.DIM d] => [matrix(Ty.DimVar d)] --> Ty.realTy))              fn [Ty.DIM d] => [matrix(Ty.DimVar d)] --> Ty.realTy))
400    
401        val fn_transpose = polyVar (N.fn_transpose, all([NK, NK],
402                fn [Ty.DIM d1, Ty.DIM d2] =>
403                  [tensor[Ty.DimVar d1, Ty.DimVar d2]] --> tensor[Ty.DimVar d2, Ty.DimVar d1]))
404    
405    (* kernels *)    (* kernels *)
406  (* FIXME: we should really get the continuity info from the kernels themselves *)  (* FIXME: we should really get the continuity info from the kernels themselves *)
407      val kn_bspln3 = monoVar (N.kn_bspln3, Ty.T_Kernel(Ty.DiffConst 2))      val kn_bspln3 = monoVar (N.kn_bspln3, Ty.T_Kernel(Ty.DiffConst 2))
408      val kn_bspln5 = monoVar (N.kn_bspln5, Ty.T_Kernel(Ty.DiffConst 4))      val kn_bspln5 = monoVar (N.kn_bspln5, Ty.T_Kernel(Ty.DiffConst 4))
409        val kn_c4hexic = monoVar (N.kn_c4hexic, Ty.T_Kernel(Ty.DiffConst 4))
410      val kn_ctmr = monoVar (N.kn_ctmr, Ty.T_Kernel(Ty.DiffConst 1))      val kn_ctmr = monoVar (N.kn_ctmr, Ty.T_Kernel(Ty.DiffConst 1))
411      val kn_tent = monoVar (N.kn_tent, Ty.T_Kernel(Ty.DiffConst 0))      val kn_tent = monoVar (N.kn_tent, Ty.T_Kernel(Ty.DiffConst 0))
412    (* kernels with false claims of differentiability, for pedagogy *)    (* kernels with false claims of differentiability, for pedagogy *)

Legend:
Removed from v.2355  
changed lines
  Added in v.2356

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