ADMB Documentation  11.1.2274
 All Classes Files Functions Variables Typedefs Friends Defines
dvec_acc.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dvec_acc.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 #include "admb_messages.h"
00013 
00014 #if !defined(OPT_LIB)
00015 
00020 double& dvector::operator[](int i)
00021 {
00022   if (i < index_min || index_max < i)
00023   {
00024   #if defined(USE_EXCEPTIONS)
00025     throw vector_range_exception(i,index_min,index_max);
00026   #else
00027     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00028     "double& dvector::operator[] (int i)", index_min, index_max, i);
00029   #endif
00030   }
00031   return *(v+i);
00032 }
00038 double& dvector::operator()(int i)
00039 {
00040   if (i < index_min || index_max < i)
00041   {
00042   #if defined(USE_EXCEPTIONS)
00043     throw vector_range_exception(i,index_min,index_max);
00044   #else
00045     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00046     "double& dvector::operator[] (int i)", index_min, index_max, i);
00047   #endif
00048   }
00049   return *(v+i);
00050 }
00056 const double& dvector::operator[](int i) const
00057 {
00058   if (i < index_min || index_max < i)
00059   {
00060   #if defined(USE_EXCEPTIONS)
00061     throw vector_range_exception(i,index_min,index_max);
00062   #else
00063     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00064     "double& dvector::operator[] (int i)", index_min, index_max, i);
00065   #endif
00066   }
00067   return *(v+i);
00068 }
00074 const double& dvector::operator()(int i) const
00075 {
00076   if (i < index_min || index_max < i)
00077   {
00078   #if defined(USE_EXCEPTIONS)
00079     throw vector_range_exception(i,index_min,index_max);
00080   #else
00081     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00082     "double& dvector::operator[] (int i)", index_min, index_max, i);
00083   #endif
00084   }
00085   return *(v+i);
00086 }
00087 #endif