ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fvar_m34.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 
13 void dmcv_prod(void);
14 
20 {
23 
25 
26  int imin = m.rowmin();
27  int imax = m.rowmax();
28  int jmin = x.indexmin();
29  int jmax = x.indexmax();
30 
31 #ifndef OPT_LIB
32  if (x.indexmin() != m.colmin() || x.indexmax() != m.colmax())
33  {
34  cerr << " Incompatible array bounds in "
35  "dvar_vector operator * (const dvar_matrix& m, const dvar_vector& x)\n";
36  ad_exit(21);
37  }
38 #endif
39 
40  kkludge_object kludge;
41  dvar_vector tmp(imin, imax, kludge);
42 
43  double_and_int* ptmpi = tmp.va + imin;
44  const dvar_vector* pmi = &m(imin);
45  for (int i = imin; i <= imax; ++i)
46  {
47  double sum = 0.0;
48  const double_and_int* pmij = pmi->va + jmin;
49  double* pxj = x.get_v() + jmin;
50  for (int j = jmin; j <= jmax; ++j)
51  {
52  //sum+=m[i][j]*x[j];
53  sum += pmij->x * *pxj;
54  ++pxj;
55  ++pmij;
56  }
57  ptmpi->x = sum;
58 
59  ++pmi;
60  ++ptmpi;
61  }
63  fp->save_dvector_value(x);
64  fp->save_dvector_position(x);
70 
71  return tmp;
72  }
73 
78 void dmcv_prod(void)
79 {
81 
89 
90  dmatrix dfm(m_pos);
91  dfm.initialize();
92 
93  int mmin = dfm.rowmin();
94  int mmax = dfm.rowmax();
95  int jmin = x.indexmin();
96  int jmax = x.indexmax();
97  double* pdftmpi = dftmp.get_v() + mmax;
98  dvector* pdfmi = &dfm(mmax);
99  for (int i=mmax; i>=mmin; i--)
100  {
101  // tmp.elem_value(i)=sum;
102  double dfsum = *pdftmpi;
103  double* pdfmij = pdfmi->get_v() + jmax;
104  double* pxj = x.get_v() + jmax;
105  for (int j = jmax; j >= jmin; --j)
106  {
107  //sum+=(m.elem(i)).elem_value(j)*x.elem_value(j);
108  *pdfmij += dfsum * *pxj;
109 
110  --pdfmij;
111  --pxj;
112  }
113  //sum=0.0;
114  dfsum = 0.0;
115 
116  --pdfmi;
117  --pdftmpi;
118  }
119  dfm.save_dmatrix_derivatives(m_pos);
120 }
int rowmax(void) const
Definition: fvar.hpp:2564
int colmin(void) const
Definition: fvar.hpp:2552
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
Description not yet available.
Definition: fvar.hpp:4814
exitptr ad_exit
Definition: gradstrc.cpp:53
Null class to allow specialized function overloads.
Definition: fvar.hpp:469
ADMB variable vector.
Definition: fvar.hpp:2172
void verify_identifier_string(const char *)
Verifies gradient stack string.
Definition: cmpdif3.cpp:149
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
Holds the data for the prevariable class.
Definition: fvar.hpp:191
void set_gradient_stack(void(*func)(void), double *dep_addr, double *ind_addr1=NULL, double mult1=0, double *ind_addr2=NULL, double mult2=0)
Description not yet available.
Definition: fvar.hpp:1045
void save_dvector_position(const dvector &v)
Definition: cmpdif4.cpp:32
int rowmax() const
Definition: fvar.hpp:2929
void save_dvector_value(const dvector &v)
Definition: cmpdif4.cpp:130
dvar_vector_position restore_dvar_vector_position()
Definition: cmpdif4.cpp:69
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.
void save_dmatrix_derivatives(const dvar_matrix_position &pos) const
Description not yet available.
Definition: cmpdif5.cpp:285
static _THREAD gradient_structure * _instance
int rowmin(void) const
Definition: fvar.hpp:2560
Description not yet available.
Definition: fvar.hpp:2819
int save_identifier_string(const char *)
Writes a gradient stack verification string.
Definition: cmpdif2.cpp:315
dvector restore_dvar_vector_value(const dvar_vector_position &tmp)
Restores the size, address, and value information for a dvar_vector.
Definition: cmpdif4.cpp:227
void save_dvar_vector_position(const dvar_vector &v)
Definition: cmpdif3.cpp:214
dvar_matrix_position restore_dvar_matrix_position()
Definition: cmpdif6.cpp:114
static _THREAD DF_FILE * fp
void save_dvar_matrix_position(const dvar_matrix &m)
Definition: cmpdif5.cpp:345
void dmcv_prod(void)
Description not yet available.
Definition: fvar_m34.cpp:78
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
Stores the adjoint gradient data that will be processed by gradcalc.
dvector restore_dvar_vector_derivatives(const dvar_vector_position &tmp)
Description not yet available.
Definition: cmpdif5.cpp:150
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
double_and_int * va
Definition: fvar.hpp:2175
static _THREAD grad_stack * GRAD_STACK1
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
void initialize(void)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat7.cpp:12
double *& get_v(void)
Definition: dvector.h:148
int rowmin() const
Definition: fvar.hpp:2925
double x
&lt; value of the variable
Definition: fvar.hpp:195
int colmax(void) const
Definition: fvar.hpp:2556
Description not yet available.
Definition: fvar.hpp:4843