ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ivec8.cpp
Go to the documentation of this file.
1 
5 #include "fvar.hpp"
6 
7 #ifndef OPT_LIB
8  #include <cassert>
9 #endif
10 
20 {
21  int min = a.indexmin();
22  int max = a.indexmax();
23  ivector results(min, max);
24  int* pai = a.get_v() + min;
25  int* presultsi = results.get_v() + min;
26  for (int i = min; i <= max; ++i)
27  {
28  *presultsi = value + *pai;
29 
30  ++pai;
31  ++presultsi;
32  }
33  return results;
34 }
44 {
45  int min = a.indexmin();
46  int max = a.indexmax();
47  ivector results(min, max);
48  int* pai = a.get_v() + min;
49  int* presultsi = results.get_v() + min;
50  for (int i = min; i <= max; ++i)
51  {
52  *presultsi = value - *pai;
53 
54  ++pai;
55  ++presultsi;
56  }
57  return results;
58 }
68 ivector operator+(const ivector& a, const ivector& b)
69 {
70  int min = a.indexmin();
71  int max = b.indexmax();
72 #ifndef OPT_LIB
73  assert(min == b.indexmin() && max == b.indexmax());
74 #endif
75  ivector results(min, max);
76  int* presultsi = results.get_v() + min;
77  int* pai = a.get_v() + min;
78  int* pbi = b.get_v() + min;
79  for (int i = min; i <= max; ++i)
80  {
81  *presultsi = *pai + *pbi;
82  ++presultsi;
83  ++pai;
84  ++pbi;
85  }
86  return results;
87 }
97 ivector operator-(const ivector& a, const ivector& b)
98 {
99  int min = a.indexmin();
100  int max = b.indexmax();
101 #ifndef OPT_LIB
102  assert(min == b.indexmin() && max == b.indexmax());
103 #endif
104  ivector results(min, max);
105  int* presultsi = results.get_v() + min;
106  int* pai = a.get_v() + min;
107  int* pbi = b.get_v() + min;
108  for (int i = min; i <= max; ++i)
109  {
110  results(i) = *pai - *pbi;
111  ++presultsi;
112  ++pai;
113  ++pbi;
114  }
115  return results;
116 }
126 {
127  int min = a.indexmin();
128  int max = a.indexmax();
129  ivector results(min, max);
130  int* pai = a.get_v() + min;
131  int* presultsi = results.get_v() + min;
132  for (int i = min; i <= max; ++i)
133  {
134  *presultsi = *pai + value;
135  ++pai;
136  ++presultsi;
137  }
138  return results;
139 }
149 {
150  int min = a.indexmin();
151  int max = a.indexmax();
152  ivector results(min, max);
153  int* pai = a.get_v() + min;
154  int* presultsi = results.get_v() + min;
155  for (int i = min; i <= max; ++i)
156  {
157  *presultsi = *pai - value;
158  ++pai;
159  ++presultsi;
160  }
161  return results;
162 }
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
int * get_v() const
Definition: ivector.h:114
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int indexmin() const
Definition: ivector.h:99
int indexmax() const
Definition: ivector.h:104
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
#define max(a, b)
Definition: cbivnorm.cpp:189