Changeset 389
- Timestamp:
- 09/11/08 06:39:16 (2 months ago)
- Files:
-
- 1 modified
-
trunk/matml/src/ternary/qhull.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/qhull.c
r385 r389 127 127 slope3 = (x2*yG-xG*y2)/vG; 128 128 129 #ifdef DEBUG 129 130 printf (" corners: %g %g %g %g %g %g %g %g %g\n slopes: %g %g\n", 130 131 corners[0], corners[1], corners[2], 131 132 corners[3], corners[4], corners[5], 132 133 corners[6], corners[7], corners[8], slope2, slope3); 134 #endif 133 135 } 134 136 else … … 164 166 current.C3 += dC3; 165 167 distance = dC2*dC2 + dC3*dC3; 166 //printf (" Added %g,%g (dist %g) to go to %g,%g\n", dC2,dC3, 167 // sqrt(distance), current.C2,current.C3); 168 #ifdef DEBUG 169 printf (" Added %g,%g (dist %g) to go to %g,%g\n", dC2,dC3, 170 sqrt(distance), current.C2,current.C3); 171 #endif 168 172 } 169 173 … … 259 263 int eparamc=0; 260 264 265 #ifdef DEBUG 261 266 printf ("Facet 0x%lx: %g,%g %g,%g %g,%g\n", facet, 262 267 corners[0], corners[1], corners[3], … … 266 271 thepoint[0], thepoint[1], thepoint[2], 267 272 fabs((corners[3]-corners[0])*(corners[7]-corners[1]) - 268 (corners[6]-corners[0])*(corners[4]-corners[1]))); 273 (corners[6]-corners[0])*(corners[4]-corners[1]))); 274 #endif 269 275 270 276 /*+ … … 288 294 } 289 295 296 #ifdef DEBUG 290 297 printf (" Centroid %g, free energy %g (func %d)\n", 291 centroid[2], Gcenter, eparamc); 298 centroid[2], Gcenter, eparamc); 299 #endif 292 300 293 301 if (Gcenter < centroid[2] && … … 296 304 if (one_phase_refine || eparam[0] != eparamc) 297 305 { 306 #ifdef DEBUG 298 307 printf (" Refining %s-phase triangle at centroid\n", 299 (eparam[0]==eparamc) ? "one" : "multi"); 308 (eparam[0]==eparamc) ? "one" : "multi"); 309 #endif 300 310 if (numnewpoints >= newpointsize) 301 311 newpoints = realloc … … 310 320 else 311 321 { 322 #ifdef DEBUG 312 323 printf (" Not refining one-phase triangle\n"); 324 #endif 313 325 } 314 326 } … … 327 339 corners[6], corners[7], corners[8]}; 328 340 341 #ifdef DEBUG 329 342 printf (" Refining multi-phase triangle\n"); 343 #endif 330 344 for (j=0; j<3; j++) 331 345 { … … 358 372 for (j=0; j<3; j++) 359 373 { 374 #ifdef DEBUG 360 375 printf (" Refining point at %g, %g function %d\n", 361 376 newcorners[3*j], newcorners[3*j+1], eparam[j]); 377 #endif 362 378 NewtonRefine (newcorners+3*j, corners, eparams+eparam[j], 363 379 T,P, 3,3, newton_tolerance); 380 #ifdef DEBUG 364 381 printf (" -> %g, %g\n", newcorners[3*j], 365 382 newcorners[3*j+1]); 383 #endif 366 384 367 385 newcorners[3*j+2] = free_energy … … 381 399 newcorners[0]+newcorners[1]<=1.) 382 400 { 401 #ifdef DEBUG 383 402 printf (" Adding new point %g,%g,%g\n", 384 newcorners[0], newcorners[1], newcorners[2]); 403 newcorners[0], newcorners[1], newcorners[2]); 404 #endif 385 405 if (numnewpoints >= newpointsize) 386 406 newpoints = realloc … … 400 420 newcorners[3]+newcorners[4]<=1.) 401 421 { 422 #ifdef DEBUG 402 423 printf (" Adding new point %g,%g,%g\n", 403 424 newcorners[3], newcorners[4], newcorners[5]); 425 #endif 404 426 if (numnewpoints >= newpointsize) 405 427 newpoints = realloc … … 423 445 newcorners[6]+newcorners[7]<=1.) 424 446 { 447 #ifdef DEBUG 425 448 printf (" Adding new point %g,%g,%g\n", 426 449 newcorners[6], newcorners[7], newcorners[8]); 450 #endif 427 451 if (numnewpoints >= newpointsize) 428 452 newpoints = realloc … … 442 466 +*/ 443 467 468 /*+ Unfortunately, adding new points can create dissonance between qhull 469 indices and Ternary indices. So this frees the old hull and creates a new 470 one around the old points and new refined ones. This adds an N log N 471 process to an otherwise order-N refining algorithm, but can't be 472 helped. +*/ 473 #ifdef DEBUG 474 printf ("Adding %d new points to hull\n", numnewpoints); 475 #endif 476 444 477 if (!(*points = realloc 445 478 (*points, (*numpoints + numnewpoints) * sizeof (ternary_point)))) 446 479 return 1; 447 480 448 printf ("Adding %d new points to hull\n", numnewpoints); 481 qh_freeqhull (True); 482 free (qpoints); 483 449 484 for (i=0; i<numnewpoints; i++) 450 485 { … … 470 505 *numpoints += numnewpoints; 471 506 472 qh_freeqhull (True); 473 free (qpoints); 474 507 #ifdef DEBUG 475 508 printf ("Done, returning\n"); 509 #endif 476 510 free(newpoints); 477 511