ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_m21.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 dvar_matrix operator-(const dvar_matrix& m1, const dmatrix& m2 )
18 {
21 
22 #ifndef OPT_LIB
23  if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
24  {
25  cerr << " Incompatible array bounds in "
26  "dvar_matrix operator+(const dvar_matrix& x, const dmatrix& m)\n";
27  ad_exit(21);
28  }
29 #endif
30 
31  int min = m1.rowmin();
32  int max = m1.rowmax();
33  dvar_matrix tmp;
34  tmp.allocate(min, max);
35 
36  dvar_vector* ptmpi = &tmp(min);
37  const dvar_vector* pm1i = &m1(min);
38  const dvector* pm2i = &m2(min);
39  for (int i = min; i <= max; ++i)
40  {
41  *ptmpi = *pm1i - *pm2i;
42 
43  ++ptmpi;
44  ++pm1i;
45  ++pm2i;
46  }
47 
49 
50  return tmp;
51 }
52 
58 {
61 
62 #ifndef OPT_LIB
63  if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
64  {
65  cerr << " Incompatible array bounds in "
66  "dvar_matrix operator+(const dvar_matrix& x, const dvar_matrix& m)\n";
67  ad_exit(21);
68  }
69 #endif
70 
71  int min = m1.rowmin();
72  int max = m1.rowmax();
73  dvar_matrix tmp;
74  tmp.allocate(min, max);
75 
76  dvar_vector* ptmpi = &tmp(min);
77  const dvar_vector* pm1i = &m1(min);
78  const dvar_vector* pm2i = &m2(min);
79  for (int i = min; i <= max; ++i)
80  {
81  *ptmpi = *pm1i - *pm2i;
82 
83  ++ptmpi;
84  ++pm1i;
85  ++pm2i;
86  }
87 
89 
90  return tmp;
91 }
92 
98 {
101 
102 #ifndef OPT_LIB
103  if (m1.colmin() != m2.colmin() || m1.colmax() != m2.colmax())
104  {
105  cerr << " Incompatible array bounds in "
106  "dvar_matrix operator+(const dmatrix& x, const dvar_matrix& m)\n";
107  ad_exit(21);
108  }
109 #endif
110 
111  int min = m1.rowmin();
112  int max = m1.rowmax();
113  dvar_matrix tmp;
114  tmp.allocate(min, max);
115 
116  dvar_vector* ptmpi = &tmp(min);
117  const dvector* pm1i = &m1(min);
118  const dvar_vector* pm2i = &m2(min);
119  for (int i = min; i <= max; ++i)
120  {
121  *ptmpi = *pm1i - *pm2i;
122 
123  ++ptmpi;
124  ++pm1i;
125  ++pm2i;
126  }
127 
129 
130  return tmp;
131 }
int rowmax(void) const
Definition: fvar.hpp:2564
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
int colmin(void) const
Definition: fvar.hpp:2552
Vector of double precision numbers.
Definition: dvector.h:50
exitptr ad_exit
Definition: gradstrc.cpp:53
ADMB variable vector.
Definition: fvar.hpp:2172
int rowmax() const
Definition: fvar.hpp:2929
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
int colmin(void) const
Definition: fvar.hpp:2939
int rowmin(void) const
Definition: fvar.hpp:2560
Description not yet available.
Definition: fvar.hpp:2819
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
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
#define max(a, b)
Definition: cbivnorm.cpp:189
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
int rowmin() const
Definition: fvar.hpp:2925
int colmax(void) const
Definition: fvar.hpp:2943
int colmax(void) const
Definition: fvar.hpp:2556