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

SCM Repository

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

Annotation of /tests/new-tests/global-var-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 stdev = ∞;
15 :    
16 :     strand S (int i) {
17 :     output real e = i;
18 :    
19 :     update {
20 :     stabilize;
21 :     }
22 :    
23 :     }
24 :    
25 :     create_collection { S(i) | i in 1..N }
26 :    
27 :     update {
28 :     // real var = variance{P.energy | P in Particle.all};
29 :     real avg = mean{ strnd.e | strnd in S.all};
30 :     real var = sum{(avg - strnd.e)^2 | strnd in S.all};
31 :     stdev = sqrt(var);
32 :     print("update: stdev = ", stdev, "\n");
33 :     }

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