1 /*
2  *   Copyright (C) 1988-1990 Yale University
3  *
4  *   This work is distributed in the hope that it will be useful; you can
5  *   redistribute it and/or modify it under the terms of the
6  *   GNU General Public License as published by the Free Software Foundation;
7  *   either version 2 of the License,
8  *   or any later version, on the following conditions:
9  *
10  *   (a) YALE MAKES NO, AND EXPRESSLY DISCLAIMS
11  *   ALL, REPRESENTATIONS OR WARRANTIES THAT THE MANUFACTURE, USE, PRACTICE,
12  *   SALE OR
13  *   OTHER DISPOSAL OF THE SOFTWARE DOES NOT OR WILL NOT INFRINGE UPON ANY
14  *   PATENT OR
15  *   OTHER RIGHTS NOT VESTED IN YALE.
16  *
17  *   (b) YALE MAKES NO, AND EXPRESSLY DISCLAIMS ALL, REPRESENTATIONS AND
18  *   WARRANTIES
19  *   WHATSOEVER WITH RESPECT TO THE SOFTWARE, EITHER EXPRESS OR IMPLIED,
20  *   INCLUDING,
21  *   BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
22  *   PARTICULAR
23  *   PURPOSE.
24  *
25  *   (c) LICENSEE SHALL MAKE NO STATEMENTS, REPRESENTATION OR WARRANTIES
26  *   WHATSOEVER TO
27  *   ANY THIRD PARTIES THAT ARE INCONSISTENT WITH THE DISCLAIMERS BY YALE IN
28  *   ARTICLE
29  *   (a) AND (b) above.
30  *
31  *   (d) IN NO EVENT SHALL YALE, OR ITS TRUSTEES, DIRECTORS, OFFICERS,
32  *   EMPLOYEES AND
33  *   AFFILIATES BE LIABLE FOR DAMAGES OF ANY KIND, INCLUDING ECONOMIC DAMAGE OR
34  *   INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER YALE SHALL BE
35  *   ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE
36  *   POSSIBILITY OF THE FOREGOING.
37  *
38  */
39 
40 /* -----------------------------------------------------------------
41 FILE:	    makebins.c
42 DESCRIPTION:determines number of bins for overlap calculation
43 CONTENTS:   makebins( INT )
44 DATE:	    Feb 13, 1988
45 REVISIONS:
46 	    Feb 27, 1988 - now called from config1 and calculates
47 		numbins based on cell area. In future, use variance.
48 	    Mar  1, 1988 - added variance.
49 	    Nov 20, 1988 - fixed aspect ratio.
50 ----------------------------------------------------------------- */
51 
52 #include <custom.h>
53 #include <yalecad/debug.h>
54 
makebins(INT numbins)55 void makebins( INT numbins )
56 {
57 
58 BINBOXPTR bptr ;
59 DOUBLE xbins, ybins ;
60 INT i, j ;
61 
62 ybins = sqrt( chipaspectG * (DOUBLE) numbins ) ;
63 ybins = ceil( ybins ) ;
64 xbins = sqrt( (DOUBLE) numbins / chipaspectG ) ;
65 xbins = ceil( xbins ) ;
66 
67 maxBinXG = (INT) xbins ;
68 maxBinYG = (INT) ybins ;
69 
70 /* take bins for border around chip into account */
71 /* bins will be labeled [0..maxBinsXG] for a total of maxBinsXG+1 bins */
72 maxBinXG++ ;
73 maxBinYG++ ;
74 OUT2("maxBinXG automatically set to:%d\n", maxBinXG );
75 OUT2("maxBinYG automatically set to:%d\n", maxBinYG );
76 
77 binptrG = (BINBOXPTR **)Ysafe_malloc( (1+maxBinXG)*sizeof(BINBOXPTR *)) ;
78 for( i = 0 ; i <= maxBinXG ; i++ ) {
79     binptrG[i]=(BINBOXPTR*) Ysafe_malloc((1+maxBinYG)*sizeof(BINBOXPTR));
80     for( j = 0 ; j <= maxBinYG ; j++ ) {
81 	bptr = binptrG[i][j] = (BINBOXPTR) Ysafe_malloc( sizeof(BINBOX));
82 	bptr->cells =
83 	    (INT *) Ysafe_malloc( (EXPCELLPERBIN+1) * sizeof(INT));
84 	/* zero position holds current number cells in bin */
85 	bptr->cells[0] = 0 ;
86 	/* space holds current size of array */
87 	bptr->space = EXPCELLPERBIN + 1 ;
88     }
89 }
90 
91 } /* end function make bins */
92