MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
lm.h
1
2//
3// Prototypes and definitions for the Levenberg - Marquardt minimization algorithm
4// Copyright (C) 2004 Manolis Lourakis (lourakis@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//
19
20#ifndef _LM_H_
21#define _LM_H_
22
23//#undef HAVE_LAPACK // uncomment this to force not using LAPACK
24
25#define LINSOLVERS_RETAIN_MEMORY // comment this is if you don't want routines in Axb.c retain working memory between calls
26
27/* no changes necessary beyond this point */
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33
34#define FABS(x) (((x)>=0.0)? (x) : -(x))
35
36/* work arrays size for LM with & without jacobian, should be multiplied by sizeof(double)
37 * or sizeof(float) to be converted to bytes
38 */
39#define LM_DER_WORKSZ(npar, nmeas) (2*(nmeas) + 4*(npar) + (nmeas)*(npar) + (npar)*(npar))
40#define LM_DIF_WORKSZ(npar, nmeas) (3*(nmeas) + 4*(npar) + (nmeas)*(npar) + (npar)*(npar))
41
42#define LM_OPTS_SZ 5 /* max(4, 5) */
43#define LM_INFO_SZ 9
44#define LM_INIT_MU 1E-03
45#define LM_STOP_THRESH 1E-17
46#define LM_DIFF_DELTA 1E-06
47#define LM_VERSION "2.1.3 (Jan. 2006)"
48
49/* double precision LM, with & without jacobian */
50/* unconstrained minimization */
51extern int dlevmar_der(
52 void (*func)(double *p, double *hx, int m, int n, void *adata),
53 void (*jacf)(double *p, double *j, int m, int n, void *adata),
54 double *p, double *x, int m, int n, int itmax, double *opts,
55 double *info, double *work, double *covar, void *adata);
56
57extern int dlevmar_dif(
58 void (*func)(double *p, double *hx, int m, int n, void *adata),
59 double *p, double *x, int m, int n, int itmax, double *opts,
60 double *info, double *work, double *covar, void *adata);
61
62/* box-constrained minimization */
63extern int dlevmar_bc_der(
64 void (*func)(double *p, double *hx, int m, int n, void *adata),
65 void (*jacf)(double *p, double *j, int m, int n, void *adata),
66 double *p, double *x, int m, int n, double *lb, double *ub,
67 int itmax, double *opts, double *info, double *work, double *covar, void *adata);
68
69extern int dlevmar_bc_dif(
70 void (*func)(double *p, double *hx, int m, int n, void *adata),
71 double *p, double *x, int m, int n, double *lb, double *ub,
72 int itmax, double *opts, double *info, double *work, double *covar, void *adata);
73
74/* linear equation constrained minimization */
75extern int dlevmar_lec_der(
76 void (*func)(double *p, double *hx, int m, int n, void *adata),
77 void (*jacf)(double *p, double *j, int m, int n, void *adata),
78 double *p, double *x, int m, int n, double *A, double *b, int k,
79 int itmax, double *opts, double *info, double *work, double *covar, void *adata);
80
81extern int dlevmar_lec_dif(
82 void (*func)(double *p, double *hx, int m, int n, void *adata),
83 double *p, double *x, int m, int n, double *A, double *b, int k,
84 int itmax, double *opts, double *info, double *work, double *covar, void *adata);
85
86
87/* single precision LM, with & without jacobian */
88/* unconstrained minimization */
89extern int slevmar_der(
90 void (*func)(float *p, float *hx, int m, int n, void *adata),
91 void (*jacf)(float *p, float *j, int m, int n, void *adata),
92 float *p, float *x, int m, int n, int itmax, float *opts,
93 float *info, float *work, float *covar, void *adata);
94
95extern int slevmar_dif(
96 void (*func)(float *p, float *hx, int m, int n, void *adata),
97 float *p, float *x, int m, int n, int itmax, float *opts,
98 float *info, float *work, float *covar, void *adata);
99
100/* box-constrained minimization */
101extern int slevmar_bc_der(
102 void (*func)(float *p, float *hx, int m, int n, void *adata),
103 void (*jacf)(float *p, float *j, int m, int n, void *adata),
104 float *p, float *x, int m, int n, float *lb, float *ub,
105 int itmax, float *opts, float *info, float *work, float *covar, void *adata);
106
107extern int slevmar_bc_dif(
108 void (*func)(float *p, float *hx, int m, int n, void *adata),
109 float *p, float *x, int m, int n, float *lb, float *ub,
110 int itmax, float *opts, float *info, float *work, float *covar, void *adata);
111
112/* linear equation constrained minimization */
113extern int slevmar_lec_der(
114 void (*func)(float *p, float *hx, int m, int n, void *adata),
115 void (*jacf)(float *p, float *j, int m, int n, void *adata),
116 float *p, float *x, int m, int n, float *A, float *b, int k,
117 int itmax, float *opts, float *info, float *work, float *covar, void *adata);
118
119extern int slevmar_lec_dif(
120 void (*func)(float *p, float *hx, int m, int n, void *adata),
121 float *p, float *x, int m, int n, float *A, float *b, int k,
122 int itmax, float *opts, float *info, float *work, float *covar, void *adata);
123
124/* linear system solvers */
125extern int dAx_eq_b_QR(double *A, double *B, double *x, int m);
126extern int dAx_eq_b_QRLS(double *A, double *B, double *x, int m, int n);
127extern int dAx_eq_b_Chol(double *A, double *B, double *x, int m);
128extern int dAx_eq_b_LU(double *A, double *B, double *x, int m);
129extern int dAx_eq_b_SVD(double *A, double *B, double *x, int m);
130
131extern int sAx_eq_b_QR(float *A, float *B, float *x, int m);
132extern int sAx_eq_b_QRLS(float *A, float *B, float *x, int m, int n);
133extern int sAx_eq_b_Chol(float *A, float *B, float *x, int m);
134extern int sAx_eq_b_LU(float *A, float *B, float *x, int m);
135extern int sAx_eq_b_SVD(float *A, float *B, float *x, int m);
136
137/* jacobian verification, double & single precision */
138extern void dlevmar_chkjac(
139 void (*func)(double *p, double *hx, int m, int n, void *adata),
140 void (*jacf)(double *p, double *j, int m, int n, void *adata),
141 double *p, int m, int n, void *adata, double *err);
142
143extern void slevmar_chkjac(
144 void (*func)(float *p, float *hx, int m, int n, void *adata),
145 void (*jacf)(float *p, float *j, int m, int n, void *adata),
146 float *p, int m, int n, void *adata, float *err);
147
148#ifdef __cplusplus
149}
150#endif
151
152#endif /* _LM_H_ */

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.