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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4386, Tue Aug 9 13:51:49 2016 UTC revision 4387, Tue Aug 9 16:28:11 2016 UTC
# Line 8  Line 8 
8   * All rights reserved.   * All rights reserved.
9   */   */
10    
11  real total = 1.0;  /*const*/ int N = 10;
12    real target = 0.0;
13    
14  strand S (int i) {  strand S (int i) {
15    output real e = i;    output real e = i;
16    
17    update {    update {
18      real e' = real(i) / total;      real delta = (target - e);
19      if (e == e') {      print (i, ": e = ", e, ", delta = ", delta, "\n");
20        if (|delta| < 0.001) {
21          stabilize;          stabilize;
22      } else {      } else {
23          e = e';          e += delta;
24      }      }
25    }    }
26    
27  }  }
28    
29  collection { S(i) | i in 1..10 }  collection { S(i) | i in 1..N }
30    
31  initially {  initially {
32    total = sum { p.e | p in S.all };    target = sum { p.e | p in S.all } / N;
33    print("initially: total = ", total, "\n");    print("initially: target = ", target, "\n");
34  }  }
35    
36  update {  update {
37    total = sum { p.e | p in S.all };    target = sum { p.e | p in S.all } / N;
38    print("update: total = ", total, "\n");    print("update: target = ", target, "\n");
39  }  }

Legend:
Removed from v.4386  
changed lines
  Added in v.4387

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