ADMB Documentation  11.1.1903
 All Classes Files Functions Variables Typedefs Friends Defines
doublind.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: doublind.cpp 1247 2013-11-08 01:35:18Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <admodel.h>
00012 
00017   double_index_type::double_index_type(const double_index_type& pit)
00018   {
00019     p=pit.p;
00020     (*(p->ncopies))++;
00021   }
00022 
00023   ad_double::ad_double(const double_index_type& it) : d(it.ddouble()) {}
00024 
00029   double_index_guts * dmatrix_index::operator [] (int i)
00030   {
00031     return new dvector_index(dmatrix::operator [](i));
00032   }
00033 
00038   double double_index_type::ddouble(void) const
00039   {
00040     return double(*p);
00041   }
00042   /*
00043   index_type::index_type(const data_int& x)
00044   {
00045     p = new number_index(int(data_int(x)));
00046   }
00047    */
00048 
00053   double_index_type::double_index_type(double x)
00054   {
00055     p = new double_index(x);
00056   }
00057 
00062 double_index_type::double_index_type(const dvector& x)
00063   {
00064     p = new dvector_index((const dvector&)(x));
00065   }
00066 
00071   double_index_type::double_index_type(const dmatrix& x)
00072   {
00073     p = new dmatrix_index((const dmatrix&)(x));
00074   }
00075 
00079 dmatrix_index::~dmatrix_index()
00080 {
00081   //DoesNothing
00082 }
00083 
00088   double_index_type::double_index_type(const d3_array& x)
00089   {
00090     p = new d3_index((d3_array&)(x));
00091   }
00092 
00097   double_index_type::double_index_type(const pre_double_index_type& pit)
00098   {
00099     p = (*(*(pit.a)).p)[pit.i];
00100   // Dave uncommented this august 1998 because program crashed
00101    // (*p->ncopies)++;
00102   }
00103 
00108   double_index_type double_index_type::operator [] (int i) const
00109   {
00110     return pre_double_index_type(this,i);
00111   }
00112 
00117   double_index_type double_index_type::operator () (int i) const
00118   {
00119     return pre_double_index_type(this,i);
00120   }
00121 
00126   double_index_type double_index_type::operator [] (int i)
00127   {
00128     return pre_double_index_type(this,i);
00129   }
00130 
00135   double_index_type double_index_type::operator () (int i)
00136   {
00137     return pre_double_index_type(this,i);
00138   }
00139 
00143 dvector_index::~dvector_index()
00144 {
00145   //DoesNothing
00146 }
00147 
00152   double_index_type::~double_index_type ()
00153   {
00154     if (!p)
00155     {
00156       cerr << "trying to delete a NULL optr in ~double_index_type()"  << endl;
00157     }
00158     else
00159     {
00160       if (!(*(p->ncopies)))
00161       {
00162         delete p;
00163         p = NULL;
00164       }
00165       else
00166       {
00167         (*(p->ncopies))--;
00168       }
00169     }
00170   }
00171 
00176 double_index_guts::~double_index_guts()
00177 {
00178   if (!(*ncopies))
00179   {
00180     delete ncopies;
00181     ncopies=NULL;
00182   }
00183 }
00184 
00189 dvector_index::dvector_index(const dvector& v) : dvector(v)
00190 {
00191   //xxjj();
00192 }
00193 
00198 double_index_guts::double_index_guts()
00199 {
00200   ncopies = new int;
00201   *ncopies=0;
00202 }
00203 
00208 double_index_guts::double_index_guts(const double_index_guts& ig)
00209 {
00210   ncopies = ig.ncopies;
00211   (*ncopies)++;
00212 }
00213 
00218 double_index_guts * double_index::operator [] (int i)
00219 {
00220   return new double_index(double(*this));
00221 }