ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat26.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.cpp
12 // constructors, destructors and misc functions involving class dvariable
13 
14 #include "fvar.hpp"
15 
16 #ifdef __TURBOC__
17  #pragma hdrstop
18  #include <iostream.h>
19 #endif
20 
21 #ifdef __ZTC__
22  #include <iostream.hpp>
23 #endif
24 
25 
26 #include <stdio.h>
27 #ifndef __SUN__
28 #endif
29 #include <math.h>
30 
36 {
37  int min = m.rowmin();
38  int max = m.rowmax();
39 
40  ivector cmin(min, max);
41  ivector cmax(min, max);
42 
43  int* pcmini = cmin.get_v() + min;
44  int* pcmaxi = cmax.get_v() + min;
45 
46  const dvector* pmi = &m(min);
47  for (int i = min; i <= max; ++i)
48  {
49  *pcmini = pmi->indexmin();
50  *pcmaxi = pmi->indexmax();
51 
52  ++pcmini;
53  ++pcmaxi;
54  ++pmi;
55  }
56 
57  dmatrix tmp(min, max, cmin, cmax);
58  dvector* ptmpi = &tmp(min);
59  pmi = &m(min);
60  for (int i = min; i <= max; ++i)
61  {
62  *ptmpi = mfexp(*pmi);
63 
64  ++ptmpi;
65  ++pmi;
66  }
67  return tmp;
68 }
69 
74 dmatrix mfexp(const dmatrix& m, const double d)
75 {
76  int min = m.rowmin();
77  int max = m.rowmax();
78 
79  ivector cmin(min, max);
80  ivector cmax(min, max);
81 
82  int* pcmini = cmin.get_v() + min;
83  int* pcmaxi = cmax.get_v() + min;
84 
85  const dvector* pmi = &m(min);
86  for (int i = min; i <= max; ++i)
87  {
88  *pcmini = pmi->indexmin();
89  *pcmaxi = pmi->indexmax();
90 
91  ++pcmini;
92  ++pcmaxi;
93  ++pmi;
94  }
95 
96  dmatrix tmp(min, max, cmin, cmax);
97  dvector* ptmpi = &tmp(min);
98  pmi = &m(min);
99  for (int i = min; i <= max; ++i)
100  {
101  *ptmpi = mfexp(*pmi, d);
102 
103  ++ptmpi;
104  ++pmi;
105  }
106  return tmp;
107 }
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
d3_array mfexp(const d3_array &m)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr7.cpp:10
int * get_v() const
Definition: ivector.h:114
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.
Description not yet available.
Definition: fvar.hpp:2819
#define max(a, b)
Definition: cbivnorm.cpp:189
int rowmin() const
Definition: fvar.hpp:2925