Revision 1973 trunk/src/linad99/fvar.hpp
fvar.hpp (revision 1973)  

1946  1946 
}; 
1947  1947 
#endif 
1948  1948  
1949 
/** 

1950 
Holds "shape" information for vector objects. 

1951 
*/ 

1952 
class vector_shapex 

1953 
{ 

1954 
public: 

1955 
vector_shapex(int lb, int ub, void *p):index_min(lb), 

1956 
index_max(ub), ncopies(0), trueptr(p) 

1957 
{ 

1958 
} 

1959 
/// Returns address of first element in the vector. 

1960 
void *get_truepointer(void) 

1961 
{ 

1962 
return trueptr; 

1963 
} 

1964 
friend class dvector; 

1965 
friend class ivector; 

1966 
friend class dvar_vector; 

1967 
#if defined(USE_VECTOR_SHAPE_POOL) 

1968 
static vector_shape_pool *xpool; 

1969 
void *operator new(size_t); 

1970 
void operator delete(void *ptr, size_t) 

1971 
{ 

1972 
xpool>free(ptr); 

1973 
} 

1974 
#endif 

1975 
void shift(int min); 

1976 
int index_min; ///< Minimum valid subscript 

1977 
int index_max; ///< Maximum valid subscript 

1978 
/** Copy counter to enable shallow copies. 

1979 
Initialized to zero in constructor. 

1980 
Incremented by 1 in copy constructor. 

1981 
Decremented by 1 in destructor. 

1982 
Memory is freed when value of ncopies reaches zero 

1983 
in the destructor. 

1984 
*/ 

1985 
unsigned int ncopies; 

1986 
/** Address of first element in the vector. 

1987 
Value set in allocate(...) function. */ 

1988 
void *trueptr; 

1949 
#include "vector_shapex.h" 

1989  1950  
1990 
private: 

1991 
friend class subdvector; 

1992 
friend class lvector; 

1993 
friend class ptr_vector; 

1994 
public: 

1995 
int decr_ncopies(void) ///< Decrement copy counter by 1. 

1996 
{ 

1997 
return ncopies; 

1998 
} 

1999 
int get_ncopies(void) ///< Return value of copy counter 

2000 
{ 

2001 
return ncopies; 

2002 
} 

2003 
int incr_ncopies(void) ///< Increment copy counter by 1. 

2004 
{ 

2005 
return ++ncopies; 

2006 
} 

2007 
int indexmin() ///< Return value of minimum valid subscript. 

2008 
{ 

2009 
return index_min; 

2010 
} 

2011 
int indexmax() ///< Return value of maximum valid subscript. 

2012 
{ 

2013 
return index_max; 

2014 
} 

2015 
}; 

2016  
2017  1951 
/** 
2018  1952 
* Description not yet available. 
2019  1953 
* \param 
...  ...  
2048  1982 
friend class dvar_vector; 
2049  1983 
}; 
2050  1984  
1985 
#include "dvector.h" 

2051  1986  
2052 
/** Vector of double precision numbers. 

2053 
A basic container class for a one dimensional array of double precision 

2054 
floating point numbers. 

2055 
Fundamental building block for higher dimensional arrays. 

2056 
All ADMB vector classes have similar functionality. 

2057 
*/ 

2058 
class dvector 

2059 
{ 

2060 
protected: 

2061 
double *v; ///< pointer to the data 

2062 
int index_min; ///< minimum valid subscript 

2063 
int index_max; ///< maximum valid subscript 

2064 
/// pointer to vector "shape" 

2065 
#if defined(THREAD_SAFE) 

2066 
ts_vector_shapex *shape; 
Also available in: Unified diff