ADMB Documentation  11.1.1913
 All Classes Files Functions Variables Typedefs Friends Defines
dvec_acc.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dvec_acc.cpp 1712 2014-02-28 23:52:33Z 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 #ifdef SAFE_ARRAYS
00023   if (i < index_min || index_max < i)
00024   {
00025   #if defined(USE_EXCEPTIONS)
00026     throw vector_range_exception(i,index_min,index_max);
00027   #else
00028     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00029     "double& dvector::operator[] (int i)", index_min, index_max, i);
00030   #endif
00031   }
00032 #endif
00033   return *(v+i);
00034 }
00040 double& dvector::operator()(int i)
00041 {
00042 #ifdef SAFE_ARRAYS
00043   if (i < index_min || index_max < i)
00044   {
00045   #if defined(USE_EXCEPTIONS)
00046     throw vector_range_exception(i,index_min,index_max);
00047   #else
00048     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00049     "double& dvector::operator[] (int i)", index_min, index_max, i);
00050   #endif
00051   }
00052 #endif
00053   return *(v+i);
00054 }
00060 const double& dvector::operator[](int i) const
00061 {
00062 #ifdef SAFE_ARRAYS
00063   if (i < index_min || index_max < i)
00064   {
00065   #if defined(USE_EXCEPTIONS)
00066     throw vector_range_exception(i,index_min,index_max);
00067   #else
00068     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00069     "double& dvector::operator[] (int i)", index_min, index_max, i);
00070   #endif
00071   }
00072 #endif
00073   return *(v+i);
00074 }
00080 const double& dvector::operator()(int i) const
00081 {
00082 #ifdef SAFE_ARRAYS
00083   if (i < index_min || index_max < i)
00084   {
00085   #if defined(USE_EXCEPTIONS)
00086     throw vector_range_exception(i,index_min,index_max);
00087   #else
00088     ADMB_ARRAY_BOUNDS_ERROR("invalid index for array",
00089     "double& dvector::operator[] (int i)", index_min, index_max, i);
00090   #endif
00091   }
00092 #endif
00093   return *(v+i);
00094 }
00095 #endif