ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f1b2v12.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 <df1b2fun.h>
12 
18  const df1b2vector& y)
19 {
20  int mmin=M.indexmin();
21  int mmax=M.indexmax();
22 
23  if (y.indexmin() !=mmin || y.indexmax() !=mmax)
24  {
25  cerr << "incompatible size in solve_trans" << endl;
26  ad_exit(1);
27  }
28  df1b2vector x(mmin,mmax);
29  int i,j;
30 
31  for (i=mmax;i>=mmin;i--)
32  {
33  df1b2variable ssum=0.0;
34  int jmax=mmax;
35  for (j=i+1;j<=jmax;j++)
36  {
37  ssum+=M(j,i)*x(j);
38  }
39  x(i)=(y(i)-ssum)/M(i,i);
40  }
41  return x;
42 }
43 
49 {
50  int imin=m.indexmin();
51  int imax=m.indexmax();
52  if (v.indexmin() != imin || v.indexmax() != imax)
53  {
54  cerr << " Incompatible vector and matrix sizes in solve " << endl;
55  ad_exit(1);
56  }
57  df1b2vector x(imin,imax);
58  x(imin)=v(imin)/m(imin,imin);
59  for (int i=imin+1;i<=imax;i++)
60  {
61  int jmin=imin;
62  df1b2variable ssum=0.0;
63  for (int j=jmin;j<=i-1;j++)
64  {
65  ssum+=m(i,j)*x(j);
66  }
67  x(i)=(v(i)-ssum)/m(i,i);
68  }
69  return x;
70 }
71 
77 {
78  int sgn;
79  return lower_triangular_ln_det(m,sgn);
80 }
81 
87 {
88  sgn=1;
89  int imin=m.indexmin();
90  int imax=m.indexmax();
91  df1b2variable ssum=0.0;
92  for (int i=imin;i<=imax;i++)
93  {
94  if (value(m(i,i))>0.0)
95  {
96  ssum+=log(m(i,i));
97  }
98  else
99  {
100  sgn=-sgn;
101  ssum+=log(-m(i,i));
102  }
103  }
104  return ssum;
105 }
dvector lower_triangular_solve(const dmatrix &m, const dvector &v)
Description not yet available.
Definition: dmat37.cpp:170
#define x
int indexmin(void) const
Definition: df1b2fun.h:1054
Description not yet available.
Definition: df1b2fun.h:953
exitptr ad_exit
Definition: gradstrc.cpp:53
int indexmin(void) const
Definition: df1b2fun.h:969
dvector lower_triangular_solve_trans(const dmatrix &M, const dvector &y)
Description not yet available.
Definition: dmat37.cpp:140
Description not yet available.
Definition: df1b2fun.h:266
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 &)
#define M
Definition: rngen.cpp:57
double lower_triangular_ln_det(const dmatrix &m)
Description not yet available.
Definition: df1b2fun.h:1042
int indexmax(void) const
Definition: df1b2fun.h:970
int indexmax(void) const
Definition: df1b2fun.h:1055
Description not yet available.
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13