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

SCM Repository

[diderot] Diff of /branches/pure-cfg/test/derivs2.diderot
ViewVC logotype

Diff of /branches/pure-cfg/test/derivs2.diderot

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

revision 959, Sat Apr 23 15:28:33 2011 UTC revision 961, Sat Apr 23 19:32:22 2011 UTC
# Line 5  Line 5 
5  // reconstruct quadratic functions, so this is a good test case.  // reconstruct quadratic functions, so this is a good test case.
6  //  //
7  // Can output image of errors in reconstructed values, or reconstructed  // Can output image of errors in reconstructed values, or reconstructed
8  // gradients, according to which of (1) of (2) is uncommented below.  // gradients, according to which of (1), (2), (3) is uncommented below.
9  // In other case, output is processed with:  // In other case, output is processed with:
10  //  //
11  // unu reshape -i mip.txt -s 3 300 300 | unu quantize -b 8 -min 0 -max 1 -o derivs2.png  // unu reshape -i mip.txt -s 3 300 300 | unu quantize -b 8 -min 0 -max 1 -o derivs2.png
# Line 15  Line 15 
15    
16  // F: full isotropic resolution  // F: full isotropic resolution
17  image(2)[] Fimg = load ("../data/parab/parab2-150.nrrd");  image(2)[] Fimg = load ("../data/parab/parab2-150.nrrd");
18  field#1(2)[] F = Fimg ⊛ ctmr;  field#1(2)[] F0 = Fimg ⊛ ctmr;
19    field#2(2)[] F = Fimg ⊛ bspln3;
20    
21  // FX: one fifth as many samples along X  // FX: one fifth as many samples along X
22  image(2)[] FXimg = load ("../data/parab/parab2-x30.nrrd");  image(2)[] FXimg = load ("../data/parab/parab2-x30.nrrd");
23  field#1(2)[] FX = FXimg ⊛ ctmr;  field#1(2)[] F0X = FXimg ⊛ ctmr;
24    field#2(2)[] FX = FXimg ⊛ bspln3;
25    
26  // FY: one fifth as many samples along Y  // FY: one fifth as many samples along Y
27  image(2)[] FYimg = load ("../data/parab/parab2-y30.nrrd");  image(2)[] FYimg = load ("../data/parab/parab2-y30.nrrd");
28  field#1(2)[] FY = FYimg ⊛ ctmr;  field#1(2)[] F0Y = FYimg ⊛ ctmr;
29    field#2(2)[] FY = FYimg ⊛ bspln3;
30    
31  int imgSize = 300;  int imgSize = 300;
32  strand sample (int xi, int yi) {  strand sample (int xi, int yi) {
# Line 31  Line 34 
34      real yy = lerp(-50.0, 50.0, 0.0, real(yi), real(imgSize-1));      real yy = lerp(-50.0, 50.0, 0.0, real(yi), real(imgSize-1));
35      vec2 p = [xx,yy];      vec2 p = [xx,yy];
36      real f = xx^2 + yy^2;     // analytic parabola function      real f = xx^2 + yy^2;     // analytic parabola function
37      vec2 g = [2.0*xx,2.0*yy]; // analytic gradient of parabola      vec2 g = [2.0*xx,2.0*yy];              // analytic gradient
38        tensor[2,2] h = [[2.0,0.0],[0.0,2.0]]; // analytic hessian
39      output vec3 val = [0.0,0.0,0.0];      output vec3 val = [0.0,0.0,0.0];
40      update {      update {
41    
42          // Uncomment one of the following:          // Uncomment one of the following:
43    
44          // (1) These are the errors in the values          // (1) These are the errors in the values (this works fine)
45          //val = [|F(p)-f|, |FX(p)-f|, |FY(p)-f|];          // This works fine; here as a sanity check
46            //val = [|F0(p)-f|, |F0X(p)-f|, |F0Y(p)-f|];
47    
48          // (2) These are magnitudes of the errors in the gradients          // (2) These are magnitudes of the errors in the gradients
49          val = [|∇F(p)-g|, |∇FX(p)-g|, |∇FY(p)-g|];          //val = [|∇F(p)-g|, |∇FX(p)-g|, |∇FY(p)-g|];
50    
51            // (3) Magnitudes of errors in Hessians
52            // The "/50.0" because of greater numerical error in the
53            // second derivatives, which may warrant further study
54            //val = [|∇(∇F)(p)-h|, |∇(∇FX)(p)-h|, |∇(∇FY)(p)-h|]/50.0;
55    
56          stabilize;          stabilize;
57      }      }

Legend:
Removed from v.959  
changed lines
  Added in v.961

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