| [5443b1] | 1 | /////////////////////////////////////////////////////////////////////////////////
 | 
|---|
 | 2 | // 
 | 
|---|
 | 3 | //  Levenberg - Marquardt non-linear minimization algorithm
 | 
|---|
 | 4 | //  Copyright (C) 2004-06  Manolis Lourakis (lourakis at ics forth gr)
 | 
|---|
 | 5 | //  Institute of Computer Science, Foundation for Research & Technology - Hellas
 | 
|---|
 | 6 | //  Heraklion, Crete, Greece.
 | 
|---|
 | 7 | //
 | 
|---|
 | 8 | //  This program is free software; you can redistribute it and/or modify
 | 
|---|
 | 9 | //  it under the terms of the GNU General Public License as published by
 | 
|---|
 | 10 | //  the Free Software Foundation; either version 2 of the License, or
 | 
|---|
 | 11 | //  (at your option) any later version.
 | 
|---|
 | 12 | //
 | 
|---|
 | 13 | //  This program is distributed in the hope that it will be useful,
 | 
|---|
 | 14 | //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 15 | //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 16 | //  GNU General Public License for more details.
 | 
|---|
 | 17 | //
 | 
|---|
 | 18 | /////////////////////////////////////////////////////////////////////////////////
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | /******************************************************************************** 
 | 
|---|
 | 21 |  * combined box and linear equation constraints Levenberg-Marquardt nonlinear
 | 
|---|
 | 22 |  * minimization. The same core code is used with appropriate #defines to derive
 | 
|---|
 | 23 |  * single and double precision versions, see also lmblec_core.c
 | 
|---|
 | 24 |  ********************************************************************************/
 | 
|---|
 | 25 | 
 | 
|---|
 | 26 | #include <stdio.h>
 | 
|---|
 | 27 | #include <stdlib.h>
 | 
|---|
 | 28 | #include <math.h>
 | 
|---|
 | 29 | #include <float.h>
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 | #include "levmar.h"
 | 
|---|
 | 32 | #include "misc.h"
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | #ifndef HAVE_LAPACK
 | 
|---|
 | 35 | 
 | 
|---|
 | 36 | #ifdef _MSC_VER
 | 
|---|
 | 37 | #pragma message("Combined box and linearly constrained optimization requires LAPACK and was not compiled!")
 | 
|---|
 | 38 | #else
 | 
|---|
 | 39 | #warning Combined box and linearly constrained optimization requires LAPACK and was not compiled!
 | 
|---|
 | 40 | #endif // _MSC_VER
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | #else // LAPACK present
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | #if !defined(LM_DBL_PREC) && !defined(LM_SNGL_PREC)
 | 
|---|
 | 45 | #error At least one of LM_DBL_PREC, LM_SNGL_PREC should be defined!
 | 
|---|
 | 46 | #endif
 | 
|---|
 | 47 | 
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | #ifdef LM_SNGL_PREC
 | 
|---|
 | 50 | /* single precision (float) definitions */
 | 
|---|
 | 51 | #define LM_REAL float
 | 
|---|
 | 52 | #define LM_PREFIX s
 | 
|---|
 | 53 | 
 | 
|---|
 | 54 | #define LM_REAL_MAX FLT_MAX
 | 
|---|
 | 55 | #define LM_REAL_MIN -FLT_MAX
 | 
|---|
 | 56 | #define __SUBCNST(x) x##F
 | 
|---|
 | 57 | #define LM_CNST(x) __SUBCNST(x) // force substitution
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | #include "lmblec_core.c" // read in core code
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 | #undef LM_REAL
 | 
|---|
 | 62 | #undef LM_PREFIX
 | 
|---|
 | 63 | #undef LM_REAL_MAX
 | 
|---|
 | 64 | #undef LM_REAL_MIN
 | 
|---|
 | 65 | #undef __SUBCNST
 | 
|---|
 | 66 | #undef LM_CNST
 | 
|---|
 | 67 | #endif /* LM_SNGL_PREC */
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 | #ifdef LM_DBL_PREC
 | 
|---|
 | 70 | /* double precision definitions */
 | 
|---|
 | 71 | #define LM_REAL double
 | 
|---|
 | 72 | #define LM_PREFIX d
 | 
|---|
 | 73 | 
 | 
|---|
 | 74 | #define LM_REAL_MAX DBL_MAX
 | 
|---|
 | 75 | #define LM_REAL_MIN -DBL_MAX
 | 
|---|
 | 76 | #define LM_CNST(x) (x)
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 | #include "lmblec_core.c" // read in core code
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | #undef LM_REAL
 | 
|---|
 | 81 | #undef LM_PREFIX
 | 
|---|
 | 82 | #undef LM_REAL_MAX
 | 
|---|
 | 83 | #undef LM_REAL_MIN
 | 
|---|
 | 84 | #undef LM_CNST
 | 
|---|
 | 85 | #endif /* LM_DBL_PREC */
 | 
|---|
 | 86 | 
 | 
|---|
 | 87 | #endif /* HAVE_LAPACK */
 | 
|---|