Subversion Repositories shark

Rev

Rev 1655 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1655 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/*
22
 * Copyright (C) 2000 Massimiliano Giorgi
23
 *
24
 * This program is free software; you can redistribute it and/or modify
25
 * it under the terms of the GNU General Public License as published by
26
 * the Free Software Foundation; either version 2 of the License, or
27
 * (at your option) any later version.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
37
 *
38
 * CVS :        $Id: distr.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $
39
 */
40
 
41
long t[PREC];
42
long counter;
43
long hoops;
44
long maxv=0;
45
 
46
void d_init(void)
47
{
48
  int i;
49
  hoops=counter=0;
50
  for (i=0;i<PREC;i++) t[i]=0;
51
}
52
 
53
void d_insert(long d)
54
{
55
  if (d>=MAXX) {
56
    hoops++;
57
    if (d>maxv) maxv=d;
58
    return;
59
  }
60
 
61
  counter++;
62
  t[(int)(d/DELTA)]++;
63
}
64
 
65
void d_dump(FILE *fout)
66
{
67
  int i;
68
 
69
  if (counter==0) {
70
    fprintf(stderr,"nothing to write to the output file\n");
71
    return;
72
  }
73
 
74
  if (hoops) {
75
    fprintf(stderr,"%li values to big (max=%li)\n",hoops,maxv);
76
  }
77
 
78
  for (i=0;i<PREC;i++)
79
    fprintf(fout,"%f %f\n",
80
            DELTA/2.0+DELTA*i,
81
            (double)t[i]/(double)counter
82
            );
83
}