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