ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dvect26.cpp
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  */
11 #include "fvar.hpp"
12 
18 void dvector::reallocate(double s)
19 {
20  if (::allocated(*this))
21  {
22  int oldmin=indexmin();
23  int oldmax=indexmax();
24  dvector tmp(indexmin(),indexmax());
25  tmp=(*this);
26  deallocate();
27  allocate(indexmin(),int(s*indexmax()));
28 #ifndef OPT_LIB
29  initialize();
30 #endif
31  int max = oldmax < indexmax() ? oldmax : indexmax();
32  (*this)(oldmin, max) = tmp(oldmin, max);
33  }
34 }
int allocated(void) const
Returns 1 (TRUE) if memory is allocated.
Definition: dvector.h:71
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void allocate(void)
Allocate dvector without allocating memory.
Definition: dvector.cpp:495
friend double max(const dvector &)
Returns the maximum value of vector vec.
Definition: dvect7.cpp:85
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void initialize(void)
Initialze all elements of dvector to zero.
Definition: dvect5.cpp:10
void reallocate(double size)
Reallocate size of array.
Definition: dvect26.cpp:18
void deallocate(void)
Called by destructor to deallocate memory for a dvector object.
Definition: dvector.cpp:92