MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Ident Class Reference

#include <id.h>

Collaboration diagram for Ident:

Public Member Functions

 Ident (integer size, integer nout, ForgettingFactor *pf, const doublereal &ldl_init=LDL_INIT)
 
virtual ~Ident (void)
 
doublereal dGetForgettingFactor (void) const
 
doublerealpdGetTheta (void)
 
void UpdateTheta (const doublereal *pd)
 
doublerealpdGetErr (void)
 
void Update (const doublereal *pphi, const doublereal *yy)
 

Protected Member Functions

void SetForgettingFactor (const doublereal &kk)
 

Protected Attributes

integer size
 
integer nout
 
doublerealpdBase
 
doublereal ** ppdBase
 
doublerealldl
 
doublereal ** vldl
 
doublerealz
 
doublereal ** vz
 
doublerealtheta
 
doublereal ** vtheta
 
doublerealphi
 
doublerealy
 
doublerealerr
 
ForgettingFactorpF
 
doublereal k
 
doublereal w
 

Detailed Description

Definition at line 44 of file id.h.

Constructor & Destructor Documentation

Ident::Ident ( integer  size,
integer  nout,
ForgettingFactor pf,
const doublereal ldl_init = LDL_INIT 
)

Definition at line 40 of file id.cc.

References ASSERT, err, ldl, nout, pdBase, phi, ppdBase, SAFENEWARR, size, theta, vldl, vtheta, vz, y, and z.

42 : size(size), nout(nout), pdBase(NULL), ppdBase(NULL),
43 ldl(NULL), vldl(NULL), z(0), vz(0), theta(NULL), vtheta(NULL),
44 phi(NULL), y(NULL), err(NULL), pF(pf), k(0.), w(0.)
45 {
46  ASSERT(size > 0);
47  ASSERT(nout > 0);
48 
49  integer i = size*size // ldl
50  +size*nout // z
51  +size*nout // theta
52  +size // phi
53  +nout // y
54  +nout; // err
55 
56  integer iv = size // vldl
57  +nout // vz
58  +nout; // vtheta
59 
62 
63  ldl = pdBase;
64  z = ldl+size*size;
65  theta = z+size*nout;
66  phi = theta+size*nout;
67  y = phi+size;
68  err = y+nout;
69 
70  for (integer j = i; j-- > 0; ) {
71  pdBase[j] = 0.;
72  }
73 
74  vldl = ppdBase;
75  vz = vldl+size;
76  vtheta = vz+nout;
77 
78  for (integer j = size; j-- > 0; ) {
79  vldl[j] = ldl+j*size;
80  vldl[j][j] = ldl_init;
81  }
82  for (integer j = nout; j-- > 0; ) {
83  vz[j] = z+j*size;
84  vtheta[j] = theta+j*size;
85  }
86 }
doublereal * pdBase
Definition: id.h:49
doublereal ** vz
Definition: id.h:56
integer size
Definition: id.h:46
integer nout
Definition: id.h:47
doublereal * z
Definition: id.h:55
ForgettingFactor * pF
Definition: id.h:65
doublereal * phi
Definition: id.h:61
doublereal * theta
Definition: id.h:58
doublereal w
Definition: id.h:67
#define ASSERT(expression)
Definition: colamd.c:977
doublereal * err
Definition: id.h:63
doublereal ** ppdBase
Definition: id.h:50
doublereal * ldl
Definition: id.h:52
doublereal ** vtheta
Definition: id.h:59
doublereal * y
Definition: id.h:62
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
doublereal ** vldl
Definition: id.h:53
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal k
Definition: id.h:66
Ident::~Ident ( void  )
virtual

Definition at line 89 of file id.cc.

References pdBase, pF, ppdBase, SAFEDELETE, and SAFEDELETEARR.

89  {
92  SAFEDELETE(pF);
93 }
doublereal * pdBase
Definition: id.h:49
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
ForgettingFactor * pF
Definition: id.h:65
doublereal ** ppdBase
Definition: id.h:50
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710

Member Function Documentation

doublereal Ident::dGetForgettingFactor ( void  ) const

Definition at line 95 of file id.cc.

References k.

Referenced by IdentProcess::dGetForgettingFactor().

95  {
96  return 1./(k*k);
97 }
doublereal k
Definition: id.h:66
doublereal * Ident::pdGetErr ( void  )

Definition at line 133 of file id.cc.

References err.

Referenced by IdentARMAXProcess::Update().

133  {
134  return err;
135 }
doublereal * err
Definition: id.h:63
doublereal * Ident::pdGetTheta ( void  )

Definition at line 115 of file id.cc.

References ldl, ldlsol(), nout, size, theta, and z.

Referenced by IdentARXProcess::GetTheta(), and IdentARMAXProcess::GetTheta().

115  {
116  // copia il termine noto z in theta (richiesto da ldlsol_())
117  for (integer i = size*nout; i-- > 0; ) {
118  theta[i] = z[i];
119  }
120 
121  __FC_DECL__(ldlsol) (ldl, &size, theta, &size, &size, &nout);
122  return theta;
123 }
integer size
Definition: id.h:46
integer nout
Definition: id.h:47
doublereal * z
Definition: id.h:55
int ldlsol(doublereal *ldl, integer *nrdldl, doublereal *b, integer *nrdb, integer *n, integer *nvet)
doublereal * theta
Definition: id.h:58
doublereal * ldl
Definition: id.h:52
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

void Ident::SetForgettingFactor ( const doublereal kk)
protected

Definition at line 99 of file id.cc.

References k, nout, size, vldl, vz, and w.

Referenced by Update().

99  {
100  k = kk;
101  w *= kk;
102  if (w > 1.e3) {
103  for (integer i = size; i-- > 0; ) {
104  for (integer j = nout; j-- > 0; ) {
105  vz[j][i] /= w;
106  }
107  vldl[i][i] *= w;
108  }
109  w = 1.;
110  } else if (w < 1.e-20) {
111  w = 1.e-20;
112  }
113 }
doublereal ** vz
Definition: id.h:56
integer size
Definition: id.h:46
integer nout
Definition: id.h:47
doublereal w
Definition: id.h:67
doublereal ** vldl
Definition: id.h:53
long int integer
Definition: colamd.c:51
doublereal k
Definition: id.h:66
void Ident::Update ( const doublereal pphi,
const doublereal yy 
)

Definition at line 137 of file id.cc.

References ForgettingFactor::dGet(), err, k, ldl, nout, pF, phi, SetForgettingFactor(), size, grad::sqrt(), uldlad(), ForgettingFactor::Update(), vtheta, y, and z.

Referenced by IdentARXProcess::Update(), and IdentARMAXProcess::Update().

137  {
138  // calcolo l'errore
139  for (integer j = nout; j-- > 0; ) {
140  err[j] = yy[j];
141  for (integer i = size; i-- > 0; ) {
142  err[j] -= vtheta[j][i]*pphi[i];
143  }
144  }
145 
146  /* calcolo il nuovo forgetting factor */
147  pF->Update(err);
148  doublereal d = pF->dGet();
149  SetForgettingFactor(k = 1./sqrt(d));
150 
151  for (integer i = size; i-- > 0; ) {
152  phi[i] = pphi[i]*k;
153  }
154  for (integer j = nout; j-- > 0; ) {
155  y[j] = yy[j]*k;
156  }
157 
158  /* aggiorno la matrice fattorizzata */
159  __FC_DECL__(uldlad) (ldl, &size, &size, phi, z, &size, &nout, y);
160 }
virtual void Update(const doublereal *pErr=NULL)=0
integer size
Definition: id.h:46
void SetForgettingFactor(const doublereal &kk)
Definition: id.cc:99
integer nout
Definition: id.h:47
doublereal * z
Definition: id.h:55
ForgettingFactor * pF
Definition: id.h:65
doublereal * phi
Definition: id.h:61
virtual doublereal dGet(void) const =0
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
doublereal * err
Definition: id.h:63
doublereal * ldl
Definition: id.h:52
doublereal ** vtheta
Definition: id.h:59
doublereal * y
Definition: id.h:62
int uldlad(doublereal *ldl, integer *nrdldl, integer *n, doublereal *x, doublereal *z, integer *nrdz, integer *nz, doublereal *y)
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal k
Definition: id.h:66

Here is the call graph for this function:

void Ident::UpdateTheta ( const doublereal pd)

Definition at line 126 of file id.cc.

References nout, size, and theta.

127 {
128  for (integer i = size*nout; i-- > 0; ) {
129  theta[i] = pd[i];
130  }
131 }
integer size
Definition: id.h:46
integer nout
Definition: id.h:47
doublereal * theta
Definition: id.h:58
long int integer
Definition: colamd.c:51

Member Data Documentation

doublereal* Ident::err
protected

Definition at line 63 of file id.h.

Referenced by Ident(), pdGetErr(), and Update().

doublereal Ident::k
protected

Definition at line 66 of file id.h.

Referenced by dGetForgettingFactor(), SetForgettingFactor(), and Update().

doublereal* Ident::ldl
protected

Definition at line 52 of file id.h.

Referenced by Ident(), pdGetTheta(), and Update().

integer Ident::nout
protected

Definition at line 47 of file id.h.

Referenced by Ident(), pdGetTheta(), SetForgettingFactor(), Update(), and UpdateTheta().

doublereal* Ident::pdBase
protected

Definition at line 49 of file id.h.

Referenced by Ident(), and ~Ident().

ForgettingFactor* Ident::pF
protected

Definition at line 65 of file id.h.

Referenced by Update(), and ~Ident().

doublereal* Ident::phi
protected

Definition at line 61 of file id.h.

Referenced by Ident(), and Update().

doublereal** Ident::ppdBase
protected

Definition at line 50 of file id.h.

Referenced by Ident(), and ~Ident().

integer Ident::size
protected

Definition at line 46 of file id.h.

Referenced by Ident(), pdGetTheta(), SetForgettingFactor(), Update(), and UpdateTheta().

doublereal* Ident::theta
protected

Definition at line 58 of file id.h.

Referenced by Ident(), pdGetTheta(), and UpdateTheta().

doublereal** Ident::vldl
protected

Definition at line 53 of file id.h.

Referenced by Ident(), and SetForgettingFactor().

doublereal** Ident::vtheta
protected

Definition at line 59 of file id.h.

Referenced by Ident(), and Update().

doublereal** Ident::vz
protected

Definition at line 56 of file id.h.

Referenced by Ident(), and SetForgettingFactor().

doublereal Ident::w
protected

Definition at line 67 of file id.h.

Referenced by SetForgettingFactor().

doublereal* Ident::y
protected

Definition at line 62 of file id.h.

Referenced by Ident(), and Update().

doublereal* Ident::z
protected

Definition at line 55 of file id.h.

Referenced by Ident(), pdGetTheta(), and Update().


The documentation for this class was generated from the following files: