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 /* 00044 index_type::index_type(const data_int& x) 00045 { 00046 p = new number_index(x); 00047 } 00048 */ 00049 00054 double_index_type::double_index_type(double x) 00055 { 00056 p = new double_index(x); 00057 } 00058 00063 double_index_type::double_index_type(const dvector& x) 00064 { 00065 p = new dvector_index((const dvector&)(x)); 00066 } 00067 00072 double_index_type::double_index_type(const dmatrix& x) 00073 { 00074 p = new dmatrix_index((const dmatrix&)(x)); 00075 } 00076 00080 dmatrix_index::~dmatrix_index() 00081 { 00082 //DoesNothing 00083 } 00084 00089 double_index_type::double_index_type(const d3_array& x) 00090 { 00091 p = new d3_index((d3_array&)(x)); 00092 } 00093 00098 double_index_type::double_index_type(const pre_double_index_type& pit) 00099 { 00100 p = (*(*(pit.a)).p)[pit.i]; 00101 // Dave uncommented this august 1998 because program crashed 00102 // (*p->ncopies)++; 00103 } 00104 00109 double_index_type double_index_type::operator [] (int i) const 00110 { 00111 return pre_double_index_type(this,i); 00112 } 00113 00118 double_index_type double_index_type::operator () (int i) const 00119 { 00120 return pre_double_index_type(this,i); 00121 } 00122 00127 double_index_type double_index_type::operator [] (int i) 00128 { 00129 return pre_double_index_type(this,i); 00130 } 00131 00136 double_index_type double_index_type::operator () (int i) 00137 { 00138 return pre_double_index_type(this,i); 00139 } 00140 00144 dvector_index::~dvector_index() 00145 { 00146 //DoesNothing 00147 } 00148 00153 double_index_type::~double_index_type () 00154 { 00155 if (!p) 00156 { 00157 cerr << "trying to delete a NULL optr in ~double_index_type()" << endl; 00158 } 00159 else 00160 { 00161 if (!(*(p->ncopies))) 00162 { 00163 delete p; 00164 p = NULL; 00165 } 00166 else 00167 { 00168 (*(p->ncopies))--; 00169 } 00170 } 00171 } 00172 00177 double_index_guts::~double_index_guts() 00178 { 00179 if (!(*ncopies)) 00180 { 00181 delete ncopies; 00182 ncopies=NULL; 00183 } 00184 } 00185 00190 dvector_index::dvector_index(const dvector& v) : dvector(v) 00191 { 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 }
Generated on Tue Mar 8 2016 19:51:32 for ADMB Documentation by 1.8.0 |