/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* Huge speed optimization posible:
	Replace corelation matrix on square of correlation matrix, it will
	remove need of cpu-consuming sqrt function
*/
#include <math.h>

unsigned long disp_n;
unsigned long disp_s;
double disp_d;
double disp_m;

void disp_init() {
	disp_n=0;
	disp_s=0;
	disp_d=0;
}


void disp_event(unsigned long disp_v) {
	unsigned long t;
	
	disp_n++;
	t=disp_n*(disp_n-1);
	
	disp_s+=disp_v;
	disp_v*=disp_n;

	if (t) disp_d+=(double)(((disp_s-disp_v)*(disp_s-disp_v)))/t;
}

void disp_post() {
    if (disp_n>0) {
	disp_m = ((double)disp_s) / disp_n;
        if (disp_n>1) {
    	    disp_d /= (disp_n-1);
	    disp_d = sqrt(disp_d);
	}
    }
}