Rev 6817 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
/*Implementation of eval_model() and spread() for R.Copyright 1999 Saikat DebRoyCopyright 2007-2016 The R Core TeamThis file is part of the nlme package for S and related languagesand is made available under the terms of the GNU General PublicLicense, version 2, or at your option, any later version,incorporated herein by reference.This program is distributed in the hope that it will beuseful, but WITHOUT ANY WARRANTY; without even the impliedwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULARPURPOSE. See the GNU General Public License for moredetails.You should have received a copy of the GNU General Public Licensealong with this program; if not, a copy is available athttp://www.r-project.org/Licenses/*/#include "nlOptimizer.h"intevaluate(double *param, int nParam, SEXP model, double **value){SEXP newPars, call, result;int i, nResult;PROTECT(newPars = allocVector(REALSXP, nParam));PROTECT(model);for(i = 0; i < nParam; i++)REAL(newPars)[i] = param[i];PROTECT(call = lang2(model, newPars));PROTECT(result = eval(call, R_GlobalEnv));nResult = LENGTH(result);if(value[0] == (double *) 0) {UNPROTECT(4);return(nResult);}double *res = REAL(result);for(i = 0; i < nResult; i++)value[0][i] = res[i];UNPROTECT(4);return(-1);}