ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_ar8.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_fn.cpp
12 // math.h functions involving prevariables
13 #include "fvar.hpp"
14 
15 #ifdef __TURBOC__
16  #pragma hdrstop
17  #include <iostream.h>
18  #include <iomanip.h>
19 #endif
20 
21 #ifdef __ZTC__
22  #include <iostream.hpp>
23  #include <iomanip.hpp>
24 #endif
25 
26 #include <stdio.h>
27 #include <math.h>
28 
29 void shape_check(const dvar_vector& v1, const dvar_vector& v2,
30  const char *function_name);
31 void shape_check(const dvector& v1, const dvar_vector& v2,
32  const char *function_name);
33 void shape_check(const dvector& v1, const dvector& v2,
34  const char *function_name);
35 void shape_check(const dvar_vector& v1, const dvector& v2,
36  const char *function_name);
37 
42  dvar_vector sinh(const dvar_vector& v1)// ***
43  {
46 
47  dvar_vector tmp(v1.indexmin(),v1.indexmax());
48  for (int i=v1.indexmin();i<=v1.indexmax();i++)
49  {
50  tmp.elem(i)=sinh(v1.elem(i)); // ***
51  }
53  return(tmp);
54  }
55 
60  dvar_vector cosh(const dvar_vector& v1)// ***
61  {
64  dvar_vector tmp(v1.indexmin(),v1.indexmax());
65  for (int i=v1.indexmin();i<=v1.indexmax();i++)
66  {
67  tmp.elem(i)=cosh(v1.elem(i)); // ***
68  }
70  return(tmp);
71  }
72 
77  dvar_vector tanh(const dvar_vector& v1)// ***
78  {
81  dvar_vector tmp(v1.indexmin(),v1.indexmax());
82  for (int i=v1.indexmin();i<=v1.indexmax();i++)
83  {
84  tmp.elem(i)=tanh(v1.elem(i)); // ***
85  }
87  return(tmp);
88  }
89 
94  dvar_vector pow(const dvar_vector& v1, const dvar_vector& v2)// ***
95  {
96  shape_check(v1,v2,
97  "dvar_vector pow(const dvar_vector& v1,const dvar_vector& v2)");
98 
101  dvar_vector tmp(v1.indexmin(),v1.indexmax());
102  for (int i=v1.indexmin();i<=v1.indexmax();i++)
103  {
104  tmp.elem(i)=pow(v1.elem(i),v2.elem(i)); // ***
105  }
107  return(tmp);
108  }
109 
114  dvar_vector pow(const prevariable& x, const dvar_vector& v2)// ***
115  {
118  dvar_vector tmp(v2.indexmin(),v2.indexmax());
119  for (int i=v2.indexmin();i<=v2.indexmax();i++)
120  {
121  tmp.elem(i)=pow(x,v2.elem(i)); // ***
122  }
124  return(tmp);
125  }
126 
131  dvar_vector asin(const dvar_vector& v1)// ***
132  {
135  dvar_vector tmp(v1.indexmin(),v1.indexmax());
136  for (int i=v1.indexmin();i<=v1.indexmax();i++)
137  {
138  tmp.elem(i)=asin(v1.elem(i)); // ***
139  }
141  return(tmp);
142  }
143 
148  dvar_vector acos(const dvar_vector& v1)// ***
149  {
152  dvar_vector tmp(v1.indexmin(),v1.indexmax());
153  for (int i=v1.indexmin();i<=v1.indexmax();i++)
154  {
155  tmp.elem(i)=acos(v1.elem(i)); // ***
156  }
158  return(tmp);
159  }
160 
165  dvar_vector log10(const dvar_vector& v1)// ***
166  {
169  dvar_vector tmp(v1.indexmin(),v1.indexmax());
170  for (int i=v1.indexmin();i<=v1.indexmax();i++)
171  {
172  tmp.elem(i)=log10(v1.elem(i)); // ***
173  }
175  return(tmp);
176  }
177 
182  void shape_check(const dvar_vector& v1, const dvar_vector& v2,
183  const char *function_name)
184  {
185  if (v1.indexmin() != v2.indexmin() || v1.indexmax() != v2.indexmax())
186  {
187  cerr << " Vector sizes do no match in" << function_name << "\n";
188  ad_exit(1);
189  }
190  }
191 
196  void shape_check(const dvector& v1, const dvar_vector& v2,
197  const char *function_name)
198  {
199  if (v1.indexmin() != v2.indexmin() || v1.indexmax() != v2.indexmax())
200  {
201  cerr << " Vector sizes do no match in" << function_name << "\n";
202  ad_exit(1);
203  }
204  }
205 
210  void shape_check(const dvar_vector& v1, const dvector& v2,
211  const char *function_name)
212  {
213  if (v1.indexmin() != v2.indexmin() || v1.indexmax() != v2.indexmax())
214  {
215  cerr << " Vector sizes do no match in" << function_name << "\n";
216  ad_exit(1);
217  }
218  }
Base class for dvariable.
Definition: fvar.hpp:1315
dvector log10(const dvector &vec)
Returns dvector with the common (base-10) logarithm of vec.
Definition: dvect6.cpp:273
dvector tanh(const dvector &vec)
Returns dvector with hyperbolic tangent for each value of vec.
Definition: dvect6.cpp:126
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
dvector cosh(const dvector &vec)
Returns dvector with hyperbolic cosine for each value of vec.
Definition: dvect6.cpp:105
exitptr ad_exit
Definition: gradstrc.cpp:53
prevariable elem(int i)
Definition: fvar.hpp:2221
ADMB variable vector.
Definition: fvar.hpp:2172
void shape_check(const dvector &a, const dvector &b, const char *message)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dvect18.cpp:26
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
int indexmin() const
Definition: fvar.hpp:2287
dvector sinh(const dvector &vec)
Returns dvector with hyperbolic sine for each value of vec.
Definition: dvect6.cpp:84
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
int indexmax() const
Definition: fvar.hpp:2292
dvector acos(const dvector &vec)
Returns dvector with principal value of the arc cosine of vec, expressed in radians.
Definition: dvect6.cpp:244
d3_array pow(const d3_array &m, int e)
Description not yet available.
Definition: d3arr6.cpp:17
dvector asin(const dvector &vec)
Returns dvector with principal value of the arc sine of vec, expressed in radians.
Definition: dvect6.cpp:229