ADMB Documentation  11.4.2891
 All Classes Files Functions Variables Typedefs Friends Defines
doublind.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
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(x);
00046 }
00047 
00052   double_index_type::double_index_type(double x)
00053   {
00054     p = new double_index(x);
00055   }
00056 
00061 double_index_type::double_index_type(const dvector& x)
00062   {
00063     p = new dvector_index((const dvector&)(x));
00064   }
00065 
00070   double_index_type::double_index_type(const dmatrix& x)
00071   {
00072     p = new dmatrix_index((const dmatrix&)(x));
00073   }
00074 
00078 dmatrix_index::~dmatrix_index()
00079 {
00080   //DoesNothing
00081 }
00082 
00087   double_index_type::double_index_type(const d3_array& x)
00088   {
00089     p = new d3_index((d3_array&)(x));
00090   }
00091 
00096   double_index_type::double_index_type(const pre_double_index_type& pit)
00097   {
00098     p = (*(*(pit.a)).p)[pit.i];
00099   // Dave uncommented this august 1998 because program crashed
00100    // (*p->ncopies)++;
00101   }
00102 
00107   double_index_type double_index_type::operator [] (int i) const
00108   {
00109     return pre_double_index_type(this,i);
00110   }
00111 
00116   double_index_type double_index_type::operator () (int i) const
00117   {
00118     return pre_double_index_type(this,i);
00119   }
00120 
00125   double_index_type double_index_type::operator [] (int i)
00126   {
00127     return pre_double_index_type(this,i);
00128   }
00129 
00134   double_index_type double_index_type::operator () (int i)
00135   {
00136     return pre_double_index_type(this,i);
00137   }
00138 
00142 dvector_index::~dvector_index()
00143 {
00144   //DoesNothing
00145 }
00146 
00151   double_index_type::~double_index_type ()
00152   {
00153     if (!p)
00154     {
00155       cerr << "trying to delete a NULL optr in ~double_index_type()"  << endl;
00156     }
00157     else
00158     {
00159       if (!(*(p->ncopies)))
00160       {
00161         delete p;
00162         p = NULL;
00163       }
00164       else
00165       {
00166         (*(p->ncopies))--;
00167       }
00168     }
00169   }
00170 
00175 double_index_guts::~double_index_guts()
00176 {
00177   if (!(*ncopies))
00178   {
00179     delete ncopies;
00180     ncopies=NULL;
00181   }
00182 }
00183 
00188 dvector_index::dvector_index(const dvector& v) : dvector(v)
00189 {
00190 }
00191 
00196 double_index_guts::double_index_guts()
00197 {
00198   ncopies = new int;
00199   *ncopies=0;
00200 }
00201 
00206 double_index_guts::double_index_guts(const double_index_guts& ig)
00207 {
00208   ncopies = ig.ncopies;
00209   (*ncopies)++;
00210 }
00211 
00216 double_index_guts * double_index::operator [] (int i)
00217 {
00218   return new double_index(double(*this));
00219 }