ADMB Documentation  11.1.2500
 All Classes Files Functions Variables Typedefs Friends Defines
f3arr15.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: f3arr15.cpp 1938 2014-04-26 06:13:12Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <fvar.hpp>
00012 
00017  dvar3_array::dvar3_array(ad_integer sl,ad_integer  sh,
00018      const index_type& nrl, const index_type& nrh,
00019      const index_type& ncl, const index_type& nch)
00020  {
00021    allocate(sl,sh,nrl,nrh,ncl,nch);
00022 #ifndef OPT_LIB
00023    initialize();
00024 #endif
00025  }
00026 
00031  void dvar3_array::allocate(ad_integer sl,ad_integer  sh,
00032      const index_type& nrl, const index_type& nrh,
00033      const index_type& ncl, const index_type& nch)
00034  {
00035    if (sh<sl)
00036    {
00037      allocate();
00038    }
00039    else
00040    {
00041      #ifdef DIAG
00042        myheapcheck("Entering d3_array matrix(sl,sh,nrl,nrh,ncl,nch)" );
00043      #endif
00044      if ( (nrl.isinteger() && (sl !=nrl.indexmin() || sh !=nrl.indexmax())) ||
00045          (nrh.isinteger() && (sl !=nrh.indexmin() || sh !=nrh.indexmax())) )
00046      {
00047        cerr << nrl.isinteger() << " " << nrh.isinteger() << endl;
00048        cerr << sl << " " << nrl.indexmin() << endl;
00049        cerr << sh << " " << nrl.indexmax() << endl;
00050        cerr << sl << " " << nrh.indexmin() << endl;
00051        cerr << sh << " " << nrh.indexmax() << endl;
00052        cerr << "Incompatible array bounds in dvar3_array(int nrl,int nrh,"
00053         "const index_type& nrl,const index_type& nrh,"
00054         "const index_type& ncl,const index_type& nch)" << endl;
00055        ad_exit(1);
00056      }
00057 
00058      if ( (shape=new three_array_shape(sl,sh)) == 0)
00059      {
00060        cerr << " Error allocating memory in dvar3_array contructor" << endl;
00061      }
00062      int ss=slicesize();
00063      if ( (t = new dvar_matrix[ss]) == 0)
00064      {
00065        cerr << " Error allocating memory in dvar3_array contructor" << endl;
00066        ad_exit(21);
00067      }
00068      t -= slicemin();
00069      for (int i=sl; i<=sh; i++)
00070      {
00071        t[i].allocate(nrl[i],nrh[i],ncl[i],nch[i]);
00072      }
00073    }
00074  }
00075 
00080  void dvar3_array::allocate(ad_integer sl,ad_integer  sh,
00081      const index_type& nrl, const index_type& nrh)
00082  {
00083    if (sh<sl)
00084    {
00085      allocate();
00086    }
00087    else
00088    {
00089      #ifdef DIAG
00090        myheapcheck("Entering d3_array matrix(sl,sh,nrl,nrh,ncl,nch)" );
00091      #endif
00092      if ( (nrl.isinteger() && (sl !=nrl.indexmin() || sh !=nrl.indexmax())) ||
00093          (nrh.isinteger() && (sl !=nrh.indexmin() || sh !=nrh.indexmax())) )
00094      {
00095        cerr << nrl.isinteger() << " " << nrh.isinteger() << endl;
00096        cerr << sl << " " << nrl.indexmin() << endl;
00097        cerr << sh << " " << nrl.indexmax() << endl;
00098        cerr << sl << " " << nrh.indexmin() << endl;
00099        cerr << "Incompatible array bounds in dvar3_array(int nrl,int nrh,"
00100         "const index_type& nrl,const index_type& nrh,"
00101         "const index_type& ncl,const index_type& nch)" << endl;
00102        ad_exit(1);
00103      }
00104 
00105      if ( (shape=new three_array_shape(sl,sh)) == 0)
00106      {
00107        cerr << " Error allocating memory in dvar3_array contructor" << endl;
00108      }
00109      int ss=slicesize();
00110      if ( (t = new dvar_matrix[ss]) == 0)
00111      {
00112        cerr << " Error allocating memory in dvar3_array contructor" << endl;
00113        ad_exit(21);
00114      }
00115      t -= slicemin();
00116      for (int i=sl; i<=sh; i++)
00117      {
00118        t[i].allocate(nrl[i],nrh[i]);
00119      }
00120    }
00121  }
00122 
00127  void dvar3_array::allocate(ad_integer sl,ad_integer  sh)
00128  {
00129    if (sh<sl)
00130    {
00131      allocate();
00132    }
00133    else
00134    {
00135      #ifdef DIAG
00136        myheapcheck("Entering d3_array matrix(sl,sh,nrl,nrh,ncl,nch)" );
00137      #endif
00138 
00139      if ( (shape=new three_array_shape(sl,sh)) == 0)
00140      {
00141        cerr << " Error allocating memory in dvar3_array contructor" << endl;
00142      }
00143      int ss=slicesize();
00144      if ( (t = new dvar_matrix[ss]) == 0)
00145      {
00146        cerr << " Error allocating memory in dvar3_array contructor" << endl;
00147        ad_exit(21);
00148      }
00149      t -= slicemin();
00150      for (int i=sl; i<=sh; i++)
00151      {
00152        t[i].allocate();
00153      }
00154    }
00155  }