27 dmatrix ret(rmin,rmax,cmin,cmax);
28 for(
int i = rmin; i<=rmax; ++i){
29 for(
int j = cmin; j<=cmax; ++j){
30 ret(i,j) =
fabs(X(i,j));
43 return solve(aa,tz,ln,sgn);
73 cout<<
"Error: Not square matrix in expm."<<
endl;
78 cout<<
"Error: Not square matrix in expm."<<
endl;
82 dmatrix AA(rmin,rmax,rmin,rmax);
86 dmatrix cX(rmin,rmax,rmin,rmax);
88 for(
int i = rmin; i<=rmax; ++i){I(i,i) = 1.0;}
91 log2NormInf/=
log(2.0);
92 int e = (int)log2NormInf + 1;
95 AA = 1.0/
pow(2.0,s)*A;
102 for(
int k = 2; k<=q; ++k){
103 c*=((double)q-k+1.0)/((double)k*(2*q-k+1));
107 if(p==1){D+=cX;}
else{D-=cX;}
112 for(
int k = 1; k<=s; ++k){
150 cout<<
"Error: Not square matrix in expm."<<
endl;
155 cout<<
"Error: Not square matrix in expm."<<
endl;
167 for(
int i = rmin; i<=rmax; ++i){I(i,i) = 1.0;}
171 log2NormInf/=
log(2.0);
172 int e = (int)
value(log2NormInf) + 1;
175 AA = 1.0/
pow(2.0,s)*A;
183 for(k = 2; k<=q; ++k){
184 c*=((double)q-k+1.0)/((double)k*(2*q-k+1));
188 if(p==1){D+=cX;}
else{D-=cX;}
193 for(k = 1; k<=s; ++k){
206 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
207 int n = [](
unsigned int colsize) ->
int
209 assert(colsize <= INT_MAX);
210 return static_cast<int>(colsize);
213 int n =
static_cast<int>(aa.
colsize());
219 cerr <<
"Error matrix not square in solve()"<<
endl;
232 for (
int i=lb;i<=ub;i++)
235 for (
int j=lb;j<=ub;j++)
245 cerr <<
"Error in matrix inverse -- matrix singular in inv(dvar_matrix)\n";
250 for (
int j=lb;j<=ub;j++)
252 for (
int i=lb;i<j;i++)
255 for (
int k=lb;k<i;k++)
257 sum -= bb(i,k)*bb(k,j);
264 for (
int i=j;i<=ub;i++)
267 for (
int k=lb;k<j;k++)
269 sum -= bb(i,k)*bb(k,j);
281 for (
int k=lb;k<=ub;k++)
292 int itemp=indx(imax);
307 for (
int i=j+1;i<=ub;i++)
309 bb(i,j) = bb(i,j) * dum;
317 part_prod(lb)=
log(
fabs(bb(lb,lb)));
318 if (bb(lb,lb)<0) sign=-
sign;
319 for (
int j=lb+1;j<=ub;j++)
321 if (bb(j,j)<0) sign=-
sign;
322 part_prod(j)=part_prod(j-1)+
log(
fabs(bb(j,j)));
324 ln_unsigned_det=part_prod(ub);
337 for (
int i=lb;i<=ub;i++)
341 for (
int kk=mmin;kk<=mmax;kk++)
343 for (
int i=lb;i<=ub;i++)
345 y(indxinv(i))=z(kk)(i);
348 for (
int i=lb;i<=ub;i++)
351 for (
int j=lb;j<=i-1;j++)
357 for (
int i=ub;i>=lb;i--)
360 for (
int j=i+1;j<=ub;j++)
362 sum-=b(i,j)*
x(kk)(j);
dmatrix trans(const dmatrix &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
dmatrix expm(const dmatrix &A)
Matrix exponential.
void initialize(void)
Zero initialize allocated dvar_matrix, then saves adjoint function and position data.
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)
void fill_seqadd(int, int)
Fills ivector elements with values starting from base and incremented by offset.
ivector sgn(const dvector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
dvector solve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
prnstream & endl(prnstream &)
Array of integers(int) with indexes from index_min to indexmax.
dvector rowsum(const dmatrix &matrix)
Returns dvector where each element contains the sum total of each row in matrix.
void RETURN_ARRAYS_INCREMENT()
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
Description not yet available.
Class definition of matrix with derivitive information .
double sign(const double x)
The sign of a number.
void RETURN_ARRAYS_DECREMENT()
dvector value(const df1_one_vector &v)
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
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.
d3_array pow(const d3_array &m, int e)
Description not yet available.
unsigned int colsize() const