ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
fvar_opr.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  */
00012 #include "fvar.hpp"
00013 
00014 #ifdef __TURBOC__
00015   #pragma hdrstop
00016   #include <iostream.h>
00017 #endif
00018 
00019 #ifdef __ZTC__
00020   #include <iostream.hpp>
00021 #endif
00022 
00023 
00024 #include <stdio.h>
00025 #include <math.h>
00026 
00027 
00028 void gradfree(dlink *);
00029 
00034 void prevariable::operator+=(const double uu)
00035  {
00036    (*v).x+=uu;
00037  }
00038 
00043 void prevariable::operator-=(const double uu)
00044  {
00045    (*v).x-=uu;
00046  }
00047 
00052 prevariable& operator+(const prevariable& v1, const prevariable& v2)
00053 {
00054   if (++gradient_structure::RETURN_PTR > gradient_structure::MAX_RETURN)
00055     gradient_structure::RETURN_PTR = gradient_structure::MIN_RETURN;
00056 
00057  gradient_structure::RETURN_PTR->v->x =(*v1.v).x+ (*v2.v).x;
00058  gradient_structure::GRAD_STACK1->set_gradient_stack4(default_evaluation4,
00059     &(gradient_structure::RETURN_PTR->v->x),&((*v1.v).x), &((*v2.v).x));
00060   return(*gradient_structure::RETURN_PTR);
00061 }
00062 
00067 prevariable& operator*(const prevariable& v1, const prevariable& v2)
00068 {
00069   if (++gradient_structure::RETURN_PTR > gradient_structure::MAX_RETURN)
00070     gradient_structure::RETURN_PTR = gradient_structure::MIN_RETURN;
00071   gradient_structure::RETURN_PTR->v->x= (*v1.v).x * (*v2.v).x;
00072   gradient_structure::GRAD_STACK1->set_gradient_stack(default_evaluation3,
00073     &(gradient_structure::RETURN_PTR->v->x),
00074     &((*v1.v).x),(*v2.v).x,&((*v2.v).x),(*v1.v).x );
00075   return(*gradient_structure::RETURN_PTR);
00076  }
00077 
00082 int prevariable::operator==(const prevariable& v1) const
00083     {
00084       return(v->x==value(v1));
00085     }
00086 
00091 int prevariable::operator <=(const prevariable& v1) const
00092     {
00093       return(v->x<=value(v1));
00094     }
00095 
00100 int prevariable::operator<(const prevariable& v1) const
00101     {
00102       return(v->x<value(v1));
00103     }
00104 
00109 int prevariable::operator>(const prevariable& v1) const
00110     {
00111       return(v->x>value(v1));
00112     }
00113 
00118 int prevariable::operator>=(const prevariable& v1) const
00119     {
00120       return(v->x >=value(v1));
00121     }
00122 
00127 int prevariable::operator!=(const prevariable& v1) const
00128     {
00129       return(v->x!=value(v1));
00130     }