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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/fields/test-kernel.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/fields/test-kernel.sml

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

revision 1949, Sat Jul 7 04:35:18 2012 UTC revision 1950, Sat Jul 7 19:03:02 2012 UTC
# Line 12  Line 12 
12      structure R = Rational      structure R = Rational
13      structure K = Kernel      structure K = Kernel
14    
15      fun eval ({isOdd, isCont, segs}, x) = let      fun eval ({isCont, segs}, x) = let
16              val nSegs = List.length segs
17              val minX = ~0.5 * real nSegs
18            fun eval' x = let            fun eval' x = let
19                  val {whole, frac} = Real.split x                  val {whole, frac} = Real.split(x - minX)
20                  val i = Real.trunc whole                  val i = Real.trunc whole
21                  fun evalPoly [] = 0.0                  fun evalPoly [] = 0.0
22                    | evalPoly (c::r) = R.toReal c + x * evalPoly r                    | evalPoly (c::r) = R.toReal c + x * evalPoly r
# Line 22  Line 24 
24                    evalPoly (List.nth(segs, i)) handle _ => 0.0                    evalPoly (List.nth(segs, i)) handle _ => 0.0
25                  end                  end
26            in            in
27              if (x >= 0.0) then eval' x              eval' x
             else if isOdd then ~(eval' (~x))  
             else eval' (~x)  
28            end            end
29    
30    
31      local      local
32      (* Path to Ploticus command *)      (* Path to Ploticus command *)
33        val plPath = "/usr/local/bin/pl"        val plPath = "/opt/local/bin/pl"
34        val env = [        val env = [
35                "PLOTICUS_PREFABS=/usr/local/src/ploticus/prefabs"                "PLOTICUS_PREFABS=/opt/local/share/ploticus/"
36              ];              ];
37      in      in
38      fun ploticus args outFn = let      fun ploticus args outFn = let
# Line 117  Line 117 
117            end            end
118    
119      fun printKernel (kern, k) = let      fun printKernel (kern, k) = let
120            val {isCont, isOdd, segs} = K.curve(kern, k)            val {isCont, segs} = K.curve(kern, k)
121            val name = if (k > 0)            val name = if (k > 0)
122                  then concat(K.name kern::List.tabulate(k, fn _ => "'"))                  then concat(K.name kern::List.tabulate(k, fn _ => "'"))
123                  else K.name kern                  else K.name kern
# Line 131  Line 131 
131            in            in
132              print(name ^ ":\n");              print(name ^ ":\n");
133              lp (0, segs);              lp (0, segs);
134              if (isOdd)              print(concat["  ", name, "(x) = -", name, "(-x) for x < 0\n"])
               then print(concat["  ", name, "(x) = -", name, "(-x) for x < 0\n"])  
               else print(concat["  ", name, "(x) = ", name, "(-x) for x < 0\n"])  
135            end            end
136    
137    end    end

Legend:
Removed from v.1949  
changed lines
  Added in v.1950

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