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

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

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