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

SCM Repository

[diderot] View of /branches/vis15/src/tests/new-tests/global-sum-test.diderot
ViewVC logotype

View of /branches/vis15/src/tests/new-tests/global-sum-test.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4497 - (download) (annotate)
Sat Sep 3 14:12:36 2016 UTC (2 years, 8 months ago) by jhr
File size: 812 byte(s)
  working on merge: updating tests with new version 2 syntax
#version 2.0

/* global-sum-test.diderot
 *
 * This program tests the use of global reductions in a program.
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 */

/*const*/ int N = 10;
real target = 0.0;

strand S (int i) {
  output real e = i;

  update {
    real delta = (target - e);
    print (i, ": e = ", e, ", delta = ", delta, "\n");
    if (|delta| < 0.001) {
	stabilize;
    } else {
	e += delta;
    }
  }

}

create_collection { S(i) | i in 1..N }

start {
//  target = sum { p.e | p in S.all } / N;
  target = mean { p.e | p in S.all };
  print("initially: target = ", target, "\n");
}

update {
  target = sum { p.e | p in S.all } / N;
  print("update: target = ", target, "\n");
}

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