ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_m38.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 {
21 
22  int rmin=m.rowmin();
23  int rmax=m.rowmax();
24 
25  ivector cmin(rmin,rmax);
26  ivector cmax(rmin,rmax);
27 
28  const dvector* pmi = &m(rmin);
29  int* pcmini = cmin.get_v() + rmin;
30  int* pcmaxi = cmax.get_v() + rmin;
31  for (int i=rmin;i<=rmax;++i)
32  {
33  *pcmini = pmi->indexmin();
34  *pcmaxi = pmi->indexmax();
35 
36  ++pcmini;
37  ++pcmaxi;
38  ++pmi;
39  }
40 
41  dvar_matrix tmp(rmin,rmax,cmin,cmax);
42 
43  pmi = &m(rmin);
44  dvar_vector *ptmpi = &tmp(rmin);
45  for (int i=rmin;i<=rmax;++i)
46  {
47  *ptmpi = x * *pmi;
48 
49  ++pmi;
50  ++ptmpi;
51  }
52 
54  return tmp;
55 }
56 
61 dvar_matrix operator*(const dvar_matrix& m, const double x)
62 {
65 
66  int rmin=m.rowmin();
67  int rmax=m.rowmax();
68 
69  ivector cmin(rmin,rmax);
70  ivector cmax(rmin,rmax);
71 
72  const dvar_vector* pmi = &m(rmin);
73  int* pcmini = cmin.get_v() + rmin;
74  int* pcmaxi = cmax.get_v() + rmin;
75  for (int i=rmin;i<=rmax;++i)
76  {
77  *pcmini = pmi->indexmin();
78  *pcmaxi = pmi->indexmax();
79 
80  ++pcmini;
81  ++pcmaxi;
82  ++pmi;
83  }
84  dvar_matrix tmp(rmin,rmax,cmin,cmax);
85 
86  pmi = &m(rmin);
87  dvar_vector *ptmpi = &tmp(rmin);
88  for (int i=rmin;i<=rmax;++i)
89  {
90  *ptmpi = x * *pmi;
91 
92  ++pmi;
93  ++ptmpi;
94  }
95 
97  return tmp;
98 }
99 
104 dvar_matrix operator*(const double x, const dvar_matrix& m)
105 {
108  int rmin=m.rowmin();
109  int rmax=m.rowmax();
110 
111  ivector cmin(rmin,rmax);
112  ivector cmax(rmin,rmax);
113 
114  const dvar_vector* pmi = &m(rmin);
115  int* pcmini = cmin.get_v() + rmin;
116  int* pcmaxi = cmax.get_v() + rmin;
117  for (int i=rmin;i<=rmax;++i)
118  {
119  *pcmini = pmi->indexmin();
120  *pcmaxi = pmi->indexmax();
121 
122  ++pcmini;
123  ++pcmaxi;
124  ++pmi;
125  }
126 
127  dvar_matrix tmp(rmin,rmax,cmin,cmax);
128 
129  pmi = &m(rmin);
130  dvar_vector *ptmpi = &tmp(rmin);
131  for (int i=rmin;i<=rmax;++i)
132  {
133  *ptmpi = x * *pmi;
134 
135  ++pmi;
136  ++ptmpi;
137  }
139  return tmp;
140 }
Base class for dvariable.
Definition: fvar.hpp:1315
int rowmax(void) const
Definition: fvar.hpp:2564
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
ADMB variable vector.
Definition: fvar.hpp:2172
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
int * get_v() const
Definition: ivector.h:114
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
int rowmax() const
Definition: fvar.hpp:2929
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
int rowmin(void) const
Definition: fvar.hpp:2560
Description not yet available.
Definition: fvar.hpp:2819
int indexmin() const
Definition: fvar.hpp:2287
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
int indexmax() const
Definition: fvar.hpp:2292
int rowmin() const
Definition: fvar.hpp:2925