ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_ar3.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 #include "fvar.hpp"
12 
18  {
21 
22  int min = t1.indexmin();
23  int max = t1.indexmax();
24 
25  dvar_vector tmp(min, max);
26  double_and_int* ptmp = tmp.va + min;
27  double_and_int* pt1 = t1.va + min;
28  for (int i = min; i <= max; ++i)
29  {
30  ptmp->x = fabs(pt1->x);
31  ++ptmp;
32  ++pt1;
33  }
34 
36  return(tmp);
37  }
38 
44  {
47 
48  int min = t1.indexmin();
49  int max = t1.indexmax();
50 
51  dvector tmp(min, max);
52  double* ptmp = tmp.get_v() + min;
53  double_and_int* pt1 = t1.va + min;
54  for (int i = min; i <= max; ++i)
55  {
56  *ptmp = pt1->x;
57  ++ptmp;
58  ++pt1;
59  }
60 
62  return(tmp);
63  }
64 
70  {
73  dvariable tmp;
74  tmp=t1*t1;
75  if (value(tmp)>0.0)
76  {
77  tmp=pow(tmp,.5);
78  }
80  return(tmp);
81  }
82 
88  {
91  dvariable tmp;
92  tmp=t1*t1;
94  return(tmp);
95  }
96 dvariable sumsq(const dvar_vector& t1) {return(norm2(t1));}
97 
103  {
106 
107  dvar_vector tmp(t1.indexmin(),t1.indexmax());
108 
109  for (int i=t1.indexmin(); i<=t1.indexmax(); i++)
110  {
111  tmp.elem(i)=sfabs(t1.elem(i));
112  }
114  return(tmp);
115  }
double sumsq(const d3_array &a)
Definition: d3arr2a.cpp:181
Vector of double precision numbers.
Definition: dvector.h:50
df1_two_variable fabs(const df1_two_variable &x)
Definition: df12fun.cpp:891
prevariable elem(int i)
Definition: fvar.hpp:2221
ADMB variable vector.
Definition: fvar.hpp:2172
double norm(const d3_array &a)
Return computed norm value of a.
Definition: d3arr2a.cpp:190
Holds the data for the prevariable class.
Definition: fvar.hpp:191
double sfabs(const double v1)
Description not yet available.
Definition: dvect14.cpp:20
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
double norm2(const d3_array &a)
Return sum of squared elements in a.
Definition: d3arr2a.cpp:167
int indexmin() const
Definition: fvar.hpp:2287
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
double_and_int * va
Definition: fvar.hpp:2175
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
#define max(a, b)
Definition: cbivnorm.cpp:189
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
double *& get_v(void)
Definition: dvector.h:148
int indexmax() const
Definition: fvar.hpp:2292
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
double x
&lt; value of the variable
Definition: fvar.hpp:195
d3_array pow(const d3_array &m, int e)
Description not yet available.
Definition: d3arr6.cpp:17