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 1597 - (view) (download)

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

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