33 static_cast<vnl_conjugate_gradient*>(userdata);
37 self->num_evaluations_++;
45 static_cast<vnl_conjugate_gradient*>(userdata);
50 f->
gradf(ref_x, ref_g);
56 static_cast<vnl_conjugate_gradient*>(userdata);
70 static_cast<vnl_conjugate_gradient*>(userdata);
74 for (
int i=0; i < n; ++i)
82 double max_norm_of_gradient;
83 long number_of_iterations;
85 double gradient_tolerance =
gtol;
97 &max_norm_of_gradient,
98 &number_of_iterations,
108 workspace.data_block(),
120 case 1: std::cout <<
"UNABLE TO OBTAIN DESCENT DIRECTION\n";
break;
121 case 2: std::cout <<
"THE FUNCTION DECREASES WITH NO MINIMUM\n";
break;
122 case 3: std::cout <<
"PRECONDITIONER NOT POSITIVE DEFINITE\n";
break;
123 case 4: std::cout <<
"UNABLE TO SATISFY ARMIJO CONDITION\n";
break;
124 default: std::cout <<
"UNKNOWN ERROR CODE\n";
break;
133 return error_code == 0;
139 os <<
"vnl_conjugate_gradient: " 143 <<
" evaluations. Cost function reported error" An object that represents a function from R^n -> R.
virtual void gradf(vnl_vector< double > const &x, vnl_vector< double > &gradient)
Calculate the gradient of f at parameter vector x.
int get_number_of_unknowns() const
Return the number of unknowns.
static double valuecomputer_(double *x, void *userdata)
vnl_vector using user-supplied storage
~vnl_conjugate_gradient() override
Destructor.
vnl_vector using user-supplied storage.
real function minimization
T const * data_block() const
Access the contiguous block storing the elements in the vector. O(1).
double f(vnl_vector< double > const &x) override
The main function. Given the parameter vector x, compute the value of f(x).
double gtol
Termination tolerance on Grad(F)' * F = 0.
void diagnose_outcome() const
Declare in a central place the list of symbols from netlib.
static void preconditioner_(double *out, double *in, void *userdata)
bool minimize(vnl_vector< double > &x)
Minimize the function supplied in the constructor until convergence or failure.
virtual void compute(vnl_vector< double > const &x, double *f, vnl_vector< double > *g)
Compute one or both of f and g.
long maxfev
Termination maximum number of iterations.
void init(vnl_cost_function &f)
Initialize all variables.
virtual double reported_error(double f_value)
Called when error is printed for user.
static void gradientcomputer_(double *g, double *x, void *userdata)
ReturnCodes failure_code_
static void valueandgradientcomputer_(double *v, double *g, double *x, void *userdata)