1 #include "BSprivate.h"
2 
3 /*+ BSoff_gnum - Find the global row number of the first row in each clique
4 
5     Input Parameters:
6 .   offset - the global row number of the first row in each color
7 .   numbering - the coloring of the cliques
8 .   distr - the number of rows in each clique
9 
10     Returns:
11     the global row number of the first row in each clique
12 
13  +*/
BSoff_gnum(BSnumbering * offset,BSnumbering * numbering,BSdistribution * distr)14 BSnumbering	*BSoff_gnum(BSnumbering *offset, BSnumbering *numbering,
15 	BSdistribution *distr)
16 {
17 	BSnumbering	*gnum;
18 	int	*count;
19 	int	 i;
20 	int	ind;
21 
22 	gnum = BSalloc_numbering(numbering->length); CHKERRN(0);
23 	MY_MALLOCN(count,(int *),sizeof(int)*offset->length,1);
24 	for (i=0;i<offset->length;i++) count[i] = 0;
25 	if (distr != NULL) {
26 		for (i=0;i<numbering->length;i++) {
27 			ind = numbering->numbers[i];
28 			gnum->numbers[i] = offset->numbers[ind] + count[ind];
29 			count[ind] += distr->distribution[i];
30 		}
31 	} else {
32 		for (i=0;i<numbering->length;i++) {
33 			ind = numbering->numbers[i];
34 			gnum->numbers[i] = offset->numbers[ind] + count[ind];
35 			count[ind]++;
36 		}
37 	}
38 	MY_FREEN(count);
39 	return(gnum);
40 }
41