ADMB Documentation  11.1.2249
 All Classes Files Functions Variables Typedefs Friends Defines
ivec7.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: ivec7.cpp 1921 2014-04-23 18:47:05Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00013 #ifdef __TURBOC__
00014   #pragma hdrstop
00015   #include <iostream.h>
00016 #endif
00017 
00018 #ifdef __ZTC__
00019   #include <iostream.hpp>
00020 #endif
00021 
00022 #include <stdlib.h>
00023 #include "admb_messages.h"
00024 
00025 #ifndef OPT_LIB
00026 
00030  int& ivector::operator[] (int i)
00031  {
00032    if (!v)
00033    {
00034        cerr << "\nattempting to acces non-allocated ivector in "
00035        "ivector::operator[]";
00036        ad_exit(1);
00037        cerr << endl;
00038    }
00039    if (i > indexmax())
00040    {
00041      ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
00042      "int& ivector::operator[] (int i)", indexmin(), indexmax(), i);
00043    }
00044    if (i<indexmin())
00045    {
00046      ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
00047      "int& ivector::operator[] (int i)", indexmin(), indexmax(), i);
00048    }
00049    return(*(v+i));
00050  }
00051 
00056  int& ivector::operator() (int i)
00057  {
00058    if (!v)
00059    {
00060      cerr << "\nattempting to acces non-allocated ivector in "
00061      "ivector::operator()";
00062      cerr << endl;
00063      ad_exit(1);
00064    }
00065    if (i > indexmax())
00066    {
00067      ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
00068      "int& ivector::operator() (int i)", indexmin(), indexmax(), i);
00069    }
00070    if (i < indexmin())
00071    {
00072      ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
00073      "int& ivector::operator() (int i)", indexmin(), indexmax(), i);
00074    }
00075    return(*(v+i));
00076  }
00077 
00082 const int& ivector::operator[](int i) const
00083  {
00084      if (!v)
00085      {
00086        cerr << "\nattempting to acces non-allocated ivector in "
00087        "ivector::operator[]";
00088        cerr << endl;
00089        ad_exit(1);
00090      }
00091      if (i>indexmax())
00092      {
00093        cerr << "\narray bound exceeded -- index too high in "
00094        "ivector::operator[]";
00095        cerr << "index value " << i << " max value " << indexmax() << endl;
00096        cerr << endl;
00097        ad_exit(1);
00098      }
00099 
00100      if (i<indexmin())
00101      {
00102        cerr << "\narray bound exceeded -- index too low in ivector::operator[]";
00103        cerr << endl;
00104        ad_exit(1);
00105      }
00106    return(*(v+i));
00107  }
00108 
00113 const int& ivector::operator()(int i) const
00114  {
00115      if (!v)
00116      {
00117        cerr << "\nattempting to acces non-allocated ivector in "
00118        "ivector::operator()";
00119        cerr << endl;
00120        ad_exit(1);
00121      }
00122      if (i>indexmax())
00123      {
00124        cerr << "\narray bound exceeded -- index too high in "
00125        "ivector::operator()";
00126        cerr << "index value " << i << " max value " << indexmax() << endl;
00127        cerr << endl;
00128        ad_exit(1);
00129      }
00130 
00131      if (i<indexmin())
00132      {
00133        cerr << "\narray bound exceeded -- index too low in ivector::operator[]";
00134        cerr << endl;
00135        ad_exit(1);
00136      }
00137    return(*(v+i));
00138  }
00139 #endif