22 return 100*tmp1*tmp1+tmp2*tmp2;
30 grad[0]=-400 *
x * (
y -
x *
x) - 2 * (1 -
x);
31 grad[1]=200 * (
y -
x *
x);
49 r.
Execute(
"result <- optim( c(0.01,0.01), RosenBrock,method='BFGS',control = list(maxit = 1000000) )");
55 std::cout.precision(8);
57 std::cout<<
"-----------------------------------------"<<std::endl;
58 std::cout<<
"Minimum x="<<min[0]<<
" y="<<min[1]<<std::endl;
59 std::cout<<
"Value at minimum ="<<RosenBrock(min)<<std::endl;
62 r.
Execute(
"optimHess(result$par, RosenBrock, RosenBrockGrad)");
63 r.
Execute(
"hresult <- optim(c(-1.2,1), RosenBrock, NULL, method = 'BFGS', hessian = TRUE)");
68 std::cout<<
"-----------------------------------------"<<std::endl;
69 std::cout<<
"Minimization with the Gradient"<<std::endl;
70 std::cout<<
"Minimum x="<<hmin[0]<<
" y="<<hmin[1]<<std::endl;
71 std::cout<<
"Value at minimum ="<<RosenBrock(hmin)<<std::endl;
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
void Execute(const TString &code)
Method to eval R code.
static TRInterface & Instance()
static method to get an TRInterface instance reference
Int_t Eval(const TString &code, TRObject &ans)
Method to eval R code and you get the result in a reference to TRObject.