ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
model23.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  */
7 #include <admodel.h>
8 #ifndef OPT_LIB
9  #include <cassert>
10  #include <climits>
11 #endif
12 
13 int adkdelta(int i,int j)
14 {
15  return i == j ? 1 : 0;
16 }
17 
18 void param_init_number::dev_correction(const dmatrix& H, const int& _ii)
19 {
20  int& ii=(int&) _ii;
21  ii++;
22 }
23 
24 void param_init_matrix::dev_correction(const dmatrix& H, const int& _ii)
25 {
26  int& ii=(int&) _ii;
27  ii+=size_count();
28 }
29 
30 void param_init_d3array::dev_correction(const dmatrix& H, const int& _ii)
31 {
32  int& ii=(int&) _ii;
33  ii+=size_count();
34 }
35 
36 void param_init_vector::dev_correction(const dmatrix& H, const int& _ii)
37 {
38  int& ii=(int&) _ii;
39  ii+=size_count();
40 }
41 
42 void param_init_bounded_vector::dev_correction(const dmatrix& H, const int& _ii)
43 {
44  int& ii=(int&) _ii;
45  ii+=size_count();
46 }
47 
49  const int& _ii)
50 {
51  dmatrix& H=(dmatrix&) _H;
52  int& ii=(int&) _ii;
53  int lmin=ii;
54 #if !defined(OPT_LIB) && (__cplusplus >= 201103L)
55  int n = [](unsigned int size) -> int
56  {
57  assert(size <= INT_MAX);
58  return static_cast<int>(size);
59  } (size());
60 #else
61  int n = static_cast<int>(size());
62 #endif
63 
64  int lmax=lmin+n-1;
65  dmatrix Htmp(lmin,lmax,lmin,lmax);
66  double ninv=1.0/double(n);
67  int i,j,k,l;
68  for (i=lmin;i<=lmax;i++)
69  {
70  for (j=lmin;j<=lmax;j++)
71  {
72  double tmp=0.0;
73  for (k=lmin;k<=lmax;k++)
74  {
75  for (l=lmin;l<=lmax;l++)
76  {
77  tmp+=(adkdelta(i,k)-ninv)*(adkdelta(j,l)-ninv)*H(k,l);
78  }
79  }
80  Htmp(i,j)=tmp;
81  }
82  }
83  for (i=lmin;i<=lmax;i++)
84  {
85  for (j=lmin;j<=lmax;j++)
86  {
87  H(i,j)=Htmp(i,j);
88  }
89  }
90  ii+=n;
91 }
virtual unsigned int size_count() const
Returns the number of active parameters.
Definition: model.cpp:904
virtual void dev_correction(const dmatrix &, const int &)
Definition: model23.cpp:30
int adkdelta(int i, int j)
Definition: model23.cpp:13
virtual unsigned int size_count() const
Returns the number of active parameters.
Definition: model.cpp:1025
unsigned int size() const
Definition: fvar.hpp:2297
virtual unsigned int size_count() const
Return number of active parameters.
Definition: model21.cpp:41
virtual void dev_correction(const dmatrix &, const int &)
Definition: model23.cpp:24
virtual void dev_correction(const dmatrix &H, const int &ii)
Definition: model23.cpp:48
virtual unsigned int size_count() const
Returns the number of active parameters.
Definition: model.cpp:724
Description not yet available.
Description not yet available.
Definition: fvar.hpp:2819
virtual void dev_correction(const dmatrix &, const int &)
Definition: model23.cpp:18
virtual void dev_correction(const dmatrix &H, const int &ii)
Definition: model23.cpp:36
virtual void dev_correction(const dmatrix &, const int &)
Definition: model23.cpp:42