Revision 1109 trunk/src/df1b2separable/df1b2gh.cpp
df1b2gh.cpp (revision 1109)  

2  2 
* $Id$ 
3  3 
* 
4  4 
* Author: David Fournier 
5 
* Copyright (c) 20082012 Regents of the University of California


5 
* Copyright (c) 20082012 Regents of the University of California 

6  6 
*/ 
7  7 
/** 
8  8 
* \file 
...  ...  
33  33 
int hroom = sum(square(lrea)); 
34  34 
int nvar=x.size()+u0.size()+hroom; 
35  35 
independent_variables y(1,nvar); 
36 


36  
37  37 
// need to set random effects active together with whatever 
38  38 
// init parameters should be active in this phase 
39 
initial_params::set_inactive_only_random_effects();


40 
initial_params::set_active_random_effects();


41 
/*int onvar=*/initial_params::nvarcalc();


39 
initial_params::set_inactive_only_random_effects(); 

40 
initial_params::set_active_random_effects(); 

41 
/*int onvar=*/initial_params::nvarcalc(); 

42  42 
initial_params::xinit(y); // get the initial values into the 
43  43 
// do we need this next line? 
44  44 
y(1,xs)=x; 
...  ...  
53  53 
quadratic_prior::get_cHessian_contribution(Hess,vxs); 
54  54 
} 
55  55 
// Here need hooks for sparse matrix structures 
56 


56  
57  57 
dvar3_array & block_diagonal_vhessian= 
58  58 
*pmin>lapprox>block_diagonal_vhessian; 
59  59 
block_diagonal_vhessian.initialize(); 
...  ...  
74  74 
dvector g(1,nvar); 
75  75 
gradcalc(0,g); 
76  76 
gradient_structure::set_YES_DERIVATIVES(); 
77 
dvar_vector vy=dvar_vector(y);


77 
dvar_vector vy=dvar_vector(y); 

78  78 
//initial_params::stddev_vscale(d,vy); 
79  79 
ii=xs+us+1; 
80  80 
if (initial_df1b2params::have_bounded_random_effects) 
...  ...  
132  132 
offset+=lus; 
133  133 
} 
134  134 
} 
135 


135  
136  136 
// have to reorder the terms to match the block diagonal hessian 
137  137 
imatrix & ls=*(pmin>lapprox>block_diagonal_re_list); 
138  138 
int mmin=ls.indexmin(); 
139  139 
int mmax=ls.indexmax(); 
140 


140  
141  141 
int ii=1; 
142  142 
int i; 
143  143 
for (i=mmin;i<=mmax;i++) 
...  ...  
202  202 
} 
203  203  
204  204 
vf+=ld; 
205 
//vf+=us*0.91893853320467241;


205 
//vf+=us*0.91893853320467241; 

206  206  
207  207 
double f=value(vf); 
208  208 
gradcalc(nvar,g); 
...  ...  
212  212 
vy(xs+1,xs+us).shift(1)=u0; 
213  213 
initial_params::reset(vy); // get the values into the model 
214  214 
gradient_structure::set_YES_DERIVATIVES(); 
215 


215  
216  216 
pmin>lapprox>in_gauss_hermite_phase=0; 
217 


217  
218  218 
ii=1; 
219  219 
for (i=1;i<=xs;i++) 
220  220 
xadjoint(i)=g(ii++); 
Also available in: Unified diff