ADMB Documentation  11.1.1913
 All Classes Files Functions Variables Typedefs Friends Defines
i3arr8.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: i3arr8.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 "i3_array.h"
00013 
00014 #ifndef OPT_LIB
00015 
00020 const int& i3_array::operator()(int k, int i, int j) const
00021     {
00022       #ifdef SAFE_ARRAYS
00023         if (k<slicemin())
00024         {
00025           cerr << "array bound exceeded -- slice index too low in "
00026           "i3_array::operator(int,int)";
00027           ad_exit(1);
00028         }
00029         if (k>slicemax())
00030         {
00031           cerr << "array bound exceeded -- slice index too high in "
00032           "i3_array::operator(int,int)";
00033           ad_exit(1);
00034         }
00035       #endif
00036       return ( (elem(k))(i,j) );
00037     }
00038 
00043 const ivector& i3_array::operator()(int k, int i) const
00044     {
00045       #ifdef SAFE_ARRAYS
00046         if (k<slicemin())
00047         {
00048           cerr << "array bound exceeded -- slice index too low in "
00049           "i3_array::operator(int,int)";
00050           ad_exit(1);
00051         }
00052         if (k>slicemax())
00053         {
00054           cerr << "array bound exceeded -- slice index too high in "
00055           "i3_array::operator(int,int)";
00056           ad_exit(1);
00057         }
00058       #endif
00059       return ( (elem(k))(i) );
00060     }
00061 
00066 const imatrix& i3_array::operator[](int i) const
00067  {
00068    #ifdef SAFE_ARRAYS
00069      if (i<slicemin())
00070      {
00071        cerr << "matrix bound exceeded -- row index too low in "
00072           "3d_array::operator[]"
00073              << "value was" << i;
00074        ad_exit(21);
00075      }
00076      if (i>slicemax())
00077      {
00078        cerr << "matrix bound exceeded -- row index too high in "
00079           "3d_array::operator[]"
00080              << "value was" << i;
00081        ad_exit(22);
00082      }
00083    #endif
00084    return(t[i]);
00085  }
00086 
00091 const imatrix& i3_array::operator()(int i) const
00092  {
00093    #ifdef SAFE_ARRAYS
00094      if (i<slicemin())
00095      {
00096        cerr << "matrix bound exceeded -- row index too low in "
00097           "3d_array::operator[]"
00098              << "value was" << i;
00099        ad_exit(21);
00100      }
00101      if (i>slicemax())
00102      {
00103        cerr << "matrix bound exceeded -- row index too high in "
00104           "3d_array::operator[]"
00105              << "value was" << i;
00106        ad_exit(22);
00107      }
00108    #endif
00109    return(t[i]);
00110  }
00111 #endif
00112 
00117 i3_array& i3_array::operator=(const i3_array& m1)
00118  {
00119    if (slicemin() != m1.slicemin() || slicemax() != m1.slicemax())
00120    {
00121      cerr << " Incompatible array bounds in "
00122           "i3_array& operator = (const i3_array&)\n";
00123      ad_exit(21);
00124    }
00125 
00126    if (t != m1.t)            // check for condition that both matrices
00127    {                         // don't point to the same object
00128      for (int i=slicemin();i<=slicemax();i++)
00129      {
00130        elem(i)=m1.elem(i);
00131      }
00132    }
00133    return(*this);
00134  }
00135 
00136  /*
00137  i3_array& i3_array::operator= (int x)
00138  {
00139    for (int i=slicemin();i<=slicemax();i++)
00140    {
00141      elem(i)=x;
00142    }
00143    return(*this);
00144  }
00145  */