ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dvect7.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 
17 dvector log(const dvector& t1)
18 {
19  int min = t1.indexmin();
20  int max = t1.indexmax();
21  dvector tmp(min, max);
22 
23  double* ptmpi = tmp.get_v() + min;
24  const double* pt1i = t1.get_v() + min;
25  for (int i = min; i <= max; ++i)
26  {
27  *ptmpi = log(*pt1i);
28 
29  ++ptmpi;
30  ++pt1i;
31  }
32  return tmp;
33 }
34 
39 dvector exp(const dvector& t1)
40 {
41  int min = t1.indexmin();
42  int max = t1.indexmax();
43  dvector tmp(min, max);
44 
45  double* ptmpi = tmp.get_v() + min;
46  const double* pt1i = t1.get_v() + min;
47  for (int i = min; i <= max; ++i)
48  {
49  *ptmpi = exp(*pt1i);
50 
51  ++ptmpi;
52  ++pt1i;
53  }
54  return tmp;
55 }
56 
61 dvector fabs(const dvector& t1)
62 {
63  int min = t1.indexmin();
64  int max = t1.indexmax();
65  dvector tmp(min, max);
66 
67  double* ptmpi = tmp.get_v() + min;
68  const double* pt1i = t1.get_v() + min;
69  for (int i = min; i <= max; ++i)
70  {
71  *ptmpi = fabs(*pt1i);
72 
73  ++ptmpi;
74  ++pt1i;
75  }
76  return tmp;
77 }
78 
85 double max(const dvector& vec)
86 {
87  int indexmin = vec.indexmin();
88  int indexmax = vec.indexmax();
89  const double* pveci = vec.get_v() + indexmin;
90  double maximum = *pveci;
91  ++pveci;
92  for (int i = indexmin + 1; i <= indexmax; ++i)
93  {
94  double value = *pveci;
95  if (value > maximum) maximum = value;
96 
97  ++pveci;
98  }
99  return maximum;
100 }
107 double min(const dvector& vec)
108 {
109  int indexmin = vec.indexmin();
110  int indexmax = vec.indexmax();
111  const double* pveci = vec.get_v() + indexmin;
112  double minimum = *pveci;
113  ++pveci;
114  for (int i = indexmin + 1; i <= indexmax; ++i)
115  {
116  double value = *pveci;
117  if (value < minimum) minimum = value;
118 
119  ++pveci;
120  }
121  return minimum;
122 }
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
df1_two_variable fabs(const df1_two_variable &x)
Definition: df12fun.cpp:891
#define min(a, b)
Definition: cbivnorm.cpp:188
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
#define max(a, b)
Definition: cbivnorm.cpp:189
double *& get_v(void)
Definition: dvector.h:148
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13