1 #ifndef __JFIT__JGANDALF__ 
    2 #define __JFIT__JGANDALF__ 
   23 namespace JPP { 
using namespace JFIT; }
 
   52   template<
class JModel_t>
 
   54     public JMessage< JGandalf<JModel_t> >
 
   87                   const JModel_t& 
model) :
 
   98       operator double()
 const  
  128     template<
class JFunction_t, 
class T, 
class ...Args>
 
  144       previous.result.chi2 = numeric_limits<double>::max();
 
  146       current.result.chi2     = numeric_limits<double>::max();
 
  162         update(fit, __begin, __end, args...);
 
  177               update(fit, __begin, __end, args...);
 
  182               catch (
const exception& 
error) {
 
  212           update(fit, __begin, __end, args...);
 
  215         DEBUG(
"Hesse matrix:" << endl << 
V << endl);
 
  219         for (
size_t i = 0; 
i != 
N; ++
i) {
 
  225           h[
i] = 1.0 / sqrt(
V(
i,
i));
 
  230         for (
size_t row = 0; row != 
N; ++row) {
 
  231           for (
size_t col = 0; col != row; ++col) {
 
  232             V(row,col) *= 
h[row] * 
h[col];
 
  233             V(col,row)  = 
V(row,col);
 
  237         for (
size_t i = 0; 
i != 
N; ++
i) {
 
  243         for (
size_t col = 0; col != 
N; ++col) {
 
  250         catch (
const exception& 
error) {
 
  252           ERROR(
"JGandalf: " << error.what() << endl << 
V << endl);
 
  259         for (
size_t row = 0; row != 
N; ++row) {
 
  279       update(fit, __begin, __end, args...);
 
  284       catch (
const exception& 
error) {
 
  330     template<
class JFunction_t, 
class T, 
class ...Args>
 
  331     inline void update(
const JFunction_t& fit, T __begin, T __end, Args ...
args)
 
  333       for (T 
i = __begin; 
i != __end; ++
i) {
 
  337         current.result.chi2     += result.chi2;
 
  338         current.result.gradient += result.gradient;
 
  340         for (
size_t row = 0; row != 
parameters.size(); ++row) {
 
  341           for (
size_t col = row; col != 
parameters.size(); ++col) {
 
  356     template<
class JFunction_t>
 
  357     inline void update(
const JFunction_t& fit)
 
  359       for (
size_t row = 0; row != 
parameters.size(); ++row) {
 
  360         for (
size_t col = 0; col != row; ++col) {
 
  361           V(row,col) = 
V(col,row);
 
  374     static inline double get(
const JModel_t& 
model, 
double JModel_t::*parameter)
 
  376       return model.*parameter;
 
  387     static inline double& 
get(JModel_t& 
model, 
double JModel_t::*parameter)
 
  389       return model.*parameter;
 
  400     static inline double get(
const JModel_t& 
model, 
const size_t index)
 
  413     static inline double& 
get(JModel_t& 
model, 
const size_t index)
 
  426     static inline double get(
const JModel_t& 
model, 
const int index)
 
  439     static inline double& 
get(JModel_t& 
model, 
const int index)
 
  462   template<
class JModel_t>
 
  469   template<
class JModel_t>
 
  476   template<
class JModel_t>
 
  483   template<
class JModel_t>
 
  490   template<
class JModel_t>
 
  497   template<
class JModel_t>
 
  504   template<
class JModel_t>
 
static int debug
debug level (default is off). 
 
double lambda
control parameter 
 
static double EPSILON
maximal distance to minimum 
 
static double PIVOT
minimal value diagonal element of Hesse matrix 
 
JMATH::JMatrixNS V
Hesse matrix. 
 
static const JZero zero
Function object to assign zero value. 
 
JMatrixND & reset()
Set matrix to the null matrix. 
 
Auxiliary data structure for floating point format specification. 
 
std::vector< parameter_type > parameters
fit parameters 
 
void resize(const size_t size)
Resize matrix. 
 
static double LAMBDA_MIN
minimal value control parameter 
 
static double LAMBDA_DOWN
multiplication factor control parameter 
 
Definition of zero value for any class. 
 
void reset()
Reset current parameters. 
 
void update(const JFunction_t &fit)
Termination method to update current parameters. 
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
JModel_t gradient
partial derivatives of chi2 
 
result_type operator()(const JFunction_t &fit, T __begin, T __end, Args...args)
Multi-dimensional fit of multiple data sets. 
 
void update(const JFunction_t &fit, T __begin, T __end, Args...args)
Recursive method to update current parameters. 
 
struct JFIT::JGandalf::@10 current
 
General purpose messaging. 
 
static double LAMBDA_UP
multiplication factor control parameter 
 
void invert()
Invert matrix according LDU decomposition. 
 
Fit method based on the Levenberg-Marquardt method. 
 
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
 
Data structure for return value of fit function. 
 
void solve(JVectorND_t &u)
Get solution of equation A x = b. 
 
result_type(const double chi2, const JModel_t &model)
Constructor. 
 
static int MAXIMUM_ITERATIONS
maximal number of iterations 
 
int numberOfIterations
number of iterations 
 
static double LAMBDA_MAX
maximal value control parameter 
 
result_type()
Default constructor. 
 
struct JFIT::JGandalf::@11 previous
 
JModel_t::parameter_type parameter_type
Data type of fit parameter. 
 
#define DEBUG(A)
Message macros. 
 
Auxiliary class for handling debug parameter within a class. 
 
JGandalf()
Default constructor.