ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_m53.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include "fvar.hpp"
12 
18 {
19  int imin=m.indexmin();
20  int imax=m.indexmax();
21  if (v.indexmin() != imin || v.indexmax() != imax)
22  {
23  cerr << " Incompatible vector and matrix sizes in solve " << endl;
24  ad_exit(1);
25  }
26  dvar_vector x(imin,imax);
27  x(imin)=v(imin)/m(imin,imin);
28  for (int i=2;i<=imax;i++)
29  {
30  int jmin=imin;
31  dvariable ssum=0.0;
32  for (int j=jmin;j<=i-1;j++)
33  {
34  ssum+=m(i,j)*x(j);
35  }
36  x(i)=(v(i)-ssum)/m(i,i);
37  }
38  return x;
39 }
40 
46 {
47  int sgn;
48  return lower_triangular_ln_det(m,sgn);
49 }
50 
56 {
57  sgn=1;
58  int imin=m.indexmin();
59  int imax=m.indexmax();
60  dvariable ssum=0.0;
61  for (int i=imin;i<=imax;i++)
62  {
63  if (value(m(i,i))>0.0)
64  {
65  ssum+=log(m(i,i));
66  }
67  else
68  {
69  sgn=-sgn;
70  ssum+=log(-m(i,i));
71  }
72  }
73  return ssum;
74 }
75 
76 
77 
78 /*
79 dvar_vector lower_triangular_solve(const dvar_matrix& a, const dvar_vector & b)
80 {
81  int i,k;
82  dvariable sum;
83 
84  int mmin=b.indexmin();
85  int mmax=b.indexmax();
86  dvar_vector x(mmin,mmax);
87 
88  for (i=mmin;i<=mmax;i++)
89  {
90  sum=b[i];
91  for (k=i-1;k>=mmin;k--)
92  {
93  sum -= a[i][k]*x[k];
94  }
95  x[i]=sum/a[i][i];
96  }
97  return x;
98  for (i=mmax;i>=mmin;i--)
99  {
100  for (sum=x[i],k=i+1;k<=mmax;k++)
101  {
102  sum -= a[k][i]*x[k];
103  }
104  x[i]=sum/a[i][i];
105  }
106 }
107  */
108 
dvector lower_triangular_solve(const dmatrix &m, const dvector &v)
Description not yet available.
Definition: dmat37.cpp:170
#define x
exitptr ad_exit
Definition: gradstrc.cpp:53
ADMB variable vector.
Definition: fvar.hpp:2172
ivector sgn(const dvector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dvect24.cpp:11
prnstream & endl(prnstream &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int indexmin() const
Definition: fvar.hpp:2287
int indexmax(void) const
Definition: fvar.hpp:2572
double lower_triangular_ln_det(const dmatrix &m)
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
int indexmin(void) const
Definition: fvar.hpp:2568
int indexmax() const
Definition: fvar.hpp:2292
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13