ADMB Documentation  11.1.1913
 All Classes Files Functions Variables Typedefs Friends Defines
d3arr8.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: d3arr8.cpp 1711 2014-02-28 22:46:44Z 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       #ifdef SAFE_ARRAYS
00021         if (k<slicemin())
00022         {
00023           cerr << "array bound exceeded -- slice index too low in "
00024           "d3_array::operator(int,int)";
00025           ad_exit(1);
00026         }
00027         if (k>slicemax())
00028         {
00029           cerr << "array bound exceeded -- slice index too high in "
00030           "d3_array::operator(int,int)";
00031           ad_exit(1);
00032         }
00033       #endif
00034       return ( (elem(k))(i,j) );
00035     }
00036 
00041 const dvector& d3_array::operator()(int k, int i) const
00042     {
00043       #ifdef SAFE_ARRAYS
00044         if (k<slicemin())
00045         {
00046           cerr << "array bound exceeded -- slice index too low in "
00047           "d3_array::operator(int,int)";
00048           ad_exit(1);
00049         }
00050         if (k>slicemax())
00051         {
00052           cerr << "array bound exceeded -- slice index too high in "
00053           "d3_array::operator(int,int)";
00054           ad_exit(1);
00055         }
00056       #endif
00057       return ( (elem(k))(i) );
00058     }
00059 
00064 const dmatrix& d3_array::operator[](int i) const
00065  {
00066    #ifdef SAFE_ARRAYS
00067      if (i<slicemin())
00068      {
00069        cerr << "matrix bound exceeded -- row index too low in "
00070        "3d_array::operator[]" << "value was" << i;
00071        ad_exit(21);
00072      }
00073      if (i>slicemax())
00074      {
00075        cerr << "matrix bound exceeded -- row index too high in "
00076        "3d_array::operator[]" << "value was" << i;
00077        ad_exit(22);
00078      }
00079    #endif
00080    return(t[i]);
00081  }
00082 #endif
00083 
00088 d3_array& d3_array::operator=(const d3_array& m1)
00089  {
00090    if (slicemin() != m1.slicemin() || slicemax() != m1.slicemax())
00091    {
00092      cerr << " Incompatible array bounds in "
00093      "d3_array& operator = (const d3_array&)\n";
00094      ad_exit(21);
00095    }
00096 
00097    if (t != m1.t)            // check for condition that both matrices
00098    {                         // don't point to the same object
00099      for (int i=slicemin();i<=slicemax();i++)
00100      {
00101        elem(i)=m1.elem(i);
00102      }
00103    }
00104    return(*this);
00105  }
00106 
00111  d3_array& d3_array::operator= (double x)
00112  {
00113    for (int i=slicemin();i<=slicemax();i++)
00114    {
00115      elem(i)=x;
00116    }
00117    return(*this);
00118  }