18 #include <iomanip.hpp>
50 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
51 int n = [](
unsigned int colsize) ->
int
53 assert(colsize <= INT_MAX);
54 return static_cast<int>(colsize);
57 int n =
static_cast<int>(aa.
colsize());
64 cerr <<
"Error matrix not square in det()"<<
endl;
70 double big,dum,
sum,temp;
79 double* pvvi = vv.
get_v() + lb;
83 double* pbbij = pbbi->
get_v() + lb;
95 cerr <<
"Error in matrix inverse -- matrix singular in "
107 double* pvvj = vv.
get_v() + lb;
113 sum = *(pbbi->
get_v() + j);
115 double* pbbik = pbbi->
get_v() + lb;
119 sum = sum - *pbbik * *(pbbk->
get_v() + j);
125 *(pbbi->
get_v() + j) = sum;
132 pvvi = vv.
get_v() + j;
135 sum = *(pbbi->
get_v() + j);
137 double* pbbik = pbbi->
get_v() + lb;
141 sum = sum - *pbbik * *(pbbk->
get_v() + j);
145 *(pbbi->
get_v() + j) = sum;
146 dum = *pvvi *
fabs(sum);
157 double* pbbimaxk = bb(imax).get_v() + lb;
158 double* pbbjk = pbbj->
get_v() + lb;
170 vv.
elem(imax) = *pvvj;
174 int itemp=indx.
elem(imax);
181 double* pbbjj = pbbj->
get_v() + j;
192 for (i=j+1;i<=ub;i++)
194 *(pbbi->
get_v() + j) *= dum;
201 double bb11 = bb(1, 1);
203 part_prod(1)=ld+
log(bb11);
206 part_prod(1)=ld+
log(-bb11);
210 for (j=lb+1;j<=ub;j++)
212 double bbjj = bb(j, j);
214 part_prod(j)=part_prod(j-1)+
log(bbjj);
217 part_prod(j)=part_prod(j-1)+
log(-(bbjj));
221 double ldet=part_prod(ub);
272 #ifndef SAFE_INITIALIZE
277 dfpart_prod(ub)=dfdet;
279 double* pdfpart_prodj = dfpart_prod.
get_v() + ub;
280 double* pdfpart_prodj_1 = dfpart_prod.
get_v() + ub - 1;
283 for (
int j=ub;j>=lb+1;j--)
285 double bjj = *(pbj->
get_v() + j);
286 double* pdfbjj = pdfbj->
get_v() + j;
290 *pdfpart_prodj_1 += *pdfpart_prodj;
291 *pdfbjj += *pdfpart_prodj / bjj;
296 *pdfpart_prodj_1 += *pdfpart_prodj;
297 *pdfbjj += *pdfpart_prodj / bjj;
299 *pdfpart_prodj = 0.0;
307 dfb(lb,lb)+=dfpart_prod(lb)/b(lb,lb);
308 dfpart_prod(lb) = 0.0;
313 for (
int j=ub;j>=lb;j--)
315 double bjj = *(pbj->
get_v() + j);
316 double* pdfbjj = pdfbj->
get_v() + j;
318 int* pindxi = indx.
get_v() + ub;
320 for (
int i=ub;i>=lb;i--)
322 double* pdfbij = pdfbi->
get_v() + j;
332 dfsum += *pdfbij / bjj;
333 *pdfbjj -= *pdfbij * *(pbi->
get_v() + j) / bjj;
337 for (
int k=
min(i-1,j-1);k>=lb;k--)
340 dfb(i,k)-=dfsum*b(k,j);
341 dfb(k,j)-=dfsum*b(i,k);
Description not yet available.
Description not yet available.
double restore_prevariable_derivative()
void save_ivector_position(const ivector &v)
void dfinvpret(void)
Adjoint code for dvar_matrix inv(const dvar_matrix& aa).
Vector of double precision numbers.
ivector_position restore_ivector_position()
void save_dmatrix_position(const dmatrix &m)
dvar_vector nograd_assign(dvector tmp)
Description not yet available.
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
df1_two_variable fabs(const df1_two_variable &x)
dmatrix_position restore_dmatrix_position()
Description not yet available.
void save_dmatrix_value(const dmatrix &m)
void verify_identifier_string(const char *)
Verifies gradient stack string.
void fill_seqadd(int, int)
Fills ivector elements with values starting from base and incremented by offset.
dvector restore_dvector_value(const dvector_position &tmp)
dmatrix restore_dmatrix_value(const dmatrix_position &mpos)
ivector sgn(const dvector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void set_gradient_stack(void(*func)(void), double *dep_addr, double *ind_addr1=NULL, double mult1=0, double *ind_addr2=NULL, double mult2=0)
Description not yet available.
void save_dvector_position(const dvector &v)
prnstream & endl(prnstream &)
Array of integers(int) with indexes from index_min to indexmax.
void save_prevariable_position(const prevariable &v)
void save_dvector_value(const dvector &v)
Description not yet available.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
double restore_double_value()
Description not yet available.
void initialize(void)
Initialze all elements of dvector to zero.
int save_identifier_string(const char *)
Writes a gradient stack verification string.
double ln_det(const dmatrix &m1, int &sgn)
Compute log determinant of a constant matrix.
dvector_position restore_dvector_position()
dvar_matrix_position restore_dvar_matrix_position()
static _THREAD DF_FILE * fp
void save_dvar_matrix_position(const dvar_matrix &m)
ivector restore_ivector_value(const ivector_position &tmp)
Description not yet available.
Class definition of matrix with derivitive information .
Stores the adjoint gradient data that will be processed by gradcalc.
void df_xldet(void)
Adjoint code for dvariable ln_det(const dvar_matrix& aa, int& sgn).
void save_double_value(double x)
dvector value(const df1_one_vector &v)
static _THREAD grad_stack * GRAD_STACK1
void save_dmatrix_derivatives(const dvar_matrix_position &_pos, const double x, const int &i, int &j)
Description not yet available.
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Fundamental data type for reverse mode automatic differentiation.
void save_ivector_value(const ivector &v)
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Description not yet available.
unsigned int colsize() const