-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlmmin_int64.h
117 lines (108 loc) · 4.42 KB
/
lmmin_int64.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* Library: lmfit (Levenberg-Marquardt least squares fitting)
*
* File: lmmin_int64.h
*
* Contents: Declarations for Levenberg-Marquardt minimization.
*
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
*
* License: FreeBSD
*
* Homepage: apps.jcns.fz-juelich.de/lmfit
*/
/*
* Copyright (c) Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of the FreeBSD Project.
*/
/*
* Changelog: KB Aug 5, 2016 Updated all instances of int to int64_t to handle long data sets
*
*
*
*/
#ifndef LMMIN_INT64_H
#define LMMIN_INT64_H
#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#else
#define __BEGIN_DECLS /* empty */
#define __END_DECLS /* empty */
#endif
#include "lmstruct_int64.h"
#include<inttypes.h>
#include"utils.h"
__BEGIN_DECLS
/* Levenberg-Marquardt minimization. */
void lmmin_int64(const int64_t n_par, long double* par, const int64_t m_dat, const void* data,
void (*evaluate)(const long double* par, const int64_t m_dat,
const void* data, long double* fvec, int64_t* userbreak),
const lm_control_struct* control, lm_status_struct* status);
/*
* This routine contains the core algorithm of our library.
*
* It minimizes the sum of the squares of m nonlinear functions
* in n variables by a modified Levenberg-Marquardt algorithm.
* The function evaluation is done by the user-provided routine 'evaluate'.
* The Jacobian is then calculated by a forward-difference approximation.
*
* Parameters:
*
* n is the number of variables (INPUT, positive integer).
*
* x is the solution vector (INPUT/OUTPUT, array of length n).
* On input it must be set to an estimated solution.
* On output it yields the final estimate of the solution.
*
* m is the number of functions to be minimized (INPUT, positive integer).
* It must fulfill m>=n.
*
* data is a pointer that is ignored by lmmin; it is however forwarded
* to the user-supplied functions evaluate and printout.
* In a typical application, it contains experimental data to be fitted.
*
* evaluate is a user-supplied function that calculates the m functions.
* Parameters:
* n, x, m, data as above.
* fvec is an array of length m; on OUTPUT, it must contain the
* m function values for the parameter vector x.
* userbreak is an integer pointer. When *userbreak is set to a
* nonzero value, lmmin will terminate.
*
* control contains INPUT variables that control the fit algorithm,
* as declared and explained in lmstruct.h
*
* status contains OUTPUT variables that inform about the fit result,
* as declared and explained in lmstruct.h
*/
/* Refined calculation of Eucledian norm. */
long double lm_enorm(int64_t, const long double*);
__END_DECLS
#endif /* LMMIN_H */