ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
d3arr4.cpp
Go to the documentation of this file.
1 
9 #include "fvar.hpp"
10 
16 double square(const double value)
17 {
18  return value * value;
19 }
29 {
30  dvector results;
31  results.allocate(values);
32  int min = values.indexmin();
33  int max = values.indexmax();
34 
35  double* pvaluesi = values.get_v() + min;
36  double* presultsi = results.get_v() + min;
37  for (int i = min; i <= max; ++i)
38  {
39  *presultsi = square(*pvaluesi);
40 
41  ++pvaluesi;
42  ++presultsi;
43  }
44  return results;
45 }
55 {
56  ivector results;
57  results.allocate(values);
58  for (int i = values.indexmin(); i <= values.indexmax(); ++i)
59  {
60  results(i) = values(i) * values(i);
61  }
62  return results;
63 }
70 {
71  dmatrix results;
72  results.allocate(a);
73  for (int i = results.rowmin(); i <= results.rowmax(); ++i)
74  {
75  results(i) = square(a(i));
76  }
77  return results;
78 }
85 {
86  d3_array results;
87  results.allocate(a);
88  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
89  {
90  results(i) = square(a(i));
91  }
92  return results;
93 }
void allocate(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat0.cpp:8
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
void allocate(const ad_integer &sl, const ad_integer &sh, const index_type &nrl, const index_type &nrh, const index_type &ncl, const index_type &nch)
Allocate array of matrices with dimensions [sl to sh] x [nrl to nrh] x [ncl to nch].
Definition: indextyp.cpp:327
void allocate(int ncl, int ncu)
Allocate memory for a dvector.
Definition: dvector.cpp:409
int slicemax() const
Definition: fvar.hpp:3830
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
int rowmax() const
Definition: fvar.hpp:2929
#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.
int indexmin() const
Definition: ivector.h:99
int slicemin() const
Definition: fvar.hpp:3826
int indexmax() const
Definition: ivector.h:104
Description not yet available.
Definition: fvar.hpp:2819
values
Definition: adjson.h:22
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
#define max(a, b)
Definition: cbivnorm.cpp:189
Description not yet available.
Definition: fvar.hpp:3727
double *& get_v(void)
Definition: dvector.h:148
void allocate(const ad_integer &ncl, const index_type &ncu)
Allocate vector of integers with dimension [_ncl to _nch].
Definition: indextyp.cpp:488
int rowmin() const
Definition: fvar.hpp:2925
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16