Revision 1107 trunk/src/df1b2separable/quadpri.cpp
quadpri.cpp (revision 1107)  

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 
...  ...  
11  11 
#include <df1b2fnl.h> 
12  12 
//#include <df1b2fun.h> 
13  13  
14 
int quadratic_prior::in_qp_calculations=0;


14 
int quadratic_prior::in_qp_calculations=0; 

15  15  
16  16 
quadratic_prior * quadratic_prior::ptr[100]; // this should be a resizeable array 
17  17 
int quadratic_prior::num_quadratic_prior=0; 
...  ...  
39  39 
dvector evaluate_function_with_quadprior(const dvector& x,int usize, 
40  40 
function_minimizer * pfmin) 
41  41 
{ 
42 
int xsize=initial_params::nvarcalc();


42 
int xsize=initial_params::nvarcalc(); 

43  43 
dvector g(1,xsize); 
44  44 
gradcalc(0,g); 
45  45 
//double f=0.0; 
...  ...  
51  51 
dvar_matrix Hess_all(1,usize,1,usize); 
52  52 
*objective_function_value::pobjfun=0.0; 
53  53 
// so that dvar_matrix Hessian contributions are calculated 
54 
laplace_approximation_calculator::where_are_we_flag=3;


54 
laplace_approximation_calculator::where_are_we_flag=3; 

55  55 
pfmin>AD_uf_inner(); 
56  56 
if ( quadratic_prior::get_num_quadratic_prior()>0) 
57  57 
{ 
58  58 
quadratic_prior::get_M_calculations(); 
59  59 
} 
60 
laplace_approximation_calculator::where_are_we_flag=0;


60 
laplace_approximation_calculator::where_are_we_flag=0; 

61  61  
62  62 
*objective_function_value::pobjfun=0.0; 
63  63 
Hess_all=pfmin>lapprox>Hess; 
...  ...  
91  91 
* Description not yet available. 
92  92 
* \param 
93  93 
*/ 
94 
dvariable quadratic_prior::get_function(void)


95 
{


94 
dvariable quadratic_prior::get_function(void) 

95 
{ 

96  96 
return (*pu)*((*pMinv)*(*pu)); 
97  97 
} 
98  98  
...  ...  
100  100 
* Description not yet available. 
101  101 
* \param 
102  102 
*/ 
103 
dvar_matrix quadratic_prior::get_Hessian(void)


104 
{


103 
dvar_matrix quadratic_prior::get_Hessian(void) 

104 
{ 

105  105 
return *pMinv; 
106  106 
} 
107  107  
...  ...  
115  115 
int mmin=(*fpu)(fpu>indexmin()).get_ind_index(); 
116  116 
return mminxs1; 
117  117 
} 
118 
//dmatrix quadratic_prior::get_cHessian(void)


118 
//dmatrix quadratic_prior::get_cHessian(void) 

119  119  
120  120 
/** 
121  121 
* Description not yet available. 
122  122 
* \param 
123  123 
*/ 
124 
void quadratic_prior::get_cHessian(dmatrix H,int xsize)


125 
{


124 
void quadratic_prior::get_cHessian(dmatrix H,int xsize) 

125 
{ 

126  126 
int offset=get_offset(xsize); 
127  127 
int imin=pMinv>indexmin(); 
128  128 
int imax=pMinv>indexmax(); 
...  ...  
182  182 
* Description not yet available. 
183  183 
* \param 
184  184 
*/ 
185 
void quadratic_prior::get_cHessian(dvar_matrix H,int xsize)


186 
{


185 
void quadratic_prior::get_cHessian(dvar_matrix H,int xsize) 

186 
{ 

187  187 
int offset=get_offset(xsize); 
188  188 
int imin=pMinv>indexmin(); 
189  189 
int imax=pMinv>indexmax(); 
...  ...  
243  243 
* Description not yet available. 
244  244 
* \param 
Also available in: Unified diff