ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
dvec_dif.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00017 dvector first_difference(const dvector& x)
00018  {
00019    if (x.size()<=1)
00020    {
00021      cerr << "Error -- vector size too small"
00022              " in first_difference(const dvector&)" << endl;
00023      ad_exit(1);
00024    }
00025    int mmin=x.indexmin();
00026    int mmax=x.indexmax()-1;
00027    dvector tmp(mmin,mmax);
00028    for (int i=mmin; i<=mmax; i++)
00029    {
00030      tmp.elem(i)=x.elem(i+1)-x.elem(i);
00031    }
00032    return(tmp);
00033  }