ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat16.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 
17 dmatrix operator-(const dmatrix& m1, const dmatrix& m2)
18  {
19  if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
20  {
21  cerr << " Incompatible array bounds in "
22  "dmatrix operator - (const dmatrix& x, const dmatrix& m)\n";
23  ad_exit(21);
24  }
25 
26  dmatrix tmp;
27  tmp.allocate(m1.rowmin(),m1.rowmax());
28 
29  for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
30  {
31  tmp.elem(i)=m1.elem(i)-m2.elem(i);
32  }
33  return(tmp);
34  }
35 
40 dmatrix operator+(const dmatrix& m1, const dmatrix& m2)
41  {
42  if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
43  {
44  cerr << " Incompatible array bounds in "
45  "dmatrix operator + (const dmatrix& x, const dmatrix& m)\n";
46  ad_exit(21);
47  }
48 
49  dmatrix tmp;
50  tmp.allocate(m1.rowmin(),m1.rowmax());
51 
52  for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
53  {
54  tmp.elem(i)=m1.elem(i)+m2.elem(i);
55  }
56  return(tmp);
57  }
58 
63 dmatrix operator+(const double d, const dmatrix& m2)
64  {
65  dmatrix tmp;
66  tmp.allocate(m2.rowmin(),m2.rowmax());
67  for (int i=m2.rowmin(); i<=m2.rowmax(); i++)
68  {
69  tmp.elem(i)=d+m2.elem(i);
70  }
71  return(tmp);
72  }
73 
78 dmatrix operator-(const double d, const dmatrix& m2)
79  {
80  dmatrix tmp;
81  tmp.allocate(m2.rowmin(),m2.rowmax());
82  for (int i=m2.rowmin(); i<=m2.rowmax(); i++)
83  {
84  tmp.elem(i)=d-m2.elem(i);
85  }
86  return(tmp);
87  }
88 
93 dmatrix operator*(const double d, const dmatrix& m2)
94  {
95  dmatrix tmp;
96  tmp.allocate(m2.rowmin(),m2.rowmax());
97  for (int i=m2.rowmin(); i<=m2.rowmax(); i++)
98  {
99  tmp.elem(i)=d*m2.elem(i);
100  }
101  return(tmp);
102  }
103 
108 dmatrix operator+(const dmatrix& m1, const double d)
109  {
110  dmatrix tmp;
111  tmp.allocate(m1.rowmin(),m1.rowmax());
112  for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
113  {
114  tmp.elem(i)=m1.elem(i)+d;
115  }
116  return(tmp);
117  }
118 
123 dmatrix operator-(const dmatrix& m1, const double d)
124  {
125  dmatrix tmp;
126  tmp.allocate(m1.rowmin(),m1.rowmax());
127  for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
128  {
129  tmp.elem(i)=m1.elem(i)-d;
130  }
131  return(tmp);
132  }
133 
138 dmatrix operator*(const dmatrix& m1, const double d)
139  {
140  dmatrix tmp;
141  tmp.allocate(m1.rowmin(),m1.rowmax());
142  for (int i=m1.rowmin(); i<=m1.rowmax(); i++)
143  {
144  tmp.elem(i)=m1.elem(i)*d;
145  }
146  return(tmp);
147  }
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat0.cpp:8
d3_array operator-(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:152
d3_array operator+(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:132
exitptr ad_exit
Definition: gradstrc.cpp:53
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
int rowmax() const
Definition: fvar.hpp:2929
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int colmin(void) const
Definition: fvar.hpp:2939
Description not yet available.
Definition: fvar.hpp:2819
dvector & elem(int i)
Definition: fvar.hpp:3011
int rowmin() const
Definition: fvar.hpp:2925
int colmax(void) const
Definition: fvar.hpp:2943