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

SCM Repository

[diderot] View of /branches/vis12/bugs/resolved/bug034.diderot
ViewVC logotype

View of /branches/vis12/bugs/resolved/bug034.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2674 - (download) (annotate)
Sat Jul 19 20:52:58 2014 UTC (7 years, 3 months ago) by jhr
File size: 2285 byte(s)
  Fixed bug034 (issues with unused variable tracking)
/*

BUG: who knows.  Running "diderotc --exec bug034.diderot" causes:
uncaught exception Fail [Fail: no location for foo]
  raised at common/phase-timer.sml:76.50-76.52
  raised at common/phase-timer.sml:76.50-76.52
  raised at typechecker/typechecker.sml:32.30-32.69

*/

input int size = 100;
input real width = 2;
real spc = width/real(size-1);
real phi=0;

real eps = 0.0001;

input bool bar = true;

function vec2 foo(vec2 v) {
  vec2 ret = [nan,nan];
  if (bar) {
    ret = [-v[1], v[0]]/(|v|^2);
  } else {
    ret = [-v[1], v[0]];
 }
 return ret;
}

vec3 ww = [0.5, 0.8, 0.5];

function vec2 ff(vec2 xy) {
//  vec2 r1 = xy - [0.6+eps, -0.3+eps];  // r = radial vector
//  vec2 r2 = xy - [-0.6+eps, 0.3+eps];
  vec2 r1 = xy - [0.8+eps, -0.5+eps];  // r = radial vector
  vec2 r2 = xy - [-0.7+eps, -0.5+eps];
  vec2 r3 = xy - [-0.6+eps, 0.6+eps];
  real w1 = nan;
  real w2 = nan;
  real w3 = nan;
  w1 = ww[0];
  w2 = ww[1];
  w3 = ww[2];
  if (!bar) {
    w1 *= 1/(|r1|^2);
    w2 *= 1/(|r2|^2);
    w3 *= 1/(|r3|^2);
  }
  return (w1*foo(r1) - w2*foo(r2) + w3*foo(r3))/(w1 + w2 + w3);
}

strand sample(int xi, int yi) {
  output vec2 vv = [0.00000001,0];
  tensor[2,2] rot = [[cos(phi),sin(phi)],[-sin(phi),cos(phi)]];
  real diag = spc*real(size-1)/2;
  vec2 orig = rot•[-diag, -diag];
  vec2 xdir = rot•[spc, 0.0];
  vec2 ydir = rot•[0.0, spc];
  vec2 xy = [nan,nan];
  update {
    if (0 == xi && 0 == yi) {
      print("NRRD0004\n");
      print("# Complete NRRD file format specification at:\n");
      print("# http://teem.sourceforge.net/nrrd/format.html\n");
      print("type: float\n");
      print("dimension: 3\n");
      print("sizes: 2 ", size, " ", size, "\n");
      print("kinds: 2-vector space space\n");
      print("endian: little\n");
      print("encoding: raw\n");
      print("space dimension: 2\n");
      print("space directions: none (", xdir[0], ",", xdir[1], ") (", ydir[0], ",", ydir[1], ")\n");
      print("space origin: (", orig[0], ",", orig[1], ")\n");
      print("data file: vv.nrrd\n");
      print("byte skip: -1\n");
    }
    xy  = orig + xi*xdir + yi*ydir;
    vv = ff(xy);
    stabilize;
  }
  stabilize {
    //print("666 ", xy[0], " ", xy[1], "\n");
  }
}
initially [ sample(xi, yi) | yi in 0..(size-1), xi in 0..(size-1) ];

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