ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dvec_dif.cpp
Go to the documentation of this file.
1 
9 #include "fvar.hpp"
10 
18 {
19  if (values.size() <= 1)
20  {
21  cerr << "Error -- vector size should be greater than 1"
22  << " in first_difference(const dvector&)" << endl;
23  ad_exit(1);
24  }
25  int indexmin = values.indexmin();
26  int indexmax = values.indexmax() - 1;
27  dvector differences(indexmin, indexmax);
28  for (int i = indexmin; i <= indexmax; ++i)
29  {
30  differences.elem(i) = values.elem(i + 1) - values.elem(i);
31  }
32  return differences;
33  }
double & elem(int i)
Definition: dvector.h:152
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
exitptr ad_exit
Definition: gradstrc.cpp:53
prnstream & endl(prnstream &)
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
dvector first_difference(const dvector &values)
Returns dvector containing the differences of an values(i) and values(i + 1) for i = 1 to values...
Definition: dvec_dif.cpp:17
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
values
Definition: adjson.h:22
unsigned int size() const
Get number of elements in array.
Definition: dvector.h:209