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

SCM Repository

[diderot] Diff of /branches/fem/examples/iso_d2s/iso_d2s.diderot
ViewVC logotype

Diff of /branches/fem/examples/iso_d2s/iso_d2s.diderot

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

revision 3233, Tue Aug 11 15:07:12 2015 UTC revision 3234, Fri Aug 14 13:35:44 2015 UTC
# Line 16  Line 16 
16  input int imgResU;// = 150;  input int imgResU;// = 150;
17  input int imgResV;  input int imgResV;
18  input int stepsMax;//=10;  input int stepsMax;//=10;
19  real epsilon = 0.000001;  real epsilon = 0.001;
20    real stepSize= 0.01;
21    
22  strand RootFind(int ui,int vi) {  strand RootFind(int ui,int vi) {
23     real xi= lerp(0, 1, -0.5, ui, imgResU-0.5);     output vec2 out = [ui,imgResV-vi]*stepSize;
    real xj= lerp(0, 1, -0.5, vi, imgResV-0.5);  
    output vec2 out = [xi,xj];  
24     int steps = 0;     int steps = 0;
25     update {     update {
26        // Stop if we're no longer inside or taken too many steps.        // Stop if we're no longer inside or taken too many steps.
# Line 29  Line 28 
28           die;           die;
29        vec2 grad = ∇F(out);        vec2 grad = ∇F(out);
30        // subsequent expressions are undefined if |∇F| is zero        // subsequent expressions are undefined if |∇F| is zero
31        if (| ∇F(out)| == 0.0)        if (|grad| == 0.0)
32           die;           die;
33        // the Newton-Raphson step        // the Newton-Raphson step
34        vec2 delta = normalize( ∇F(out)) * F(out)/| ∇F(out)|;        vec2 delta = normalize(grad) * F(out)/|grad|;
35        // we've converged if the change is small enough        // we've converged if the change is small enough
36        if (|delta| < epsilon)        if (|delta| < epsilon)
37           stabilize;           stabilize;
38        out -= delta;        out -=  delta*stepSize;
39        steps += 1;        steps += 1;
40     }     }
41  }  }

Legend:
Removed from v.3233  
changed lines
  Added in v.3234

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