12 static int factors[30];
17 static int powers[30];
38 static void collect_factors(
long fact,
long power )
40 factors[nfactor]=fact;
41 powers[nfactor]=power;
58 static int test_fact(
long* numP,
long fact )
63 while ( ( t = *numP / fact ) * fact == *numP )
70 collect_factors( fact, power );
87 static void factor(
long num )
94 if ( lnum == 0 || lnum == 1 ) {
96 collect_factors( lnum, 1 );
100 for ( p = 0; p < (int)(
sizeof(low_primes)/
sizeof(*low_primes)); ++p )
101 if ( ! test_fact( &lnum, low_primes[p] ) )
goto done;
103 fact = ( low_primes[p - 1] + 5 ) / 6 * 6 - 1;
106 if ( ! test_fact( &lnum, fact ) )
109 if ( ! test_fact( &lnum, fact ) )
115 collect_factors( lnum, 1 );
136 double xmax=0,xmin=0,ymax=0,ymin=0;
139 double xlo, xhi, ylo, yhi;
143 factor((
long) partitions);
147 for ( i=nfactor-1; i >= 0; --i){
149 for( j=1; j <=powers[i] ; ++j){
151 xdiv=xdiv*factors[i];
154 ydiv=ydiv*factors[i];
159 printf(
"xdiv=%d ydiv=%d\n",xdiv,ydiv);
165 if(partition_method==geometric){
172 else if(partition_method==other){
184 xmax+=fabs(xmax)*margin;
185 xmin-=fabs(xmin)*margin;
186 ymax+=fabs(ymax)*margin;
187 ymin-=fabs(ymin)*margin;
191 dx=(xmax-xmin)/(xdiv);
192 dy=(ymax-ymin)/(ydiv);
198 for (i=0; i < xdiv; ++i){
200 for (j=0; j < ydiv; ++j){
205 if(partition_method==geometric){
206 if (xlo <= xmin+0.01) xlo = -
SPINF;
207 if (xhi >= xmax-0.01) xhi =
SPINF;
208 if (ylo <= ymin+0.01) ylo = -
SPINF;
209 if (yhi >= ymax-0.01) yhi =
SPINF;
220 printf(
"Partition %d: %f, %f, %f, %f\n",
275 sprintf(data,
"%sspace_partitions.xml",
outputpath);
276 file = fopen(data,
"w");
277 fputs(
"<spacepartitions>\n" , file);
278 fputs(
"<partitions>\n" , file);
279 fputs(
"<number>" , file);
282 fputs(
"</number>\n" , file);
285 fputs(
"<node>\n" , file);
286 fputs(
"<nodeid>" , file);
287 sprintf(data,
"%i", node_info->
node_id);
289 fputs(
"</nodeid>\n" , file);
290 fputs(
"<xmin>" , file);
293 else{ sprintf(data,
"%f", node_info->
partition_data[0]); fputs(data, file); }
294 fputs(
"</xmin>\n" , file);
295 fputs(
"<xmax>" , file);
298 else{ sprintf(data,
"%f", node_info->
partition_data[1]); fputs(data, file); }
299 fputs(
"</xmax>\n" , file);
300 fputs(
"<ymin>" , file);
303 else{ sprintf(data,
"%f", node_info->
partition_data[2]); fputs(data, file); }
304 fputs(
"</ymin>\n" , file);
305 fputs(
"<ymax>" , file);
308 else{ sprintf(data,
"%f", node_info->
partition_data[3]); fputs(data, file); }
309 fputs(
"</ymax>\n" , file);
310 fputs(
"<zmin>" , file);
313 else{ sprintf(data,
"%f", node_info->
partition_data[4]); fputs(data, file); }
314 fputs(
"</zmin>\n" , file);
315 fputs(
"<zmax>" , file);
318 else{ sprintf(data,
"%f", node_info->
partition_data[5]); fputs(data, file); }
319 fputs(
"</zmax>\n" , file);
320 fputs(
"</node>\n" , file);
322 node_info = node_info->
next;
324 fputs(
"</partitions>\n" , file);
325 fputs(
"</spacepartitions>" , file);