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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1598 - (download) (annotate)
Wed Nov 2 13:43:52 2011 UTC (7 years, 6 months ago) by jhr
File size: 1782 byte(s)
  Compacting code for line counting.
/*! \file bmark-diderot.diderot
 *
 * \author Gordon Kindlmann
 */

/*
 * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 */

int gridSize = 120;
field#2(3)[] F = bspln3 ⊛ load("../../data/lungcrop.nrrd");
input int stepsMax = 30;
input real epsilon = 0.001;
input real travelMax = 5.0;
input real strnMin = 170.0;

strand sample (int ui, int vi, int wi) {
    output vec3 pos = [lerp(21.6401, 21.6401 + 140.0*0.5,
                              -0.5, real(ui), real(gridSize)-0.5),
                       lerp(-175.8792, -175.8792 + 200.0*0.5, 
                              -0.5, real(vi), real(gridSize)-0.5),
                       lerp(-188.0000, -188.0000 + 140.0*0.5,
                              -0.5, real(wi), real(gridSize)-0.5)];
    int steps = 0;
    real travel = 0.0;
    update {
        if (!inside(pos, F) || steps > stepsMax || travel > travelMax)
	    die;
        real gmag = |∇F(pos)|;
        if (gmag == 0.0)    // can't compute step if |∇F|, so have to bail
	    die;
        vec3 grad = ∇F(pos);
        tensor[3,3] hess = ∇⊗∇F(pos);

        real{3} eval = evals(hess);
        real strn = -eval{1};
        vec3{3} evec = evecs(hess);
        vec3 dir = normalize((evec{2}⊗evec{2} + evec{1}⊗evec{1})•grad);

        real fdd = grad•dir;
        real sdd = dir•hess•dir;
        vec3 delta = (0.1 if sdd >= 0.0 else -fdd/sdd)*dir;
        if (|delta| < epsilon) {
           if (strn >= strnMin)
             stabilize;
           die;
        }
        pos += delta;
        steps += 1;
        travel += |delta|;
    }
}

initially { sample(ui, vi, wi) | 
             wi in 0..(gridSize-1), 
             vi in 0..(gridSize-1), 
             ui in 0..(gridSize-1) };

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