ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat36.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  dmatrix(min,max)
19 {
20  for (int i=min;i<=max;i++)
21  {
22  (*this)(i).allocate(min,i);
23  }
24 }
25 
31 {
32  int imin=m.indexmin();
33  int imax=m.indexmax();
34  if (v.indexmin() != imin || v.indexmax() != imax)
35  {
36  cerr << " Incompatible vector and matrix sizes in solve " << endl;
37  ad_exit(1);
38  }
39  dvector x(imin,imax);
40  x(imin)=v(imin)/m(imin,imin);
41  for (int i=2;i<=imax;i++)
42  {
43  int jmin=imin;
44  double ssum=0.0;
45  for (int j=jmin;j<=i-1;j++)
46  {
47  ssum+=m(i,j)*x(j);
48  }
49  x(i)=(v(i)-ssum)/m(i,i);
50  }
51  return x;
52 }
53 
59 {
60  int min=T.indexmin();
61  int max=T.indexmax();
62  dmatrix tmp(min,max,min,max);
63  int i,j;
64  for (i=min;i<=max;i++)
65  {
66  tmp(i,i)=T(i,i);
67  for (j=i+1;j<=max;j++)
68  {
69  tmp(i,j)=T(j,i);
70  tmp(j,i)=T(j,i);
71  }
72  }
73  return tmp;
74 }
75 
81 {
82  int mmin=M.indexmin();
83  int mmax=M.indexmax();
84 
85  if (y.indexmin() !=mmin || y.indexmax() !=mmax)
86  {
87  cerr << "incompatible size in solve_trans" << endl;
88  ad_exit(1);
89  }
90  dvector x(mmin,mmax);
91  int i,j;
92 
93  for (i=mmax;i>=mmin;i--)
94  {
95  double sum=0.0;
96  for (j=i+1;j<=mmax;j++)
97  {
98  sum+=M(j,i)*x(j);
99  }
100  x(i)=(y(i)-sum)/M(i,i);
101  }
102 
103  return x;
104 }
105 
111 {
112  int mmin=M.indexmin();
113  int mmax=M.indexmax();
114  int i,j;
115  dmatrix tmp(mmin,mmax,mmin,mmax);
116  for (i=mmin;i<=mmax;i++)
117  {
118  for (j=1;j<i;j++)
119  tmp(j,i)=0;
120  for (j=i;j<=mmax;j++)
121  tmp(j,i)=M(j,i);
122  }
123  return tmp;
124 }
125 
131 {
132  int mmin=M.indexmin();
133  int mmax=M.indexmax();
134  int i,j;
135  dmatrix tmp(mmin,mmax,mmin,mmax);
136  for (i=mmin;i<=mmax;i++)
137  {
138  for (j=1;j<i;j++)
139  tmp(i,j)=0;
140  for (j=i;j<=mmax;j++)
141  tmp(i,j)=M(j,i);
142  }
143  return tmp;
144 }
dmatrix fillout(const lower_triangular_dmatrix &M)
Description not yet available.
Definition: dmat36.cpp:110
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat0.cpp:8
lower_triangular_dmatrix(int, int)
Description not yet available.
Definition: dmat36.cpp:17
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
int indexmin() const
Definition: fvar.hpp:2917
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
exitptr ad_exit
Definition: gradstrc.cpp:53
dmatrix fillout_trans(const lower_triangular_dmatrix &M)
Description not yet available.
Definition: dmat36.cpp:130
dvector solve(const dmatrix &aa, const dvector &z)
Solve a linear system using LU decomposition.
Definition: dmat34.cpp:46
dmatrix symmetrize(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat12.cpp:14
prnstream & endl(prnstream &)
dvector solve_trans(const lower_triangular_dmatrix &M, const dvector &y)
Description not yet available.
Definition: dmat36.cpp:80
#define min(a, b)
Definition: cbivnorm.cpp:188
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
#define M
Definition: rngen.cpp:57
Description not yet available.
Definition: fvar.hpp:2819
int indexmax() const
Definition: fvar.hpp:2921
Description not yet available.
Definition: fvar.hpp:8960
#define max(a, b)
Definition: cbivnorm.cpp:189