| 1 | /** @file psMinimize.c
|
|---|
| 2 | * \brief basic minimization functions
|
|---|
| 3 | * @ingroup Math
|
|---|
| 4 | *
|
|---|
| 5 | * This file will contain function prototypes for various minimization,
|
|---|
| 6 | * chi-squared minimization, and 1-D polynomial fitting routines.
|
|---|
| 7 | *
|
|---|
| 8 | * @author GLG, MHPCC
|
|---|
| 9 | *
|
|---|
| 10 | * @version $Revision: 1.39 $ $Name: $
|
|---|
| 11 | * @date $Date: 2005/02/17 19:26:23 $
|
|---|
| 12 | *
|
|---|
| 13 | * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
|
|---|
| 14 | *
|
|---|
| 15 | */
|
|---|
| 16 |
|
|---|
| 17 | #if !defined(PS_MINIMIZE_H)
|
|---|
| 18 | #define PS_MINIMIZE_H
|
|---|
| 19 |
|
|---|
| 20 | /** \file psMinimize.h
|
|---|
| 21 | * \brief minimization operations
|
|---|
| 22 | * \ingroup Stats
|
|---|
| 23 | */
|
|---|
| 24 | /** \addtogroup Stats
|
|---|
| 25 | * \{
|
|---|
| 26 | */
|
|---|
| 27 |
|
|---|
| 28 | #include "psVector.h"
|
|---|
| 29 | #include "psMemory.h"
|
|---|
| 30 | #include "psArray.h"
|
|---|
| 31 | #include "psImage.h"
|
|---|
| 32 | #include "psMatrix.h"
|
|---|
| 33 | #include "psFunctions.h"
|
|---|
| 34 | #include "psStats.h"
|
|---|
| 35 | #include "psTrace.h"
|
|---|
| 36 | #include "psError.h"
|
|---|
| 37 | #include "psConstants.h"
|
|---|
| 38 |
|
|---|
| 39 | typedef struct
|
|---|
| 40 | {
|
|---|
| 41 | psS32 maxIter; ///< Convergence limit
|
|---|
| 42 | psF32 tol; ///< Error Tolerance
|
|---|
| 43 | psF32 value; ///< Value of function at minimum
|
|---|
| 44 | psS32 iter; ///< Number of iterations to date
|
|---|
| 45 | psF32 lastDelta; ///< The last difference for the fit
|
|---|
| 46 | }
|
|---|
| 47 | psMinimization;
|
|---|
| 48 |
|
|---|
| 49 | psMinimization *psMinimizationAlloc(psS32 maxIter,
|
|---|
| 50 | psF32 tol);
|
|---|
| 51 |
|
|---|
| 52 | /** Derive a polynomial fit.
|
|---|
| 53 | *
|
|---|
| 54 | * psVectorFitPolynomial1d returns the polynomial that best fits the
|
|---|
| 55 | * observations. The input parameters are a polynomial that specifies the
|
|---|
| 56 | * fit order, myPoly, which will be altered and returned with the best-fit
|
|---|
| 57 | * coefficients; and the observations, x, y and yErr. The independent
|
|---|
| 58 | * variable list, x may be NULL, in which case the vector index is used.
|
|---|
| 59 | * The dependent variable error, yErr may be null, in which case the solution
|
|---|
| 60 | * is determined in the assumption that all data errors are equal. This
|
|---|
| 61 | * function must be valid only for types psF32, psF64.
|
|---|
| 62 | *
|
|---|
| 63 | * @return psPolynomial1D* polynomial fit
|
|---|
| 64 | */
|
|---|
| 65 | psPolynomial1D* psVectorFitPolynomial1D(
|
|---|
| 66 | psPolynomial1D* myPoly, ///< Polynomial to fit
|
|---|
| 67 | const psVector* x, ///< Ordinates (or NULL to just use the indices)
|
|---|
| 68 | const psVector* y, ///< Coordinates
|
|---|
| 69 | const psVector* yErr ///< Errors in coordinates, or NULL
|
|---|
| 70 | );
|
|---|
| 71 |
|
|---|
| 72 | psSpline1D *psVectorFitSpline1D(psSpline1D *mySpline, ///< The spline which will be generated.
|
|---|
| 73 | const psVector* x, ///< Ordinates (or NULL to just use the indices)
|
|---|
| 74 | const psVector* y, ///< Coordinates
|
|---|
| 75 | const psVector* yErr ///< Errors in coordinates, or NULL
|
|---|
| 76 | );
|
|---|
| 77 |
|
|---|
| 78 | typedef
|
|---|
| 79 | psF64 (*psMinimizeLMChi2Func)(psVector *deriv,
|
|---|
| 80 | psVector *params,
|
|---|
| 81 | psVector *x);
|
|---|
| 82 |
|
|---|
| 83 | psBool psMinimizeLMChi2(psMinimization *min,
|
|---|
| 84 | psImage *covar,
|
|---|
| 85 | psVector *params,
|
|---|
| 86 | const psVector *paramMask,
|
|---|
| 87 | const psArray *x,
|
|---|
| 88 | const psVector *y,
|
|---|
| 89 | const psVector *yErr,
|
|---|
| 90 | psMinimizeLMChi2Func func);
|
|---|
| 91 |
|
|---|
| 92 | psBool p_psMinLM_GuessABP (psImage *Alpha,
|
|---|
| 93 | psVector *Beta,
|
|---|
| 94 | psVector *Params,
|
|---|
| 95 | psImage *alpha,
|
|---|
| 96 | psVector *beta,
|
|---|
| 97 | psVector *params,
|
|---|
| 98 | psF64 lambda);
|
|---|
| 99 |
|
|---|
| 100 | psF64 p_psMinLM_SetABX (psImage *alpha,
|
|---|
| 101 | psVector *beta,
|
|---|
| 102 | psVector *params,
|
|---|
| 103 | const psArray *x,
|
|---|
| 104 | const psVector *y,
|
|---|
| 105 | const psVector *dy,
|
|---|
| 106 | psMinimizeLMChi2Func func);
|
|---|
| 107 |
|
|---|
| 108 | typedef
|
|---|
| 109 | psF32 (*psMinimizePowellFunc)(const psVector *params,
|
|---|
| 110 | const psArray *coords);
|
|---|
| 111 |
|
|---|
| 112 | psBool psMinimizePowell(psMinimization *min,
|
|---|
| 113 | psVector *params,
|
|---|
| 114 | const psVector *paramMask,
|
|---|
| 115 | const psArray *coords,
|
|---|
| 116 | psMinimizePowellFunc func);
|
|---|
| 117 |
|
|---|
| 118 | psVector *psMinimizeLMChi2Gauss1D(psImage *deriv,
|
|---|
| 119 | const psVector *params,
|
|---|
| 120 | const psArray *coords);
|
|---|
| 121 |
|
|---|
| 122 | psVector *psMinimizePowellChi2Gauss1D(const psVector *params,
|
|---|
| 123 | const psArray *coords);
|
|---|
| 124 |
|
|---|
| 125 | typedef
|
|---|
| 126 | psVector *(*psMinimizeChi2PowellFunc)(const psVector *params,
|
|---|
| 127 | const psArray *coords);
|
|---|
| 128 |
|
|---|
| 129 | psBool psMinimizeChi2Powell(psMinimization *min,
|
|---|
| 130 | psVector *params,
|
|---|
| 131 | const psVector *paramMask,
|
|---|
| 132 | const psArray *coords,
|
|---|
| 133 | const psVector *value,
|
|---|
| 134 | const psVector *error,
|
|---|
| 135 | psMinimizeChi2PowellFunc func);
|
|---|
| 136 |
|
|---|
| 137 | // XXX EAM : psGaussJordan provided as an alternate to LU Decomp for psMinimizeLMChi2
|
|---|
| 138 | bool psGaussJordan (psImage *a, psVector *b);
|
|---|
| 139 |
|
|---|
| 140 | /* \} */// End of MathGroup Functions
|
|---|
| 141 |
|
|---|
| 142 | #endif
|
|---|
| 143 |
|
|---|