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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4387 - (view) (download)

1 : jhr 4328 /* global-sum-test.diderot
2 :     *
3 :     * This program tests the use of global reductions in a program.
4 :     *
5 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
6 :     *
7 :     * COPYRIGHT (c) 2016 The University of Chicago
8 :     * All rights reserved.
9 :     */
10 :    
11 : jhr 4387 /*const*/ int N = 10;
12 :     real target = 0.0;
13 : jhr 4328
14 :     strand S (int i) {
15 :     output real e = i;
16 :    
17 :     update {
18 : jhr 4387 real delta = (target - e);
19 :     print (i, ": e = ", e, ", delta = ", delta, "\n");
20 :     if (|delta| < 0.001) {
21 : jhr 4328 stabilize;
22 :     } else {
23 : jhr 4387 e += delta;
24 : jhr 4328 }
25 :     }
26 :    
27 :     }
28 :    
29 : jhr 4387 collection { S(i) | i in 1..N }
30 : jhr 4328
31 :     initially {
32 : jhr 4387 target = sum { p.e | p in S.all } / N;
33 :     print("initially: target = ", target, "\n");
34 : jhr 4328 }
35 :    
36 :     update {
37 : jhr 4387 target = sum { p.e | p in S.all } / N;
38 :     print("update: target = ", target, "\n");
39 : jhr 4328 }

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