ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_op7.cpp
Go to the documentation of this file.
1 
5 #include "fvar.hpp"
6 
12 dvariable& square(const prevariable& variable)
13 {
15 
16  double& x = value(variable);
17  RETURN_PTR->v->x = x * x;
18 
20  &(RETURN_PTR->v->x), &(variable.v->x), 2 * x );
21 
22  return *RETURN_PTR;
23 }
30 {
31  dvar_matrix results;
32  results.allocate(matrix);
33 
34  int min = matrix.rowmin();
35  int max = matrix.rowmax();
36  const dvar_vector* pmatrixi = &matrix(min);
37  dvar_vector* presultsi = &results(min);
38  for (int i = min; i <= max; ++i)
39  {
40  *presultsi = square(*pmatrixi);
41 
42  ++pmatrixi;
43  ++presultsi;
44  }
45  return results;
46 }
void default_evaluation2(void)
Description not yet available.
Definition: def_eval.cpp:136
Base class for dvariable.
Definition: fvar.hpp:1315
int rowmax(void) const
Definition: fvar.hpp:2564
#define x
ADMB variable vector.
Definition: fvar.hpp:2172
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
static dvariable * next_RETURN_PTR()
Definition: gradstrc.cpp:457
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int rowmin(void) const
Definition: fvar.hpp:2560
double_and_int * v
pointer to the data
Definition: fvar.hpp:1333
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
void allocate(int nrl, int nrh, int ncl, int nch)
Allocates AD variable matrix with dimensions nrl to nrh by ncl to nch.
Definition: fvar_mat.cpp:216
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
static _THREAD grad_stack * GRAD_STACK1
#define max(a, b)
Definition: cbivnorm.cpp:189
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
double x
&lt; value of the variable
Definition: fvar.hpp:195