Changeset 6322 for trunk/psLib/src/math/psMinimizePowell.c
- Timestamp:
- Feb 3, 2006, 12:05:22 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMinimizePowell.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMinimizePowell.c
r6186 r6322 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-0 1-23 22:25:31$11 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-02-03 22:05:22 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 15 *16 * XXX: must follow coding name standards on local functions.17 * XXX: put local functions in front.18 15 * 19 16 */ … … 69 66 /*****************************************************************************/ 70 67 /* GLOBAL VARIABLES */ 71 /* XXX: Do these conform to code standard? */72 68 /*****************************************************************************/ 73 69 static psMinimizeChi2PowellFunc Chi2PowellFunc = NULL; 74 static psVector * myValue;75 static psVector * myError;70 static psVector *PowellValue; 71 static psVector *PowellError; 76 72 /*****************************************************************************/ 77 73 /* FILE STATIC VARIABLES */ … … 97 93 Repeat this process until a local minimum is found. 98 94 99 XXX: 100 new algorithm: 95 XXX: new algorithm: 101 96 start at x=0, expand in one direction until the function 102 97 decreases. Then you have two points in the bracket. Keep going until it … … 104 99 direction. 105 100 106 XXX: 107 This is F32 only. Must add 108 F64 support (actually, make the defaults F64, 101 XXX: This is F32 only. Must add F64 support (actually, make the defaults F64, 109 102 and convert F32 vectors to F64). 110 103 111 XXX: 112 output bracket vector should be an input as well. 104 XXX: output bracket vector should be an input as well. 113 105 *****************************************************************************/ 114 106 psVector *p_psDetermineBracket( … … 355 347 *****************************************************************************/ 356 348 #define PS_LINEMIN_MAX_ITERATIONS 30 357 psF32 p_psLineMin(psMinimization *min, 358 psVector *params, 359 psVector *line, 360 const psVector *paramMask, 361 const psArray *coords, 362 psMinimizePowellFunc func) 349 psF32 p_psLineMin( 350 psMinimization *min, 351 psVector *params, 352 psVector *line, 353 const psVector *paramMask, 354 const psArray *coords, 355 psMinimizePowellFunc func) 363 356 { 364 357 PS_ASSERT_PTR_NON_NULL(min, NAN); … … 502 495 #define PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE 0.01 503 496 504 bool psMinimizePowell(psMinimization *min, 505 psVector *params, 506 const psVector *paramMask, 507 const psArray *coords, 508 psMinimizePowellFunc func) 497 bool psMinimizePowell( 498 psMinimization *min, 499 psVector *params, 500 const psVector *paramMask, 501 const psArray *coords, 502 psMinimizePowellFunc func) 509 503 { 510 504 PS_ASSERT_PTR_NON_NULL(min, NULL); … … 696 690 This functions uses global variables to receive the function pointer, the 697 691 data values, and the data errors. 692 698 693 XXX: This is F32 only. Must implement F64. 699 694 *****************************************************************************/ 700 static psF32 myPowellChi2Func(const psVector *params, 701 const psArray *coords) 695 static psF32 myPowellChi2Func( 696 const psVector *params, 697 const psArray *coords) 702 698 { 703 699 psTrace(__func__, 4, "---- myPowellChi2Func() begin ----\n"); 704 700 PS_ASSERT_VECTOR_NON_NULL(params, NAN); 705 701 PS_ASSERT_VECTOR_NON_EMPTY(params, NAN); 706 PS_ASSERT_VECTOR_NON_NULL( myValue, NAN);707 PS_ASSERT_VECTOR_NON_EMPTY( myValue, NAN);702 PS_ASSERT_VECTOR_NON_NULL(PowellValue, NAN); 703 PS_ASSERT_VECTOR_NON_EMPTY(PowellValue, NAN); 708 704 PS_ASSERT_PTR_NON_NULL(coords, NAN); 709 705 … … 714 710 715 711 tmp = Chi2PowellFunc(params, coords); 716 if ( myError == NULL) {712 if (PowellError == NULL) { 717 713 for (i=0;i<coords->n;i++) { 718 d = (tmp->data.F32[i] - myValue->data.F32[i]);714 d = (tmp->data.F32[i] - PowellValue->data.F32[i]); 719 715 chi2+= d * d; 720 716 } 721 717 } else { 722 718 for (i=0;i<coords->n;i++) { 723 d = (tmp->data.F32[i] - myValue->data.F32[i]) / myError->data.F32[i];719 d = (tmp->data.F32[i] - PowellValue->data.F32[i]) / PowellError->data.F32[i]; 724 720 chi2+= d * d; 725 721 } … … 741 737 psMinimizePowell(). 742 738 *****************************************************************************/ 743 bool psMinimizeChi2Powell(psMinimization *min, 744 psVector *params, 745 const psVector *paramMask, 746 const psArray *coords, 747 const psVector *value, 748 const psVector *error, 749 psMinimizeChi2PowellFunc model) 739 bool psMinimizeChi2Powell( 740 psMinimization *min, 741 psVector *params, 742 const psVector *paramMask, 743 const psArray *coords, 744 const psVector *value, 745 const psVector *error, 746 psMinimizeChi2PowellFunc model) 750 747 { 751 myValue = (psVector *) value;752 myError = (psVector *) error;748 PowellValue = (psVector *) value; 749 PowellError = (psVector *) error; 753 750 754 751 Chi2PowellFunc = model;
Note:
See TracChangeset
for help on using the changeset viewer.
