/*
 * $Id: i3arr8.cpp 1921 2014-04-23 18:47:05Z johnoel $
 *
 * Author: David Fournier
 * Copyright (c) 2008-2012 Regents of the University of California
 */
/**
 * \file
 * Description not yet available.
 */
#include "fvar.hpp"
//#include "i3_array.h"

#ifndef OPT_LIB

/**
 * Description not yet available.
 * \param
 */
const int& i3_array::operator()(int k, int i, int j) const
    {
        if (k<slicemin())
        {
          cerr << "array bound exceeded -- slice index too low in "
          "i3_array::operator(int,int)";
          ad_exit(1);
        }
        if (k>slicemax())
        {
          cerr << "array bound exceeded -- slice index too high in "
          "i3_array::operator(int,int)";
          ad_exit(1);
        }
      return ( (elem(k))(i,j) );
    }

/**
 * Description not yet available.
 * \param
 */
const ivector& i3_array::operator()(int k, int i) const
    {
        if (k<slicemin())
        {
          cerr << "array bound exceeded -- slice index too low in "
          "i3_array::operator(int,int)";
          ad_exit(1);
        }
        if (k>slicemax())
        {
          cerr << "array bound exceeded -- slice index too high in "
          "i3_array::operator(int,int)";
          ad_exit(1);
        }
      return ( (elem(k))(i) );
    }

/**
 * Description not yet available.
 * \param
 */
const imatrix& i3_array::operator[](int i) const
 {
     if (i<slicemin())
     {
       cerr << "matrix bound exceeded -- row index too low in "
          "3d_array::operator[]"
             << "value was" << i;
       ad_exit(21);
     }
     if (i>slicemax())
     {
       cerr << "matrix bound exceeded -- row index too high in "
          "3d_array::operator[]"
             << "value was" << i;
       ad_exit(22);
     }
   return(t[i]);
 }

/**
 * Description not yet available.
 * \param
 */
const imatrix& i3_array::operator()(int i) const
 {
     if (i<slicemin())
     {
       cerr << "matrix bound exceeded -- row index too low in "
          "3d_array::operator[]"
             << "value was" << i;
       ad_exit(21);
     }
     if (i>slicemax())
     {
       cerr << "matrix bound exceeded -- row index too high in "
          "3d_array::operator[]"
             << "value was" << i;
       ad_exit(22);
     }
   return(t[i]);
 }
#endif

/**
 * Description not yet available.
 * \param
 */
i3_array& i3_array::operator=(const i3_array& m1)
 {
   if (slicemin() != m1.slicemin() || slicemax() != m1.slicemax())
   {
     cerr << " Incompatible array bounds in "
          "i3_array& operator = (const i3_array&)\n";
     ad_exit(21);
   }

   if (t != m1.t)            // check for condition that both matrices
   {                         // don't point to the same object
     for (int i=slicemin();i<=slicemax();i++)
     {
       elem(i)=m1.elem(i);
     }
   }
   return(*this);
 }

 /*
 i3_array& i3_array::operator= (int x)
 {
   for (int i=slicemin();i<=slicemax();i++)
   {
     elem(i)=x;
   }
   return(*this);
 }
 */
