ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
xmodelm5.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
7 #include <admodel.h>
8 
9 # include <df1b2fun.h>
10 # include <adrndeff.h>
11 
13 {
14  if (lapprox->gh->mi)
15  {
17  }
18  else
19  {
20  dvariable fun=0.0;
22  dvector& w=lapprox->gh->w;
23  for (int is=1;is<=nsc;is++)
24  {
25  fun-=log(1.e-50+exp(-lapprox->gh->gauss_hermite_values(is))*w);
26  }
27  return fun;
28  }
29 }
30 
32 {
33  multi_index mi=*(lapprox->gh->mi);
34  dvariable fun=0.0;
36  dvector& w=lapprox->gh->w;
38  for (int isc=1;isc<=nsc;isc++)
39  {
40  dvariable ftmp=0.0;
41  int lus=lrea(isc);
42  mi.initialize();
43  double ww;
44  do
45  {
46  ww=1.0;
47  for (int iu=1;iu<=lus;iu++)
48  {
49  ww*= w(mi()(iu));
50  }
51  int is=mi.get_offset()+1;
52  ftmp+=exp(-lapprox->gh->gauss_hermite_values(isc,is))*ww;
53  ++mi;
54  }
55  while(mi.get_depth()<=lus);
56  fun-=log(ftmp);
57  }
58  return fun;
59 }
laplace_approximation_calculator * lapprox
Definition: admodel.h:1862
Description not yet available.
Vector of double precision numbers.
Definition: dvector.h:50
int get_depth(void)
Definition: fvar.hpp:9235
Description not yet available.
Definition: fvar.hpp:9222
dvariable do_gauss_hermite_integration_multi(void)
Definition: xmodelm5.cpp:31
gauss_hermite_stuff * gh
Definition: adrndeff.h:223
dvariable do_gauss_hermite_integration(void)
Definition: xmodelm5.cpp:12
int get_offset(void)
Definition: multiindex.cpp:47
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
multi_index * mi
Definition: adrndeff.h:413
Description not yet available.
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
void initialize()
Description not yet available.
Definition: multiindex.cpp:65
#define w
dvar_matrix gauss_hermite_values
Definition: adrndeff.h:409
Description not yet available.
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13