ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_m30.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 // file fvar.cpp
12 // constructors, destructors and misc functions involving class dvariable
13 
14 #include "fvar.hpp"
15 
16 #ifdef __TURBOC__
17  #pragma hdrstop
18  #include <iostream.h>
19 #endif
20 
21 #ifdef __ZTC__
22  #include <iostream.hpp>
23 #endif
24 
25 
26 #include <stdio.h>
27 #ifndef __SUN__
28 #endif
29 #include <math.h>
30 
35 dvar_matrix operator/(const dvar_matrix& m, const double e)
36 {
37  dvar_matrix tmp;
38  int min = m.indexmin();
39  int max = m.indexmax();
40  if (min <= max)
41  {
42  tmp.allocate(min, max);
43  dvar_vector* ptmp = &tmp(min);
44  const dvar_vector* pm = &m(min);
45  for (int i = min; i <= max; ++i)
46  {
47  *ptmp = *pm / e;
48  ++pm;
49  ++ptmp;
50  }
51  }
52  return tmp;
53 }
54 
60 {
61  dvar_matrix tmp;
62  int min = m.indexmin();
63  int max = m.indexmax();
64  if (min <= max)
65  {
66  tmp.allocate(min, max);
67  dvar_vector* ptmp = &tmp(min);
68  const dvar_vector* pm = &m(min);
69  for (int i = min; i <= max; ++i)
70  {
71  *ptmp = *pm / e;
72  ++pm;
73  ++ptmp;
74  }
75  }
76  return tmp;
77 }
78 
84 {
85  dvar_matrix tmp;
86  int min = m.indexmin();
87  int max = m.indexmax();
88  tmp.allocate(min, max);
89  if (min <= max)
90  {
91  dvar_vector* ptmp = &tmp(min);
92  const dvector* pm = &m(min);
93  for (int i = min; i <= max; ++i)
94  {
95  *ptmp = *pm / e;
96  ++pm;
97  ++ptmp;
98  }
99  }
100  return tmp;
101 }
102 
108 {
109  if (m.rowmin() != m.colmin() || m.rowmax() != m.colmax() )
110  {
111  cerr << " Non square matrix passed to dmatrix symmetrize\n";
112  ad_exit(1);
113  }
114  int rmin=m.rowmin();
115  int rmax=m.rowmax();
116 
117  dvar_matrix s(rmin,rmax,rmin,rmax);
118 
119 
120  for (int i=rmin;i<=rmax;i++)
121  {
122  s(i,i)=m(i,i);
123  for (int j=rmin;j<i;j++)
124  {
125  s(i,j)=(m(i,j)+m(j,i))/2.;
126  s(j,i)=s(i,j);
127  }
128  }
129 
130  return s;
131 }
Base class for dvariable.
Definition: fvar.hpp:1315
int rowmax(void) const
Definition: fvar.hpp:2564
int colmin(void) const
Definition: fvar.hpp:2552
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Definition: fvar.hpp:2917
exitptr ad_exit
Definition: gradstrc.cpp:53
ADMB variable vector.
Definition: fvar.hpp:2172
dmatrix symmetrize(const dmatrix &matrix)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat12.cpp:14
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int rowmin(void) const
Definition: fvar.hpp:2560
Description not yet available.
Definition: fvar.hpp:2819
int indexmax() const
Definition: fvar.hpp:2921
int indexmax(void) const
Definition: fvar.hpp:2572
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
void allocate(int nrl, int nrh, int ncl, int nch)
Allocates AD variable matrix with dimensions nrl to nrh by ncl to nch.
Definition: fvar_mat.cpp:216
d3_array operator/(const d3_array &m, const double d)
Author: David Fournier.
Definition: d3arr2b.cpp:14
#define max(a, b)
Definition: cbivnorm.cpp:189
int indexmin(void) const
Definition: fvar.hpp:2568
int colmax(void) const
Definition: fvar.hpp:2556