1#ifndef TTTRLIB_I_BFGS_H
2#define TTTRLIB_I_BFGS_H
10#include "lbfgs/lbfgs.h"
16int fjac1(
void (*)(
double*,
double*),
double*,
int,
int,
double,
double*);
18int fgrad1(
void (*)(
double*,
double&),
double*,
int,
double,
double*);
20int fjac2(
void (*)(
double*,
double*),
double*,
int,
int,
double,
double*);
22int fgrad2(
void (*)(
double*,
double&),
double*,
int,
double,
double*);
24int fjac4(
void (*)(
double*,
double*),
double*,
int,
int,
double,
double*);
26int fgrad4(
void (*)(
double*,
double&),
double*,
int,
double,
double*);
37 if (N>0) {
delete[] xd;
delete[] fixed; }
42 if (N>0) {
delete[] xd;
delete[] fixed; }
46 for(
int i=0; i<N; i++) fixed[i] = 0;
57 double x1 = 1.0, x2 = 1.0, e = 1.e-18, estep = 1.001;
84 int info = 0, bfgsM, Nfree = 0, j = 1;
85 for(
int i=0; i<N; i++) {
89 Nfree < 7 ? bfgsM = Nfree : bfgsM = 7;
93 X.setbounds(1, Nfree);
94 for(
int i=0; i<N; i++)
95 if (!fixed[i]) X(j++) = x[i];
99 lbfgsminimize(Nfree, bfgsM, X, sqrt_eps, eps, sqrt_eps,
maxiter, info);
103 for(
int i=0; i<N; i++)
104 if (!fixed[i]) x[i] = X(j++);
128 void lbfgsminimize(
const int&,
const int&, ap::real_1d_array&,
const double&,
const double&,
129 const double&,
const int&,
int&);
130 void lbfgslincomb(
const int&,
const double&,
const ap::real_1d_array&,
131 int, ap::real_1d_array&,
int);
132 double lbfgsdotproduct(
const int&,
const ap::real_1d_array&,
int,
133 const ap::real_1d_array&,
int);
134 void lbfgsmcsrch(
const int&, ap::real_1d_array&,
double&, ap::real_1d_array&,
135 const ap::real_1d_array&,
int,
double&,
const double&,
const double&,
const int&,
136 int&,
int&, ap::real_1d_array&,
const double&,
const double&,
const double&);
137 void lbfgsmcstep(
double&,
double&,
double&,
double&,
double&,
double&,
double&,
138 const double&,
const double&,
bool&,
const double&,
const double&,
int&);
139 void lbfgsnewiteration(
const ap::real_1d_array&,
double,
const ap::real_1d_array&);
142 void fgrad1(ap::real_1d_array&,
double&, ap::real_1d_array&);
143 void fgrad2(ap::real_1d_array&,
double&, ap::real_1d_array&);
144 void fgrad4(ap::real_1d_array&,
double&, ap::real_1d_array&);
145 void funcgrad(ap::real_1d_array& x,
double& fval, ap::real_1d_array& g) { fgrad2(x, fval, g); }
void seteps()
Definition i_lbfgs.h:56
void free(int n)
Definition i_lbfgs.h:71
int minimize(double *x, void *p)
Definition i_lbfgs.h:80
void fix(int n)
Definition i_lbfgs.h:67
void setN(int n)
Definition i_lbfgs.h:41
bfgs(TargetFP fun, int n)
Definition i_lbfgs.h:35
int maxiter
Definition i_lbfgs.h:77
void seteps(double e)
Definition i_lbfgs.h:50
bfgs(TargetFP fun)
Definition i_lbfgs.h:34
~bfgs()
Definition i_lbfgs.h:36
int fjac2(void(*)(double *, double *), double *, int, int, double, double *)
int fjac4(void(*)(double *, double *), double *, int, int, double, double *)
int fgrad2(void(*)(double *, double &), double *, int, double, double *)
int fgrad1(void(*)(double *, double &), double *, int, double, double *)
int fjac1(void(*)(double *, double *), double *, int, int, double, double *)
double(* TargetFP)(double *, void *)
Definition i_lbfgs.h:14
int fgrad4(void(*)(double *, double &), double *, int, double, double *)