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

SCM Repository

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

Annotation of /tests/new-tests/global-sum-test.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (view) (download)

1 : glk 4640 #version 2.0
2 :    
3 :     /* 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 :     /*const*/ int N = 10;
14 :     real target = 0.0;
15 :    
16 :     strand S (int i) {
17 :     output real e = i;
18 :    
19 :     update {
20 :     real delta = (target - e);
21 :     print (i, ": e = ", e, ", delta = ", delta, "\n");
22 :     if (|delta| < 0.001) {
23 :     stabilize;
24 :     } else {
25 :     e += delta;
26 :     }
27 :     }
28 :    
29 :     }
30 :    
31 :     start {
32 :     // target = sum { p.e | p in S.all } / N;
33 :     target = mean { p.e | p in S.all };
34 :     print("initially: target = ", target, "\n");
35 :     }
36 :    
37 :     update {
38 :     target = sum { p.e | p in S.all } / N;
39 :     print("update: target = ", target, "\n");
40 :     }
41 :    
42 :     create_collection { S(i) | i in 1..N }
43 :    

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