24 a_fn::a_fn(
int nv,
double dmin,
double gmin) : nv_(nv), dmin_(dmin), gmin_(gmin)
38 o << (*x_)(0) << std::endl;
41 for (
int i = 0; i <
nv_-1; i++)
43 o << (*x_)(
nv_-1) << std::endl;
49 for (
int i = 0; i <
nv_; i++)
55 double p0 = (*x_)(ai);
57 (*x_)(ai) = p0-
dmin_/2.;
58 double Fmin = this->
getF();
59 (*x_)(ai) = p0+
dmin_/2.;
60 double Fmax = this->
getF();
62 return (Fmax-Fmin)/
dmin_;
67 for (
int i = 0; i <
nv_; i++)
68 grad(i) = this->
getdF(i);
73 double ax = this->
getX(ai);
74 double dfp = this->
getdF(ai);
75 double fp = this->
getF();
76 (*x_)(ai) = ax-fp/dfp;
81 double f0 = this->
getF();
82 double df = this->
getdF(ai);
88 double f = this->
getF();
98 for (
int i = 0; i <
nv_; i++)
99 (*
x_)(i) += dir(i)*alpha;
102 void a_fn::go(
double alpha,
const a_mat_c& dir)
104 for (
int i = 0; i <
nv_; i++)
105 (*
x_)(i) = (*
x0_)(i) + dir(i)*alpha;
113 double a_fn::gF(
double alpha,
const a_mat_c& dir)
121 double f0 = this->
getF();
122 const double p = 0.381966011249;
123 double crit0 = (B1-A1)/1.e10;
137 f1 = this->gF(x1,dir);
142 f2 = this->gF(x2,dir);
149 t1 =
true; t2 =
false;
155 t1 =
true; t2 =
true;
162 t1 =
false; t2 =
true;
167 double f = this->
getF();
170 std::cout <<
"f>f0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
177 double f0 = this->
getF();
190 double f = this->gF(0,dir);
192 di = di0*exp(k*log(0.1));
204 if (iter ==1 ) prov++;
207 double A1 = i-di-di/2.;
209 std::cout <<
"A1: " << A1 <<
" B1: " << B1 << std::endl;
211 double f = this->
getF();
214 std::cout <<
"minGold----------------------------" << std::endl;
222 std::cout <<
"minGold0++++++++++++++++++++++++++++" << std::endl;
234 std::cout <<
"f: " << this->
getF() << std::endl;
245 for (
int j = 0; j <
nv_; j++)
247 if (this->
getdF(j)>0)
277 for (
int i = 0; i < nv; i++)
297 double f = this->
getF();
315 std::cout <<
"i" << iter <<
" f: " << f << std::endl;
328 if ((d1 != 0)&&(iter % 10))
a_quaternion sqrt(const a_quaternion &x)
void minGold(const a_mat_c &dir)
void showX(std::ostream &o)
void setX(const a_mat_c &)
void incr(double alpha, const a_mat_c &dir)
void minGold0(const a_mat_c &dir, double A1, double B1)
a_fn(int nv=1, double dmin=1.e-5, double gmin=1e-6)