102 (
int _min,
int _max,
int _bw)
107 d.allocate(0,_bw-1,lb,_max);
118 for (
int i=0;i<=bw-1;i++)
134 for (
int i=0;i<=bw-1;i++)
147 ostream& ofs= (ostream&) _ofs;
155 for (
int i=imin;i<=imax;i++)
157 for (
int j=imin;j<=imax;j++)
170 ofs << S(i1,j1) <<
" ";
174 if (i<imax) ofs <<
endl;
176 return (ostream&)ofs;
184 (
int _min,
int _max,
int _bw)
189 d.allocate(0,_bw-1,lb,_max);
199 ostream& ofs= (ostream&) _ofs;
205 for (
int i=imin;i<=imax;i++)
207 for (
int j=imin;j<=imax;j++)
212 ofs << S(i,j) <<
" ";
221 if (i<imax) ofs <<
endl;
223 return (ostream&)ofs;
232 #include <iostream.h>
236 #include <iostream.hpp>
240 #include <iostream.h>
243 #include <iostream.h>
261 for (
int i=mmin;i<=mmax;i++)
278 #ifndef SAFE_INITIALIZE
286 cerr <<
"Error matrix not positive definite in choleski_decomp"
287 " value was " <<
M(1,1) <<
" for index 1" <<
endl;
299 int jmin=
admax(2,i-bw+1);
300 for (j=jmin;j<=i-1;j++)
303 int kmin=
max(1,j-bw+1,i-bw+1);
304 for (k=kmin;k<=j-1;k++)
311 int kmin=
admax(i-bw+1,1);
318 for (k=kmin;k<=i-1;k++)
325 cerr <<
"Error matrix not positive definite in choleski_decomp"
326 " value was " << tmp <<
" for index " << i <<
endl;
337 << CMM << endl<<
endl;
342 << ev << endl<<
endl;
344 << evec << endl<<
endl;
421 #ifndef SAFE_INITIALIZE
428 cerr <<
"Error matrix not positive definite in choleski_decomp"
436 L(i,1)=
M(i,1)/L(1,1);
441 int jmin=
admax(2,i-bw+1);
442 for (j=jmin;j<=i-1;j++)
445 int kmin=
max(1,j-bw+1,i-bw+1);
446 for (k=kmin;k<=j-1;k++)
448 tmp1(i,j)-=L(i,k)*L(j,k);
450 L(i,j)=tmp1(i,j)/L(j,j);
453 int kmin=
admax(i-bw+1,1);
460 for (k=kmin;k<=i-1;k++)
462 tmp(i)-=L(i,k)*L(i,k);
467 cerr <<
"Error matrix not positive definite in choleski_decomp"
481 dftmp(i)+=dfL(i,i)/(2.0*L(i,i));
483 int kmin=
admax(i-bw+1,1);
484 for (k=i-1;k>=kmin;k--)
487 dfL(i,k)-=2.*dftmp(i)*L(i,k);
492 int jmin=
admax(2,i-bw+1);
493 for (j=i-1;j>=jmin;j--)
496 double linv=1./L(j,j);
497 dftmp1(i,j)+=dfL(i,j)*linv;
498 dfL(j,j)-=dfL(i,j)*tmp1(i,j)*linv*linv;
500 kmin=
max(1,j-bw+1,i-bw+1);
501 for (k=j-1;k>=kmin;k--)
504 dfL(i,k)-=dftmp1(i,j)*L(j,k);
505 dfL(j,k)-=dftmp1(i,j)*L(i,k);
508 dfM(i,j)+=dftmp1(i,j);
512 double linv=1./L(1,1);
516 dfM(i,1)+=dfL(i,1)*linv;
517 dfL(1,1)-=dfL(i,1)*
M(i,1)*linv*linv;
521 dfM(1,1)+=dfL(1,1)/(2.*L(1,1));
545 for (
int i=imin;i<=imax;i++)
547 for (
int j=imin;j<=imax;j++)
560 (*this)(i,j)=S(i1,j1);
578 for (
int i=imin;i<=imax;i++)
580 for (
int j=imin;j<=imax;j++)
595 int max(
int i,
int j,
int k)
623 for (
int i=max;i>=
min;i--)
638 int& ierr=(
int&)(_ierr);
646 #ifndef SAFE_INITIALIZE
654 cerr <<
"Error matrix not positive definite in choleski_decomp"
655 " value was " <<
M(1,1) <<
" for index 1" <<
endl;
668 int jmin=
admax(2,i-bw+1);
669 for (j=jmin;j<=i-1;j++)
672 int kmin=
max(1,j-bw+1,i-bw+1);
673 for (k=kmin;k<=j-1;k++)
680 int kmin=
admax(i-bw+1,1);
681 for (k=kmin;k<=i-1;k++)
687 cerr <<
"Error matrix not positive definite in choleski_decomp"
688 " value was " << tmp <<
" for index " << i <<
endl;
713 for (
int i=1;i<=B.
bw-1;i++)
void save_dmatrix_derivatives(const dvar_matrix_position &) const
Description not yet available.
Description not yet available.
Description not yet available.
Base class for dvariable.
void initialize(void)
Description not yet available.
banded_lower_triangular_dmatrix restore_banded_lower_triangular_dvar_matrix_derivatives(const dvar_matrix_position &_pos)
Description not yet available.
double sumsq(const d3_array &a)
Vector of double precision numbers.
Description not yet available.
banded_lower_triangular_dvar_matrix(int _min, int _max, int _bw)
Description not yet available.
void initialize(void)
Zero initialize allocated dvar_matrix, then saves adjoint function and position data.
Description not yet available.
int bandwidth(void) const
double & elem_value(int i, int j)
void initialize(void)
Description not yet available.
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.
double norm(const d3_array &a)
Return computed norm value of a.
df1_one_matrix choleski_decomp(const df1_one_matrix &MM)
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 dfcholeski_decomp(void)
Description not yet available.
int bandwidth(void) const
prescientific setscientific(void)
Description not yet available.
prnstream & endl(prnstream &)
dmatrix eigenvectors(const banded_symmetric_dmatrix &_SS, const dvector &_e)
Description not yet available.
Array of integers(int) with indexes from index_min to indexmax.
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void initialize(void)
Description not yet available.
dvar_vector_position restore_dvar_vector_position()
Description not yet available.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void allocate(void)
Does not allocate, but initializes members.
void dfcholeski_decomp_banded(void)
Description not yet available.
Description not yet available.
banded_symmetric_dvar_matrix(int _min, int _max, int _bw)
Description not yet available.
Description not yet available.
void initialize(void)
Initialze all elements of dvector to zero.
double norm2(const d3_array &a)
Return sum of squared elements in a.
int save_identifier_string(const char *)
Writes a gradient stack verification string.
dvector restore_dvar_vector_value(const dvar_vector_position &tmp)
Restores the size, address, and value information for a dvar_vector.
dvar_matrix_position restore_dvar_matrix_position()
static _THREAD DF_FILE * fp
void save_dvar_matrix_position(const dvar_matrix &m)
dvar_matrix()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
ostream & operator<<(const ostream &_s, preshowpoint p)
Description not yet available.
dmatrix restore_lower_triangular_dvar_matrix_value(const dvar_matrix_position &mpos)
Description not yet available.
Stores the adjoint gradient data that will be processed by gradcalc.
double ln_det_choleski(const banded_symmetric_dmatrix &MM, int &ierr)
void save_dvar_matrix_value(const dvar_matrix &m)
dvector value(const df1_one_vector &v)
static _THREAD grad_stack * GRAD_STACK1
void check_choleski_decomp(const banded_symmetric_dvar_matrix &MM, int &ierr)
prevariable operator()(int i, int j)
Fundamental data type for reverse mode automatic differentiation.
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
banded_symmetric_dmatrix restore_banded_symmetric_dvar_matrix_value(const dvar_matrix_position &mpos)
Description not yet available.
Description not yet available.
int bandwidth(void) const
void initialize(void)
Description not yet available.
prevariable operator()(int i, int j)
Description not yet available.