Changeset 6420
- Timestamp:
- Feb 9, 2006, 6:12:02 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMinimizePowell.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMinimizePowell.c
r6346 r6420 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-02-07 23:14:21 $ 11 * NOTE: XXX: The SDR is silent about data types. F32 is implemented here. 12 * 13 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-02-10 04:12:02 $ 13 15 * 14 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 98 100 increases, or x is too large. If thst does not work, expand in the other 99 101 direction. 100 101 XXX: This is F32 only. Must add F64 support (actually, make the defaults F64,102 and convert F32 vectors to F64).103 102 104 103 XXX: output bracket vector should be an input as well. … … 341 340 XXX: This routine is not very efficient in terms of total evaluations of the 342 341 function. 343 XXX: This is F32 only (make it F64).344 342 XXX: Since this is an internal function, many of the parameter checks are 345 343 redundant. 346 XXX: Don't modify the psMinimization argument.347 344 *****************************************************************************/ 348 345 #define PS_LINEMIN_MAX_ITERATIONS 30 349 psF32 p_psLineMin(346 static psF32 LineMin( 350 347 psMinimization *min, 351 348 psVector *params, … … 385 382 psS32 numIterations = 0; 386 383 387 psTrace(__func__, 4, "---- p_psLineMin() begin ----\n");384 psTrace(__func__, 4, "---- LineMin() begin ----\n"); 388 385 PS_VECTOR_F32_CHECK_ZERO_VECTOR(line, boolLineIsNull); 389 386 390 387 if (boolLineIsNull == true) { 391 388 min->value = func(params, coords); 392 psTrace(__func__, 2, " p_psLineMin() called with zero line vector. Return 0.0. Function value is %f\n", min->value);389 psTrace(__func__, 2, "LineMin() called with zero line vector. Return 0.0. Function value is %f\n", min->value); 393 390 return(0.0); 394 391 } … … 410 407 while (numIterations < PS_LINEMIN_MAX_ITERATIONS) { 411 408 numIterations++; 412 psTrace(__func__, 6, " p_psLineMin(): iteration %d\n", numIterations);409 psTrace(__func__, 6, "LineMin(): iteration %d\n", numIterations); 413 410 414 411 a = bracket->data.F32[0]; … … 464 461 min->value = func(params, coords); 465 462 psFree(bracket); 466 psTrace(__func__, 4, "---- p_psLineMin() end.a (%f) (%f) ----\n", mul, min->value);463 psTrace(__func__, 4, "---- LineMin() end.a (%f) (%f) ----\n", mul, min->value); 467 464 return(mul); 468 465 } … … 472 469 PS_VECTOR_ADD_MULTIPLE(params, paramMask, line, params, mul); 473 470 min->value = func(params, coords); 474 psTrace(__func__, 4, "---- p_psLineMin() end.b (%f) %f ----\n", mul, min->value);471 psTrace(__func__, 4, "---- LineMin() end.b (%f) %f ----\n", mul, min->value); 475 472 476 473 psFree(bracket); … … 488 485 489 486 XXX: We do not use Brent's method. 490 491 XXX: The SDR is silent about data types. F32 is implemented here.492 Reimplement in F64, convert F32 vectors to F64.493 487 *****************************************************************************/ 494 488 #define PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS 20 … … 574 568 P_PSMINIMIZATION_SET_MAXITER((&dummyMin),PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS); 575 569 *(float*)&dummyMin.tol = PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE; 576 mul = p_psLineMin(&dummyMin, 577 Q, 578 ((psVector *) v->data[i]), 579 myParamMask, 580 coords, 581 func); 570 mul = LineMin(&dummyMin, Q, ((psVector *) v->data[i]), 571 myParamMask, coords, func); 582 572 if (isnan(mul)) { 583 573 psError(PS_ERR_UNKNOWN, false, … … 594 584 currFuncVal = dummyMin.value; 595 585 } 586 // XXX: how can it be that we are not saving mul anywhere? 596 587 } 597 588 psTrace(__func__, 6, "New function value is %f\n", currFuncVal); 589 // XXX: There must be a bug here. How can currFuncVal be the current function value? 590 // It is simply the minimum along one of the parameter dimensions. 598 591 599 592 // 4: Set the vector u = Q - P … … 616 609 } 617 610 618 mul = p_psLineMin(&dummyMin, params, u, myParamMask, coords, func);611 mul = LineMin(&dummyMin, params, u, myParamMask, coords, func); 619 612 if (isnan(mul)) { 620 613 psError(PS_ERR_UNKNOWN, false, … … 628 621 psFree(v); 629 622 min->iter = iterationNumber; 630 // XXX: Ensure that currFuncVal is the correct value to use here.631 623 min->value = currFuncVal; 632 // XXX: ensure that the lastDelta should be 0.0.633 624 min->lastDelta = 0.0; 634 625 psTrace(__func__, 4, "---- psMinimizePowell() end (1)(true) ----\n"); … … 690 681 This functions uses global variables to receive the function pointer, the 691 682 data values, and the data errors. 692 693 XXX: This is F32 only. Must implement F64.694 683 *****************************************************************************/ 695 684 static psF32 myPowellChi2Func(
Note:
See TracChangeset
for help on using the changeset viewer.
