ADMB Documentation  11.1.1916
 All Classes Files Functions Variables Typedefs Friends Defines
dmat_acc.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: dmat_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  dvector& dmatrix::operator[] (int i)
00021  {
00022    #ifdef SAFE_ARRAYS
00023      if (i < rowmin())
00024      {
00025        ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
00026        "dvector& dmatrix::operator[] (int i)", rowmin(), rowmax(), i);
00027      }
00028      if (i > rowsize()+rowmin()-1)
00029      {
00030        ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too high",
00031        "dvector& dmatrix::operator[] (int i)", rowmin(), rowmax(), i);
00032      }
00033    #endif
00034    return *(m+i);
00035  }
00036 
00041 const dvector& dmatrix::operator[](int i) const
00042  {
00043    #ifdef SAFE_ARRAYS
00044      if (i<rowmin())
00045      {
00046        cerr << "matrix bound exceeded -- row index too low in "
00047        "dmatrix::operator[]" << "value was" << i;
00048        ad_exit(21);
00049      }
00050      if (i>rowsize()+rowmin()-1)
00051      {
00052        cerr << "matrix bound exceeded -- row index too high in "
00053        "dmatrix::operator[]" << "value was" << i;
00054        ad_exit(22);
00055      }
00056    #endif
00057    return *(m+i);
00058  }
00059 #endif