Rev 5272 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
/* $Id: nlOptimizer.c,v 1.3 2000/07/03 18:22:49 bates Exp $Implementation of eval_model() and spread() for R.Copyright 1999 Saikat DebRoy <saikat@stat.wisc.edu>This file is part of the nlme library 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 PublicLicense along with this program; if not, write to the FreeSoftware Foundation, Inc., 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA*/#include "nlOptimizer.h"#ifndef R_S_H#include "nonlin.h"#endif /* R_S_H */intevaluate(double *param, longint nParam aMOD, double **value aSEV){#ifdef R_S_HSEXP newPars, result;int i, nResult;PROTECT(newPars = allocVector(REALSXP, nParam));for(i = 0; i < nParam; i++)REAL(newPars)[i] = param[i];PROTECT(result = eval(lang2(model, newPars), R_GlobalEnv));nResult = LENGTH(result);if(value[0] == (double *) 0) {UNPROTECT(2);return(nResult);}for(i = 0; i < nResult; i++)value[0][i] = REAL(result)[i];UNPROTECT(2);#elsespread(param, nParam SEV);eval_model(TRUE SEV);value[0] = nl_results[0];#endifreturn(-1);}