ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dvect4.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 dvector operator*(const dvector& t1, const double x)
18 {
19  int min = t1.indexmin();
20  int max = t1.indexmax();
21  dvector tmp(min, max);
22 
23  double* ptmpi = tmp.get_v() + min;
24  double* pt1i = t1.get_v() + min;
25  for (int i = min; i <= max; ++i)
26  {
27  *ptmpi = *pt1i * x;
28 
29  ++ptmpi;
30  ++pt1i;
31  }
32  return tmp;
33 }
34 
39 dvector operator/(const double x, const dvector& t1)
40 {
41  int min = t1.indexmin();
42  int max = t1.indexmax();
43  dvector tmp(min, max);
44 
45  double* ptmpi = tmp.get_v() + min;
46  double* pt1i = t1.get_v() + min;
47  for (int i = min; i <= max; ++i)
48  {
49  *ptmpi = x / *pt1i;
50 
51  ++ptmpi;
52  ++pt1i;
53  }
54  return tmp;
55 }
56 
61 dvector operator/(const dvector& t1, const double x)
62 {
63  int min = t1.indexmin();
64  int max = t1.indexmax();
65  dvector tmp(min, max);
66 
67  double* ptmpi = tmp.get_v() + min;
68  double* pt1i = t1.get_v() + min;
69  for (int i = min; i <= max; ++i)
70  {
71  *ptmpi = *pt1i / x;
72 
73  ++ptmpi;
74  ++pt1i;
75  }
76  return tmp;
77 }
78 
83 dvector operator+(const double x, const dvector& t1)
84 {
85  int min = t1.indexmin();
86  int max = t1.indexmax();
87  dvector tmp(min, max);
88 
89  double* ptmpi = tmp.get_v() + min;
90  double* pt1i = t1.get_v() + min;
91  for (int i = min; i <= max; ++i)
92  {
93  *ptmpi = x + *pt1i;
94 
95  ++ptmpi;
96  ++pt1i;
97  }
98  return tmp;
99 }
100 
105 dvector operator+(const dvector& t1, const double x)
106 {
107  int min = t1.indexmin();
108  int max = t1.indexmax();
109  dvector tmp(min, max);
110 
111  double* ptmpi = tmp.get_v() + min;
112  double* pt1i = t1.get_v() + min;
113  for (int i = min; i <= max; ++i)
114  {
115  *ptmpi = *pt1i + x;
116 
117  ++ptmpi;
118  ++pt1i;
119  }
120  return tmp;
121 }
122 
127 dvector operator-(const double x, const dvector& t1)
128 {
129  int min = t1.indexmin();
130  int max = t1.indexmax();
131  dvector tmp(min, max);
132 
133  double* ptmpi = tmp.get_v() + min;
134  double* pt1i = t1.get_v() + min;
135  for (int i = min; i <= max; ++i)
136  {
137  *ptmpi = x - *pt1i;
138 
139  ++ptmpi;
140  ++pt1i;
141  }
142  return tmp;
143 }
144 
149 dvector operator-(const dvector& t1, const double x)
150 {
151  int min = t1.indexmin();
152  int max = t1.indexmax();
153  dvector tmp(min, max);
154 
155  double* ptmpi = tmp.get_v() + min;
156  double* pt1i = t1.get_v() + min;
157  for (int i = min; i <= max; ++i)
158  {
159  *ptmpi = *pt1i - x;
160 
161  ++ptmpi;
162  ++pt1i;
163  }
164  return tmp;
165 }
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
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
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
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
#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.
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
double *& get_v(void)
Definition: dvector.h:148