ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ivec7.cpp
Go to the documentation of this file.
1 
5 #include "fvar.hpp"
6 
7 #ifdef __TURBOC__
8  #pragma hdrstop
9  #include <iostream.h>
10 #endif
11 
12 #ifdef __ZTC__
13  #include <iostream.hpp>
14 #endif
15 
16 #include <stdlib.h>
17 #include "admb_messages.h"
18 #include <stdexcept>
19 
20 #ifndef OPT_LIB
21 
27 int& ivector::operator[](int i)
28 {
29  if (!v)
30  {
31  cerr << "\nError: Unable to access unallocated ivector"
32  << " in ivector::operator[]\n";
33  ad_exit(1);
34  }
35  else if (i > indexmax())
36  {
37  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
38  "int& ivector::operator[](int i)", indexmin(), indexmax(), i);
39  }
40  else if (i < indexmin())
41  {
42  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
43  "int& ivector::operator[](int i)", indexmin(), indexmax(), i);
44  }
45 
46  return *(v + i);
47 }
53 int& ivector::operator()(int i)
54 {
55  if (!v)
56  {
57  cerr << "\nError: Unable to access unallocated ivector"
58  << " in ivector::operator()\n";
59  ad_exit(1);
60  }
61  else if (i > indexmax())
62  {
63  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
64  "int& ivector::operator() (int i)", indexmin(), indexmax(), i);
65  }
66  else if (i < indexmin())
67  {
68  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
69  "int& ivector::operator() (int i)", indexmin(), indexmax(), i);
70  }
71  return *(v + i);
72 }
78 const int& ivector::operator[](int i) const
79 {
80  if (!v)
81  {
82  cerr << "\nError: Unable to access unallocated ivector"
83  << " in ivector::operator[]\n";
84  ad_exit(1);
85  }
86  else if (i > indexmax())
87  {
88  cerr << "\narray bound exceeded -- index too high"
89  << " in ivector::operator[]";
90  ad_exit(1);
91  }
92  else if (i < indexmin())
93  {
94  cerr << "\narray bound exceeded -- index too low"
95  << " in ivector::operator[]";
96  ad_exit(1);
97  }
98  return *(v + i);
99 }
105 const int& ivector::operator()(int i) const
106 {
107  if (!v)
108  {
109  cerr << "\nError: Unable to access unallocated ivector"
110  << " in ivector::operator()\n";
111  ad_exit(1);
112  }
113  else if (i > indexmax())
114  {
115  cerr << "\narray bound exceeded -- index too high"
116  << " in ivector::operator()";
117  ad_exit(1);
118  }
119  else if (i < indexmin())
120  {
121  cerr << "\narray bound exceeded -- index too low"
122  << " in ivector::operator()";
123  ad_exit(1);
124  }
125  return *(v + i);
126 }
127 #endif
exitptr ad_exit
Definition: gradstrc.cpp:53
int & operator[](int i)
Definition: ivector.h:194
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int & operator()(int i)
Definition: ivector.h:198
int indexmin() const
Definition: ivector.h:99
int indexmax() const
Definition: ivector.h:104
#define ADMB_ARRAY_BOUNDS_ERROR(message, function, lower_bounds, upper_bounds, index)
Definition: admb_messages.h:47
int * v
Definition: ivector.h:55