ADMB Documentation  11.1.2192
 All Classes Files Functions Variables Typedefs Friends Defines
d3arr8.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: d3arr8.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 #ifndef OPT_LIB
00013 
00018 const double& d3_array::operator()(int k, int i, int j) const
00019     {
00020         if (k<slicemin())
00021         {
00022           cerr << "array bound exceeded -- slice index too low in "
00023           "d3_array::operator(int,int)";
00024           ad_exit(1);
00025         }
00026         if (k>slicemax())
00027         {
00028           cerr << "array bound exceeded -- slice index too high in "
00029           "d3_array::operator(int,int)";
00030           ad_exit(1);
00031         }
00032       return ( (elem(k))(i,j) );
00033     }
00034 
00039 const dvector& d3_array::operator()(int k, int i) const
00040     {
00041         if (k<slicemin())
00042         {
00043           cerr << "array bound exceeded -- slice index too low in "
00044           "d3_array::operator(int,int)";
00045           ad_exit(1);
00046         }
00047         if (k>slicemax())
00048         {
00049           cerr << "array bound exceeded -- slice index too high in "
00050           "d3_array::operator(int,int)";
00051           ad_exit(1);
00052         }
00053       return ( (elem(k))(i) );
00054     }
00055 
00060 const dmatrix& d3_array::operator[](int i) const
00061  {
00062      if (i<slicemin())
00063      {
00064        cerr << "matrix bound exceeded -- row index too low in "
00065        "3d_array::operator[]" << "value was" << i;
00066        ad_exit(21);
00067      }
00068      if (i>slicemax())
00069      {
00070        cerr << "matrix bound exceeded -- row index too high in "
00071        "3d_array::operator[]" << "value was" << i;
00072        ad_exit(22);
00073      }
00074    return(t[i]);
00075  }
00076 #endif
00077 
00082 d3_array& d3_array::operator=(const d3_array& m1)
00083  {
00084    if (slicemin() != m1.slicemin() || slicemax() != m1.slicemax())
00085    {
00086      cerr << " Incompatible array bounds in "
00087      "d3_array& operator = (const d3_array&)\n";
00088      ad_exit(21);
00089    }
00090 
00091    if (t != m1.t)            // check for condition that both matrices
00092    {                         // don't point to the same object
00093      for (int i=slicemin();i<=slicemax();i++)
00094      {
00095        elem(i)=m1.elem(i);
00096      }
00097    }
00098    return(*this);
00099  }
00100 
00105  d3_array& d3_array::operator= (double x)
00106  {
00107    for (int i=slicemin();i<=slicemax();i++)
00108    {
00109      elem(i)=x;
00110    }
00111    return(*this);
00112  }