00001 /* 00002 * $Id$ 00003 * 00004 * Author: David Fournier 00005 * Copyright (c) 2008-2012 Regents of the University of California 00006 */ 00007 #include <admodel.h> 00008 00009 # include <df1b2fun.h> 00010 # include <adrndeff.h> 00011 00012 dvariable function_minimizer::do_gauss_hermite_integration(void) 00013 { 00014 if (lapprox->gh->mi) 00015 { 00016 return do_gauss_hermite_integration_multi(); 00017 } 00018 else 00019 { 00020 dvariable fun=0.0; 00021 int nsc=lapprox->num_separable_calls; 00022 dvector& w=lapprox->gh->w; 00023 for (int is=1;is<=nsc;is++) 00024 { 00025 fun-=log(1.e-50+exp(-lapprox->gh->gauss_hermite_values(is))*w); 00026 } 00027 return fun; 00028 } 00029 } 00030 00031 dvariable function_minimizer::do_gauss_hermite_integration_multi(void) 00032 { 00033 multi_index mi=*(lapprox->gh->mi); 00034 dvariable fun=0.0; 00035 int nsc=lapprox->num_separable_calls; 00036 dvector& w=lapprox->gh->w; 00037 ivector& lrea = *(lapprox->num_local_re_array); 00038 for (int isc=1;isc<=nsc;isc++) 00039 { 00040 dvariable ftmp=0.0; 00041 int lus=lrea(isc); 00042 mi.initialize(); 00043 double ww; 00044 do 00045 { 00046 ww=1.0; 00047 for (int iu=1;iu<=lus;iu++) 00048 { 00049 ww*= w(mi()(iu)); 00050 } 00051 int is=mi.get_offset()+1; 00052 ftmp+=exp(-lapprox->gh->gauss_hermite_values(isc,is))*ww; 00053 ++mi; 00054 } 00055 while(mi.get_depth()<=lus); 00056 fun-=log(ftmp); 00057 } 00058 return fun; 00059 }
Generated on Tue Mar 8 2016 19:51:35 for ADMB Documentation by 1.8.0 |