Example based on http://stat.ethz.ch/R-manual/R-devel/library/stats/html/optim.html 
 
 
{
}
 
{
   grad[0]=-400 * 
x * (
y - 
x * 
x) - 2 * (1 - 
x);
 
   grad[1]=200 * (
y - 
x * 
x);
 
   return grad;
}
 
{
 
   
 
   
   
 
   
   
   
   r.Execute(
"result <- optim( c(0.01,0.01), RosenBrock,method='BFGS',control = list(maxit = 1000000) )");
 
   
 
   
 
   std::cout.precision(8);
   
   std::cout<<"-----------------------------------------"<<std::endl;
   std::cout<<"Minimum x="<<min[0]<<" y="<<min[1]<<std::endl;
   std::cout<<
"Value at minimum ="<<
RosenBrock(min)<<std::endl;
 
 
   
   r.Execute(
"optimHess(result$par, RosenBrock, RosenBrockGrad)");
 
   r.Execute(
"hresult <- optim(c(-1.2,1), RosenBrock, NULL, method = 'BFGS', hessian = TRUE)");
 
   
 
   
   std::cout<<"-----------------------------------------"<<std::endl;
   std::cout<<"Minimization with the Gradient"<<std::endl;
   std::cout<<
"Minimum x="<<
hmin[0]<<
" y="<<
hmin[1]<<std::endl;
 
}
double Double_t
Double 8 bytes.
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t hmin
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
 
This is a class to pass functions from ROOT to R.
 
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
 
static TRInterface & Instance()
static method to get an TRInterface instance reference
 
- Author
 - Omar Zapata 
 
Definition in file Minimization.C.