ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_op2.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 // file: fvar_ops.cpp
12 // operators involving prevariables
13 
14 
15 #include "fvar.hpp"
16 
17 #ifdef __TURBOC__
18  #pragma hdrstop
19  #include <iostream.h>
20 #endif
21 
22 #ifdef __ZTC__
23  #include <iostream.hpp>
24 #endif
25 
26 #include <stdio.h>
27 #include <math.h>
28 
33 prevariable& operator+(const double x, const prevariable& v2)
34 {
36 
37  RETURN_PTR->v->x = x + (v2.v->x);
39  &(RETURN_PTR->v->x),&(v2.v->x));
40 
41  return *RETURN_PTR;
42 }
43 
48 prevariable& operator+(const prevariable& v1, const double x)
49 {
51 
52  RETURN_PTR->v->x=v1.v->x+ x;
54  &(RETURN_PTR->v->x), &(v1.v->x));
55 
56  return *RETURN_PTR;
57 }
58 
64 {
66 
67  RETURN_PTR->v->x=v1.v->x - v2.v->x;
69  &(RETURN_PTR->v->x),&(v1.v->x),&(v2.v->x));
70 
71  return *RETURN_PTR;
72 }
73 
78 prevariable& operator-(const prevariable& v1, const double x)
79 {
81 
82  RETURN_PTR->v->x=v1.v->x - x;
84  &(RETURN_PTR->v->x), &(v1.v->x));
85 
86  return *RETURN_PTR;
87 }
88 
93 prevariable& operator-(const double x, const prevariable& v2)
94 {
96 
97  RETURN_PTR->v->x = x - v2.v->x;
99  &(RETURN_PTR->v->x), &(v2.v->x));
100 
101  return *RETURN_PTR;
102 }
103 
109 {
111 
112  RETURN_PTR->v->x = -(v1.v->x);
114  &(RETURN_PTR->v->x),&(v1.v->x));
115 
116  return *RETURN_PTR;
117 }
118 
124 {
126 
127  double x = 1 / v2.v->x;
128  double y = v1.v->x * x;
129  RETURN_PTR->v->x = y;
131  &(RETURN_PTR->v->x),&(v1.v->x),x,&(v2.v->x),-y*x);
132 
133  return *RETURN_PTR;
134 }
135 
140 prevariable& operator/(const double u, const prevariable& v2)
141 {
143 
144  double x = 1 / v2.v->x;
145  double y = u * x;
146  RETURN_PTR->v->x = y;
147 
149  &(RETURN_PTR->v->x), &(v2.v->x),-y*x);
150 
151  return *RETURN_PTR;
152 }
153 
158 prevariable& operator/(const prevariable& v1, const double u)
159 {
161 
162  double x = 1 / u;
163  double y = v1.v->x * x;
164 
165  RETURN_PTR->v->x = y;
166 
168  &(RETURN_PTR->v->x), &(v1.v->x),x);
169 
170  return *RETURN_PTR;
171 }
Base class for dvariable.
Definition: fvar.hpp:1315
void default_evaluation3(void)
Description not yet available.
Definition: def_eval.cpp:157
d3_array operator-(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:152
#define x
d3_array operator+(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:132
void default_evaluation1m(void)
Description not yet available.
Definition: def_eval.cpp:110
void set_gradient_stack(void(*func)(void), double *dep_addr, double *ind_addr1=NULL, double mult1=0, double *ind_addr2=NULL, double mult2=0)
Description not yet available.
Definition: fvar.hpp:1045
void default_evaluation1(void)
Description not yet available.
Definition: def_eval.cpp:93
static dvariable * next_RETURN_PTR()
Definition: gradstrc.cpp:457
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void default_evaluation(void)
Description not yet available.
Definition: def_eval.cpp:61
double_and_int * v
pointer to the data
Definition: fvar.hpp:1333
d3_array operator/(const d3_array &m, const double d)
Author: David Fournier.
Definition: d3arr2b.cpp:14
void default_evaluation4m(void)
Description not yet available.
Definition: def_eval.cpp:265
static _THREAD grad_stack * GRAD_STACK1
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
double x
&lt; value of the variable
Definition: fvar.hpp:195