ADMB Documentation  11.1x.2716
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_op8.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: fvar_op8.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include "fvar.hpp"
00012 
00019 prevariable& cube(const prevariable& v1)
00020 {
00021   double x=value(v1);
00022   double x2=x*x;
00023   if (++gradient_structure::RETURN_PTR > gradient_structure::MAX_RETURN)
00024     gradient_structure::RETURN_PTR = gradient_structure::MIN_RETURN;
00025   gradient_structure::RETURN_PTR->v->x=x2*x;
00026    gradient_structure::GRAD_STACK1->set_gradient_stack(default_evaluation2,
00027      &(gradient_structure::RETURN_PTR->v->x), &(v1.v->x),3*x2 );
00028    return(*gradient_structure::RETURN_PTR);
00029  }
00030 
00037 prevariable& fourth(const prevariable& v1)
00038 {
00039   double x=value(v1);
00040   double x2=x*x;
00041   if (++gradient_structure::RETURN_PTR > gradient_structure::MAX_RETURN)
00042     gradient_structure::RETURN_PTR = gradient_structure::MIN_RETURN;
00043   gradient_structure::RETURN_PTR->v->x=x2*x2;
00044    gradient_structure::GRAD_STACK1->set_gradient_stack(default_evaluation2,
00045      &(gradient_structure::RETURN_PTR->v->x), &(v1.v->x),4*x2*x );
00046    return(*gradient_structure::RETURN_PTR);
00047  }