bnosac / dlib

allowing R users to work with dlib through Rcpp
13 stars 2 forks source link

Using optimization.h in Rcpp #2

Closed Vivianstats closed 6 years ago

Vivianstats commented 7 years ago

Thank you very much for this package! I want to do constrained optimization with Rcpp and found this package helpful.

I would like to test the examples given in optimization_ex.cpp.html (http://dlib.net/optimization_ex.cpp.html) in Rcpp but got the following message:

no matching constructor for initialization of 'dlib::matrix<double,0,1, dlib::memory_manager_stateless_kernel_1,dlib::row_major_layout>'

Below are my codes:

include

using namespace Rcpp; // [[Rcpp::plugins(cpp11)]] // [[Rcpp::depends(dlib)]]

include <dlib/optimization.h>

using namespace dlib; using namespace std; typedef matrix<double,0,1> column_vector; // [[Rcpp::export]] double rosen (const column_vector& m) { //const column_vector m; //const double x = m(0); //const double y = m(1); const double x = 1; const double y = 1; double res = 100.0pow(y - xx,2) + pow(1 - x,2); return(res); }

Can you provide me with some guidance on the problem? Thanks.

jwijffels commented 7 years ago

Vivian, I only used this package for image recognition, not on optimisation. If you have questions on the C++ part, I believe you should better redirect your question to the dlib mailing list.

Vivianstats commented 7 years ago

Thanks for the information. Since I'm just using the examples codes given in the dlib library, I think the problem might be in the interface between R and Rcpp, but I didn't figure out the solution yet.

jwijffels commented 7 years ago

Blindly copy-pasting the examples also did not work out for me when I implemented image.dlib on top of dlib https://github.com/bnosac/image/tree/master/image.dlib. Your error indicates that there is no matching constructor. That looks like you did not load the right header files but again I'm not an expert in the optimisation header.

jwijffels commented 6 years ago

Closing as no active feedback given in last month.