Hi Yan, maybe you have an answer for me: I call the following in my code:
119 nlopt::opt opt_GMM = nlopt::opt(nlopt::NLOPT_LD_LBFGS, 3); 120 opt_GMM.set_min_objective(objective_fun, &sample); 121 nlopt::result opt_GMM.optimize(&opar, &funv); I compile it via R CMD INSTALL .... and I get: MCgmmS.cc:119: error: 'NLOPT_LD_LBFGS' is not a member of 'nlopt' MCgmmS.cc:121: error: expected initializer before '.' token My Makevars looks like this: PKG_CPPFLAGS = -Inlopt-2.3/include -g -O1 PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -Lnlopt-2.3/libs/ -lnlopt I use this reference from NLopt: http://ab-initio.mit.edu/wiki/index.php/NLopt_C-plus-plus_Reference#Objective_function In some way the compiler doesn't find the algorithm object.... did you implemented your version in C or C++? Best Simon On Feb 3, 2013, at 6:26 PM, Yan Zhou <zhou...@me.com> wrote: > Yes, of course. > > I was thinking about the situation where NLOpt pass the parameter and > (possible) gradient vector through pointers and you need to use Armadillo on > these vectors. But if all you need is to pass a matrix as the function data, > in principle you can pass almost anything through void *. > > Best, > > Yan Zhou > > On Feb 03, 2013, at 05:13 PM, Simon Zehnder <szehn...@uni-bonn.de> wrote: > >> Mmmmmh, I just think about the function data: It is pointed to via void*. >> That should give me the possibility to directly point to a arma::mat, right? >> That would be the easiest way to do it. >> >> Best >> >> Simon >> On Feb 3, 2013, at 5:45 PM, Yan Zhou <zhou...@me.com> wrote: >> >> > I believe the answer is no. But most Arma object provide memptr to get the >> > raw pointer which you can pass through nlopt interface. Inside the >> > objective function you can create Arma object using auxiliary pointer. >> > AFAIK, for const double * argument you can only creat Arma object by copy >> > while for double * you can creat object that use the pointer directly. >> > After this step you can use armadillo inside and outside the objective >> > function. >> > >> > Best, >> > >> > Yan >> > >> > On Feb 3, 2013, at 4:35 PM, Simon Zehnder <szehn...@uni-bonn.de> wrote: >> > >> >> Hi Yan, >> >> >> >> do you know if one can also write a C++ objective function in NLOpt, that >> >> works with Armadillo Objects? >> >> >> >> Best >> >> >> >> Simon >> >> >> >> On Feb 3, 2013, at 12:50 PM, Yan Zhou <zhou...@me.com> wrote: >> >> >> >>> I good numerical optimization library I used before is NLOpt, for >> >>> non-linear optimization. http://ab-initio.mit.edu/wiki/index.php/NLopt >> >>> >> >>> You can use it just like and C/C++ library in your own code or you can >> >>> use its own R interface as an R package. >> >>> >> >>> Best, >> >>> >> >>> Yan >> >>> >> >>> On Feb 3, 2013, at 11:47 AM, Simon Zehnder <szehn...@uni-bonn.de> wrote: >> >>> >> >>>> Hi fellows, >> >>>> >> >>>> I am using the RcppArmadillo package and I need in C++ some >> >>>> optimization methods. Before I used always the Scythe Statistical >> >>>> Library which had both: linear algebra and optimization methods. >> >>>> Armadillo has only linear algebra support. >> >>>> >> >>>> Now my question: What numerical optimization libraries in C++ do you >> >>>> use, when working with RcppArmadillo? It should be fast! >> >>>> >> >>>> >> >>>> Best >> >>>> >> >>>> Simon >> >>>> >> >>>> >> >>>> _______________________________________________ >> >>>> Rcpp-devel mailing list >> >>>> Rcpp-devel@lists.r-forge.r-project.org >> >>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel >> >>> >> >> >>
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel