ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vector_shapex.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  *
7  * ADModelbuilder and associated libraries and documentations are
8  * provided under the general terms of the "New BSD" license
9  *
10  * License:
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are
14  * met:
15  *
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  *
19  * 2. Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  *
23  * 3. Neither the name of the University of California, Otter Research,
24  * nor the ADMB Foundation nor the names of its contributors may be used
25  * to endorse or promote products derived from this software without
26  * specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef __ADMB_VECTOR_SHAPEX_H__
42 #define __ADMB_VECTOR_SHAPEX_H__
43 
47 {
48 #if defined(USE_VECTOR_SHAPE_POOL)
49 public:
50  static vector_shape_pool* xpool;
51 
52  void* operator new(size_t);
53  void operator delete(void* ptr, size_t);
54  vector_shapex(const vector_shapex&) = delete;
55  vector_shapex& operator=(const vector_shapex&) = delete;
56 #endif
57 
58  public:
59  vector_shapex(int lb, int ub, void *p):index_min(lb),
60  index_max(ub), ncopies(0), trueptr(p)
61  {
62  }
64  void *get_truepointer(void)
65  {
66  return trueptr;
67  }
68 
69  void shift(int min);
70  int index_min;
71  int index_max;
72 
79  unsigned int ncopies;
82  void *trueptr;
83 
84 public:
85  unsigned int decr_ncopies(void)
86  {
87  return ncopies == 0 ? 0 : --ncopies;
88  }
89  unsigned int get_ncopies(void)
90  {
91  return ncopies;
92  }
93  unsigned int incr_ncopies(void)
94  {
95  return ++ncopies;
96  }
97  int indexmin()
98  {
99  return index_min;
100  }
101  int indexmax()
102  {
103  return index_max;
104  }
105 
106  friend class subdvector;
107  friend class lvector;
108  friend class ptr_vector;
109  friend class dvector;
110  friend class ivector;
111  friend class dvar_vector;
112 };
113 #endif
unsigned int get_ncopies(void)
Definition: vector_shapex.h:89
void * trueptr
Address of first element in the vector.
Definition: vector_shapex.h:82
Vector of double precision numbers.
Definition: dvector.h:50
Description not yet available.
Definition: fvar.hpp:568
Description not yet available.
Definition: fvar.hpp:656
void * get_truepointer(void)
Returns address of first element in the vector.
Definition: vector_shapex.h:64
ADMB variable vector.
Definition: fvar.hpp:2172
unsigned int decr_ncopies(void)
Definition: vector_shapex.h:85
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
#define min(a, b)
Definition: cbivnorm.cpp:188
unsigned int ncopies
Copy counter to enable shallow copies.
Definition: vector_shapex.h:79
int index_min
Minimum valid subscript.
Definition: vector_shapex.h:70
Holds "shape" information for vector objects.
Definition: vector_shapex.h:46
vector_shapex(int lb, int ub, void *p)
Definition: vector_shapex.h:59
int index_max
Maximum valid subscript.
Definition: vector_shapex.h:71
void shift(int min)
Description not yet available.
Definition: shape.cpp:33
friend class subdvector
Description not yet available.
Definition: fvar.hpp:480
unsigned int incr_ncopies(void)
Definition: vector_shapex.h:93