18 #if defined (__WAT32__)
24 #include <iostream.hpp>
34 double ln_unsigned_det;
48 double ln_unsigned_det;
67 const double& _ln_unsigned_det,
double&
sign)
69 double& ln_unsigned_det=(
double&) (_ln_unsigned_det);
70 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
71 int n = [](
unsigned int colsize) ->
int
73 assert(colsize <= INT_MAX);
74 return static_cast<int>(colsize);
77 int n =
static_cast<int>(aa.
colsize());
83 cerr <<
"Error matrix not square in solve()"<<
endl;
92 double big,dum,
sum,temp;
97 double* pvvi = &vv(lb);
98 for (
int i=lb;i<=ub;i++)
101 double* pbbij = pbbi->
get_v() + lb;
102 for (
int j=lb;j<=ub;j++)
113 cerr <<
"Error in matrix inverse -- matrix singular in inv(dmatrix)\n";
122 double* pvvj = &vv(lb);
123 for (
int j=lb;j<=ub;j++)
126 for (
int i=lb;i<j;i++)
128 sum = *(pbbi->
get_v() + j);
129 double* pbbik = pbbi->
get_v() + lb;
131 for (
int k=lb;k<i;k++)
133 sum -= *pbbik * *(pbbk->
get_v() + j);
139 *(pbbi->
get_v() + j) = sum;
148 for (
int i=j;i<=ub;i++)
150 sum = *(pbbi->
get_v() + j);
151 double* pbbik = pbbi->
get_v() + lb;
153 for (
int k=lb;k<j;k++)
155 sum -= *pbbik * *(pbbk->
get_v() + j);
160 *(pbbi->
get_v() + j) = sum;
161 dum = *pvvi *
fabs(sum);
172 double* pbbjk = pbbj->
get_v() + lb;
173 double* pbbimaxk = bb(imax).get_v() + lb;
174 for (
int k=lb;k<=ub;k++)
188 int itemp=indx(imax);
195 double* pbbjj = pbbj->
get_v() + j;
205 for (
int i=j+1;i<=ub;i++)
207 *(pbbi->
get_v() + j) = *(pbbi->
get_v() + j) * dum;
219 part_prod(lb)=
log(
fabs(bb(lb,lb)));
220 if (bb(lb,lb)<0) sign=-
sign;
222 for (
int j=lb+1;j<=ub;j++)
224 double bbjj = bb(j, j);
225 if (bbjj < 0) sign=-
sign;
226 part_prod(j)=part_prod(j-1)+
log(
fabs(bbjj));
228 ln_unsigned_det=part_prod(ub);
237 int* pindxi = indx.
get_v() + lb;
238 for (
int i=lb;i<=ub;i++)
240 indxinv(*pindxi) = i;
244 int* pindxinvi = indxinv.
get_v() + lb;
245 for (
int i=lb;i<=ub;i++)
252 double* pyi = &y(lb);
253 for (
int i=lb;i<=ub;i++)
257 double* pbbij = pbbi->
get_v() + lb;
258 double* pyj = &y(lb);
259 for (
int j=lb;j<=i-1;j++)
261 sum -= *pbbij * *pyj;
273 double* pxi = x.
get_v() + ub;
274 for (
int i=ub;i>=lb;i--)
278 double* pbbij = pbbi->
get_v() + i + 1;
279 double* pxj = x.
get_v() + i + 1;
280 for (
int j=i+1;j<=ub;j++)
282 sum -= *pbbij * *pxj;
287 *pxi = sum / *(pbbi->
get_v() + i);
void dmdv_solve(void)
Adjoint code for dvar_vector solve(const dvar_matrix& aa, const dvar_vector& z,.
Vector of double precision numbers.
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.
unsigned int colsize() const
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.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Description not yet available.
dvector csolve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
double sign(const double x)
The sign of a number.
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.