ADMB Documentation  11.1.1890
 All Classes Files Functions Variables Typedefs Friends Defines
imat4.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: imat4.cpp 1713 2014-03-01 00:26:20Z 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 #ifdef __TURBOC__
00014   #pragma hdrstop
00015 #endif
00016 
00017 #ifndef OPT_LIB
00018 
00023  ivector& imatrix::operator[] (int i)
00024  {
00025    #ifdef SAFE_ARRAYS
00026    if (i < rowmin())
00027    {
00028      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
00029      "ivector& imatrix::operator[] (int i)", rowmin(), rowmax(), i);
00030    }
00031    if (i > rowsize() + rowmin() - 1)
00032    {
00033      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too high",
00034      "ivector& imatrix::operator[] (int i)", rowmin(), rowmax(), i);
00035    }
00036    #endif
00037    return m[i];
00038  }
00039 
00044 const ivector& imatrix::operator[](int i) const
00045  {
00046    #ifdef SAFE_ARRAYS
00047      if (i<rowmin())
00048      {
00049        cerr << "matrix bound exceeded -- row index too low in "
00050        "imatrix::operator[]" << "value was" << i;
00051        ad_exit(21);
00052      }
00053      if (i>rowsize()+rowmin()-1)
00054      {
00055        cerr << "matrix bound exceeded -- row index too high in "
00056        "imatrix::operator[]" << "value was" << i;
00057        ad_exit(22);
00058      }
00059    #endif
00060    return m[i];
00061  }
00062 #endif