Disclaimer: I searched for the answer using the keywords: R, optimization, C ++, C, optimization, maxima, minima, local maximum, optimization, Newton's method, descent of the gradient, etc. and did not find satisfactory answers. R optimizing the manual page gives Fortran source code, but not C translation. Please let me know if I should look for other keywords or if you can quickly find a website that clearly answers this question.
Question: I am new to C ++ and want to convert one of my R programs to C ++. I am using the optimization function in R and want to know if there are any libraries / header / function files in C ++ that will easily give me the same results. Give an example, if possible.
Here is a simple optimization example R, maximizing f (p) = p * (1-p) over (0,1), where the maximum is p = 0.5 and f (0.5) = 0.25:
> optimize(function(p) p*(1-p),c(0,1),maximum=T) $maximum [1] 0.5 $objective [1] 0.25
Thank you for your help!
source share