ADMB Documentation  11.1.1903
 All Classes Files Functions Variables Typedefs Friends Defines
imat2.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: imat2.cpp 1716 2014-03-03 20:34:53Z 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 #if !defined(OPT_LIB)
00018 
00023  int& imatrix::operator() (int i,int j)
00024  {
00025    #ifdef SAFE_ARRAYS
00026    if (i < rowmin())
00027    {
00028      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
00029      "int& imatrix::operator() (int i, int j)", rowmin(), rowmax(), i);
00030    }
00031    if (i > rowmax())
00032    {
00033      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too high",
00034      "int& imatrix::operator() (int i, int j)", rowmin(), rowmax(), i);
00035    }
00036    if (j < (*this)(i).indexmin())
00037    {
00038      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
00039      "int& imatrix::operator() (int i, int j)",
00040      (*this)(i).indexmin(), (*this)(i).indexmax(), j);
00041    }
00042    if (j > (*this)(i).indexmax())
00043    {
00044      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too high",
00045      "int& imatrix::operator() (int i, int j)",
00046      (*this)(i).indexmin(), (*this)(i).indexmax(), j);
00047    }
00048    #endif
00049    return(*((*(m+i)).v+j));
00050  }
00051 
00056 const int& imatrix::operator()(int i, int j) const
00057  {
00058    #ifdef SAFE_ARRAYS
00059      if (i<rowmin())
00060      {
00061        cerr << "matrix bound exceeded -- row index too low in "
00062        "imatrix::operator()(int, int)"
00063              << "\nvalue was " << i << endl;
00064        ad_exit(21);
00065      }
00066      if (i>rowmax())
00067      {
00068        cerr << "matrix bound exceeded -- row index too high in "
00069        "imatrix::operator()(int, int)"
00070              << "\nvalue was " << i << endl;
00071        ad_exit(22);
00072      }
00073      if (j<(*this)(i).indexmin())
00074      {
00075        cerr << "matrix bound exceeded -- column index too low in "
00076        "imatrix::operator()(int, int)"
00077             << "\nvalue was " << j << endl;
00078        ad_exit(21);
00079      }
00080      if (j>(*this)(i).indexmax())
00081      {
00082        cerr << "matrix bound exceeded -- column index too high in "
00083        "imatrix::operator()(int, int)"
00084             << "\nvalue was " << j << endl;
00085        ad_exit(22);
00086      }
00087    #endif
00088    return(*((*(m+i)).v+j));
00089  }
00090 #endif