ADMB Documentation  11.1.1903
 All Classes Files Functions Variables Typedefs Friends Defines
fvma_acc.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvma_acc.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 
00014 #ifndef OPT_LIB
00015 
00020     prevariable dvar_matrix::operator () (int i, int j)
00021     {
00022       #ifdef SAFE_ARRAYS
00023       if (i < rowmin())
00024       {
00025         ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
00026         "prevariable dvar_matrix::operator () (int i, int j)",
00027         rowmin(), rowmax(), i);
00028       }
00029       if (i > rowmax())
00030       {
00031         ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
00032         "prevariable dvar_matrix::operator () (int i, int j)",
00033         rowmin(), rowmax(), i);
00034       }
00035       if (j < elem(i).indexmin())
00036       {
00037         ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- second index too low",
00038         "prevariable dvar_matrix::operator () (int i, int j)",
00039         elem(i).indexmin(), elem(i).indexmax(), j);
00040       }
00041       if (j > elem(i).indexmax())
00042       {
00043         ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- second index too high",
00044         "prevariable dvar_matrix::operator () (int i, int j)",
00045         elem(i).indexmin(), elem(i).indexmax(), j);
00046       }
00047       #endif
00048       return ( m[i].va+j );
00049     }
00050 
00055  dvar_vector& dvar_matrix::operator[] (int i)
00056  {
00057    #ifdef SAFE_ARRAYS
00058    if (i < rowmin())
00059    {
00060      ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too low",
00061      "prevariable dvar_matrix::operator () (int i, int j)",
00062      rowmin(), rowmax(), i);
00063    }
00064    if (i > rowsize() + rowmin() - 1)
00065    {
00066      ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- index too high",
00067      "prevariable dvar_matrix::operator () (int i, int j)",
00068      rowmin(), rowmax(), i);
00069    }
00070    #endif
00071    return (m[i]);
00072  }
00073 
00078 const prevariable dvar_matrix::operator()(int i, int j) const
00079     {
00080       #ifdef SAFE_ARRAYS
00081         if (i<rowmin())
00082         {
00083           cerr << "array bound exceeded -- index too low in "
00084           "dvar_matrix::operator(int,int)"
00085                << " first argument was " << i << endl;
00086           ad_exit(21);
00087         }
00088         if (j<elem(i).indexmin())
00089         {
00090           cerr << "array bound exceeded -- index too low in "
00091           "dvar_matrix::operator(int,int)"
00092                << " first argument was " << i << endl;
00093           ad_exit(22);
00094         }
00095         if (i>rowmax())
00096         {
00097           cerr << "array bound exceeded -- index too high in "
00098           "dvar_matrix::operator(int,int)"
00099                << " second argument was " << j << endl;
00100           ad_exit(23);
00101         }
00102         if (j>elem(i).indexmax())
00103         {
00104           cerr << "array bound exceeded -- index too high in "
00105           "dvar_matrix::operator(int,int)"
00106                << " second argument was " << j << endl;
00107           ad_exit(24);
00108         }
00109       #endif
00110       return ( m[i].va+j );
00111     }
00112 
00117 const dvar_vector& dvar_matrix::operator[](int i) const
00118  {
00119    #ifdef SAFE_ARRAYS
00120      if (i<rowmin())
00121      {
00122        cerr << "matrix bound exceeded -- row index too low in "
00123           "dvar_matrix::operator[]"
00124              << "value was" << i;
00125        ad_exit(21);
00126      }
00127      if (i>rowsize()+rowmin()-1)
00128      {
00129        cerr << "matrix bound exceeded -- row index too high in "
00130           "dvar_matrix::operator[]"
00131              << "value was" << i;
00132        ad_exit(22);
00133      }
00134    #endif
00135    return (m[i]);
00136  }
00137 #endif