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

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

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