ADMB Documentation  11.1x.2711
 All Classes Files Functions Variables Typedefs Friends Defines
i3arr8.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: i3arr8.cpp 1921 2014-04-23 18:47:05Z 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         if (k<slicemin())
00023         {
00024           cerr << "array bound exceeded -- slice index too low in "
00025           "i3_array::operator(int,int)";
00026           ad_exit(1);
00027         }
00028         if (k>slicemax())
00029         {
00030           cerr << "array bound exceeded -- slice index too high in "
00031           "i3_array::operator(int,int)";
00032           ad_exit(1);
00033         }
00034       return ( (elem(k))(i,j) );
00035     }
00036 
00041 const ivector& i3_array::operator()(int k, int i) const
00042     {
00043         if (k<slicemin())
00044         {
00045           cerr << "array bound exceeded -- slice index too low in "
00046           "i3_array::operator(int,int)";
00047           ad_exit(1);
00048         }
00049         if (k>slicemax())
00050         {
00051           cerr << "array bound exceeded -- slice index too high in "
00052           "i3_array::operator(int,int)";
00053           ad_exit(1);
00054         }
00055       return ( (elem(k))(i) );
00056     }
00057 
00062 const imatrix& i3_array::operator[](int i) const
00063  {
00064      if (i<slicemin())
00065      {
00066        cerr << "matrix bound exceeded -- row index too low in "
00067           "3d_array::operator[]"
00068              << "value was" << i;
00069        ad_exit(21);
00070      }
00071      if (i>slicemax())
00072      {
00073        cerr << "matrix bound exceeded -- row index too high in "
00074           "3d_array::operator[]"
00075              << "value was" << i;
00076        ad_exit(22);
00077      }
00078    return(t[i]);
00079  }
00080 
00085 const imatrix& i3_array::operator()(int i) const
00086  {
00087      if (i<slicemin())
00088      {
00089        cerr << "matrix bound exceeded -- row index too low in "
00090           "3d_array::operator[]"
00091              << "value was" << i;
00092        ad_exit(21);
00093      }
00094      if (i>slicemax())
00095      {
00096        cerr << "matrix bound exceeded -- row index too high in "
00097           "3d_array::operator[]"
00098              << "value was" << i;
00099        ad_exit(22);
00100      }
00101    return(t[i]);
00102  }
00103 #endif
00104 
00109 i3_array& i3_array::operator=(const i3_array& m1)
00110  {
00111    if (slicemin() != m1.slicemin() || slicemax() != m1.slicemax())
00112    {
00113      cerr << " Incompatible array bounds in "
00114           "i3_array& operator = (const i3_array&)\n";
00115      ad_exit(21);
00116    }
00117 
00118    if (t != m1.t)            // check for condition that both matrices
00119    {                         // don't point to the same object
00120      for (int i=slicemin();i<=slicemax();i++)
00121      {
00122        elem(i)=m1.elem(i);
00123      }
00124    }
00125    return(*this);
00126  }
00127 
00128  /*
00129  i3_array& i3_array::operator= (int x)
00130  {
00131    for (int i=slicemin();i<=slicemax();i++)
00132    {
00133      elem(i)=x;
00134    }
00135    return(*this);
00136  }
00137  */