ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
lmat2.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 //#undef OPT_LIB
00012 #include "fvar.hpp"
00013 #include "admb_messages.h"
00014 #ifdef __TURBOC__
00015   #pragma hdrstop
00016 #endif
00017 #if !defined (OPT_LIB)
00018 
00023 AD_LONG_INT& lmatrix::operator()(int i, int j)
00024  {
00025    if (i < rowmin())
00026    {
00027      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
00028      "AD_LONG_INT& lmatrix::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      "AD_LONG_INT& lmatrix::operator() (int i, int j)", rowmin(), rowmax(), i);
00034    }
00035    if (j < (*this)(i).indexmin())
00036    {
00037      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- column index too low",
00038      "AD_LONG_INT& lmatrix::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 -- column index too low",
00044      "AD_LONG_INT& lmatrix::operator() (int i, int j)",
00045      (*this)(i).indexmin(), (*this)(i).indexmax(), j);
00046    }
00047    return(*((*(m+i)).v+j));
00048  }
00049 
00054 const AD_LONG_INT& lmatrix::operator()(int i, int j) const
00055  {
00056      if (i<rowmin())
00057      {
00058        cerr << "matrix bound exceeded -- row index too low in "
00059        "lmatrix::operator()(int, int)" << "\nvalue was " << i;
00060        ad_exit(21);
00061      }
00062      if (i>rowmax())
00063      {
00064        cerr << "matrix bound exceeded -- row index too high in "
00065        "lmatrix::operator()(int, int)" << "\nvalue was " << i;
00066        ad_exit(22);
00067      }
00068      if (j<(*this)(i).indexmin())
00069      {
00070        cerr << "matrix bound exceeded -- column index too low in "
00071        "lmatrix::operator()(int, int)" << "\nvalue was " << j;
00072        ad_exit(21);
00073      }
00074      if (j>(*this)(i).indexmax())
00075      {
00076        cerr << "matrix bound exceeded -- column index too high in "
00077        "lmatrix::operator()(int, int)" << "\nvalue was " << j;
00078        ad_exit(22);
00079      }
00080    return(*((*(m+i)).v+j));
00081  }
00082 #endif