1 #include	"BSprivate.h"
2 
3 /*+ BSnum2distr - Compute the distribution of a numbering
4 
5     Input Parameters:
6 .   numbering - the numbering
7 
8     Returns:
9     the distribution of the numbering
10 
11     Notes: The assumption is that the numbering runs from 0 to n
12     and that the distribution will tell how many 0's, how many 1's, etc.
13 
14  +*/
BSnum2distr(BSnumbering * numbering)15 BSdistribution *BSnum2distr(BSnumbering *numbering)
16 {
17 	BSdistribution	*distr;
18 	int	max;
19 	int	i;
20 
21 	max = 0;
22 	for (i=0;i<numbering->length;i++) {
23 		if (numbering->numbers[i] > max) max = numbering->numbers[i];
24 	}
25 	distr = BSalloc_distribution(max); CHKERRN(0);
26 	for (i=0;i<=max;i++) {
27 		distr->distribution[i] = 0;
28 	}
29 	for (i=0;i<numbering->length;i++) {
30 		distr->distribution[numbering->numbers[i]]++;
31 	}
32 	return(distr);
33 }
34 
35