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

SCM Repository

[diderot] Annotation of /benchmarks/programs/ridge3d/bmark-diderot.diderot
ViewVC logotype

Annotation of /benchmarks/programs/ridge3d/bmark-diderot.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1582 - (view) (download)

1 : glk 1582
2 :     int gridSize = 120;
3 :     field#2(3)[] F = bspln3 ⊛ load("../../data/lungcrop.nrrd");
4 :     input int stepsMax = 20;
5 :     input real epsilon = 0.005;
6 :     real travelMax = 5.0;
7 :    
8 :     strand sample (int ui, int vi, int wi) {
9 :     output vec3 pos = [lerp(21.6401, 21.6401 + 140.0*0.5,
10 :     -0.5, real(ui), real(gridSize)-0.5),
11 :     lerp(-175.8792, -175.8792 + 200.0*0.5,
12 :     -0.5, real(vi), real(gridSize)-0.5),
13 :     lerp(-188.0000, -188.0000 + 140.0*0.5,
14 :     -0.5, real(wi), real(gridSize)-0.5)];
15 :     int steps = 0;
16 :     real travel = 0.0;
17 :     update {
18 :     if (!inside(pos, F) || steps > stepsMax || travel > travelMax) {
19 :     die;
20 :     }
21 :     real gmag = |∇F(pos)|;
22 :     if (gmag == 0.0) { // can't compute step if |∇F|, so have to bail
23 :     die;
24 :     }
25 :     vec3 grad = ∇F(pos);
26 :     tensor[3,3] hess = ∇⊗∇F(pos);
27 :    
28 :    
29 :     real{3} eval = evals(hess);
30 :     real strn = -eval{2};
31 :     vec3{3} evec = evecs(hess);
32 :     vec3 dir = normalize((evec{2}⊗evec{2} + evec{1}⊗evec{1})•grad);
33 :     /*
34 :     vec3 dir = normalize(grad);
35 :     real strn = 0.0;
36 :     */
37 :    
38 :     real fdd = grad•dir;
39 :     real sdd = dir•hess•dir;
40 :     vec3 delta = (0.1 if sdd >= 0.0 else -fdd/sdd)*dir;
41 :     if (|delta| < epsilon) {
42 :     if (strn >= 300.0) {
43 :     stabilize;
44 :     }
45 :     die;
46 :     }
47 :     // BUG: can't have: else {
48 :     pos += delta;
49 :     steps += 1;
50 :     travel += |delta|;
51 :     // BUG: can't have: }
52 :     }
53 :     }
54 :    
55 :     initially { sample(ui, vi, wi) |
56 :     wi in 0..(gridSize-1),
57 :     vi in 0..(gridSize-1),
58 :     ui in 0..(gridSize-1) };

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