Changeset 449

Show
Ignore:
Timestamp:
07/29/09 15:33:44 (15 years ago)
Author:
vbarta
Message:

control iteration with integers, not doubles (overrides memory when it rounds off)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/tests/test_util.cpp

    r436 r449  
    8686    double ystep = (yb(1) - yb(0)) / yn; 
    8787 
    88     int i = 0; 
    89     for (double x = xb(0); x <= xb(1); x += xstep, i++) { 
     88    double x = xb(0); 
     89    for (int i = 0; i <= xn; x += xstep, i++) { 
    9090        rgr(0) = x; 
    91         int j = 0; 
    92         for (double y = yb(0); y <= yb(1); y += ystep, j++) { 
     91        double y = yb(0); 
     92        for (int j = 0; j <= yn; y += ystep, j++) { 
    9393            rgr(1) = y; 
    9494            Pdf(i, j) = exp(ep->evallog(rgr)); 
     
    110110    vec Si(yn + 1); 
    111111 
    112     int i = 0; 
    113     for (double x = xb(0); x <= xb(1); x += xstep, i++) { 
     112    double x = xb(0); 
     113    for (int i = 0; i <= xn; x += xstep, i++) { 
    114114        Mu(i) = x; 
    115115        rgr(0) = x; 
    116         int j = 0; 
    117         for (double y = yb(0); y <= yb(1); y += ystep, j++) { 
     116        double y = yb(0); 
     117        for (int j = 0; j <= yn; y += ystep, j++) { 
    118118            Si(j) = y; 
    119119            rgr(1) = y; 
     
    123123 
    124124    vec fm = sum(Pdf, 2); 
     125    double sfm = sum(fm); 
    125126    vec fs = sum(Pdf, 1); 
    126     return vec_2(Mu * fm / sum(fm), Si * fs / sum(fs)); 
     127    double sfs = sum(fs); 
     128    double vi0 = Mu * fm / sfm; 
     129    double vi1 = Si * fs / sfs; 
     130    return vec_2(vi0, vi1); 
    127131} 
    128132