ADMB Documentation  11.1.1890
 All Classes Files Functions Variables Typedefs Friends Defines
lmat2.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: lmat2.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 //#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    #ifdef SAFE_ARRAYS
00026    if (i < rowmin())
00027    {
00028      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- row index too low",
00029      "AD_LONG_INT& lmatrix::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      "AD_LONG_INT& lmatrix::operator() (int i, int j)", rowmin(), rowmax(), i);
00035    }
00036    if (j < (*this)(i).indexmin())
00037    {
00038      ADMB_ARRAY_BOUNDS_ERROR("matrix bound exceeded -- column index too low",
00039      "AD_LONG_INT& lmatrix::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 -- column index too low",
00045      "AD_LONG_INT& lmatrix::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 AD_LONG_INT& lmatrix::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        "lmatrix::operator()(int, int)" << "\nvalue was " << i;
00063        ad_exit(21);
00064      }
00065      if (i>rowmax())
00066      {
00067        cerr << "matrix bound exceeded -- row index too high in "
00068        "lmatrix::operator()(int, int)" << "\nvalue was " << i;
00069        ad_exit(22);
00070      }
00071      if (j<(*this)(i).indexmin())
00072      {
00073        cerr << "matrix bound exceeded -- column index too low in "
00074        "lmatrix::operator()(int, int)" << "\nvalue was " << j;
00075        ad_exit(21);
00076      }
00077      if (j>(*this)(i).indexmax())
00078      {
00079        cerr << "matrix bound exceeded -- column index too high in "
00080        "lmatrix::operator()(int, int)" << "\nvalue was " << j;
00081        ad_exit(22);
00082      }
00083    #endif
00084    return(*((*(m+i)).v+j));
00085  }
00086 #endif