Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] Diff of /branches/ein16/synth/d2/symb/symb_fv2d1.diderot
 [diderot] / branches / ein16 / synth / d2 / symb / symb_fv2d1.diderot

# Diff of /branches/ein16/synth/d2/symb/symb_fv2d1.diderot

revision 4242, Thu Jul 21 14:43:40 2016 UTC revision 4243, Thu Jul 21 17:54:34 2016 UTC
# Line 21  Line 21
21
22  //-- field defined by coefficients --  //-- field defined by coefficients --
23  //-- single--  //-- single--
24  input vec3 base1 = [2, 0, 7];    // _, x, x*x  input vec3 base1 = [0, 0, 0];    // _, x, x*x
25  input vec3 base2 = [0, 9, 7];    // _, x, x*x  input vec3 base2 = [0, 0, 0];
26
27  function vec2 func(real x) {  input real scale = 1;
28
29    function tensor[2] func(real x) {
30
31      real a1 = base1[0];
32      real b1 = base1[1];      real a = base1[0];
33      real c1 = base1[2];      real b = base1[1];
34      real a2 = base2[0];      real c = base1[2];
35      real b2 = base2[1];      real d = base2[0];
36      real c2 = base2[2];      real e = base2[1];
37      vec2 ret = [0, 0];      real f = base2[2];
38
39        tensor[2] ret = [0,0];
40      if (0 == which) {      if (0 == which) {
41          ret= [a1+b1*x+c1*x*x,a2+b2*x+c2*x*x];          real ret1 = a+b*x+c*x*x;
42            real ret2 = d+e*x+f*x*x;
43            ret = [ret1,ret2];
44      }      }
45
46      else {      else {
47          print("Sorry, no function defined for which = ", which, "\n");          print("Sorry, no function defined for which = ", which, "\n");
48      }      }
# Line 45  Line 51
51  }  }
52
53  strand sample(int idx0) {  strand sample(int idx0) {
54      output tensor[2] out = [0.0,0.0];      output tensor[2] out = [0.0,0];
55      update {      update {
56          /* Diderot doesn't (currently) allow print statements from          /* Diderot doesn't (currently) allow print statements from
57          global initialization, so to print something once per          global initialization, so to print something once per
# Line 61  Line 67
67          print("dimension: 2\n");          print("dimension: 2\n");
68          print("sizes: 2 ", sz0, "\n");          print("sizes: 2 ", sz0, "\n");
69          print("kinds: 2-vector space \n");          print("kinds: 2-vector space \n");
70         // print("centers: cell\n");          print("centers: cell cell\n");
71          // NOTE: this assumes machine endianness          // NOTE: this assumes machine endianness
72          print("endian: little\n");          print("endian: little\n");
73          print("encoding: raw\n");          print("encoding: raw\n");
# Line 69  Line 75
75          // Diderot prints vectors like it parses them, e.g "[0.1,0.3]"          // Diderot prints vectors like it parses them, e.g "[0.1,0.3]"
76          // but this is not how orientation vectors are stored in the NRRD          // but this is not how orientation vectors are stored in the NRRD
77          // header, hence the need to print individual components          // header, hence the need to print individual components
78         // print("space directions: (", edge0, ")\n");          print("space directions: (", edge0, ")\n");
79          print("space origin: (", orig, ")\n");          print("space origin: (", orig, ")\n");
80          // NOTE: this assumes output filename is not explicitly set          // NOTE: this assumes output filename is not explicitly set
81          print("data file: out.nrrd\n");          print("data file: out.nrrd\n");

Legend:
 Removed from v.4242 changed lines Added in v.4243