Commit 74100945 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Estimation DLL: various minor changes

parent e5d093c6
...@@ -61,7 +61,7 @@ void ...@@ -61,7 +61,7 @@ void
LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams, LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams,
Matrix &Q, Matrix &H, size_t period) Matrix &Q, Matrix &H, size_t period)
{ {
size_t i, j, k, k1, k2; size_t i, k, k1, k2;
int test; int test;
bool found; bool found;
std::vector<size_t>::const_iterator it; std::vector<size_t>::const_iterator it;
...@@ -79,7 +79,7 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams ...@@ -79,7 +79,7 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams
switch (estiParDesc.estParams[i].ptype) switch (estiParDesc.estParams[i].ptype)
{ {
case EstimatedParameter::shock_SD: case EstimatedParameter::shock_SD:
k = (int) estiParDesc.estParams[i].ID1; k = estiParDesc.estParams[i].ID1;
Q(k, k) = estParams(i)*estParams(i); Q(k, k) = estParams(i)*estParams(i);
break; break;
...@@ -87,7 +87,7 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams ...@@ -87,7 +87,7 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams
#ifdef DEBUG #ifdef DEBUG
mexPrintf("Setting of H var_endo\n"); mexPrintf("Setting of H var_endo\n");
#endif #endif
k = (int) estiParDesc.estParams[i].ID1; k = estiParDesc.estParams[i].ID1;
H(k, k) = estParams(i)*estParams(i); H(k, k) = estParams(i)*estParams(i);
break; break;
...@@ -95,8 +95,8 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams ...@@ -95,8 +95,8 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams
#ifdef DEBUG #ifdef DEBUG
mexPrintf("Setting of Q corrx\n"); mexPrintf("Setting of Q corrx\n");
#endif #endif
k1 = (int) estiParDesc.estParams[i].ID1; k1 = estiParDesc.estParams[i].ID1;
k2 = (int) estiParDesc.estParams[i].ID2; k2 = estiParDesc.estParams[i].ID2;
Q(k1, k2) = estParams(i)*sqrt(Q(k1, k1)*Q(k2, k2)); Q(k1, k2) = estParams(i)*sqrt(Q(k1, k1)*Q(k2, k2));
Q(k2, k1) = Q(k1, k2); Q(k2, k1) = Q(k1, k2);
// [CholQ,testQ] = chol(Q); // [CholQ,testQ] = chol(Q);
...@@ -131,8 +131,8 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams ...@@ -131,8 +131,8 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams
#ifdef DEBUG #ifdef DEBUG
mexPrintf("Setting of H corrn\n"); mexPrintf("Setting of H corrn\n");
#endif #endif
k1 = (int) estiParDesc.estParams[i].ID1; k1 = estiParDesc.estParams[i].ID1;
k2 = (int) estiParDesc.estParams[i].ID2; k2 = estiParDesc.estParams[i].ID2;
// H(k1,k2) = xparam1(i)*sqrt(H(k1,k1)*H(k2,k2)); // H(k1,k2) = xparam1(i)*sqrt(H(k1,k1)*H(k2,k2));
// H(k2,k1) = H(k1,k2); // H(k2,k1) = H(k1,k2);
H(k1, k2) = estParams(i)*sqrt(H(k1, k1)*H(k2, k2)); H(k1, k2) = estParams(i)*sqrt(H(k1, k1)*H(k2, k2));
...@@ -168,7 +168,7 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams ...@@ -168,7 +168,7 @@ LogLikelihoodSubSample::updateParams(const Vector &estParams, Vector &deepParams
//if estim_params_.np > 0 // i.e. num of deep parameters >0 //if estim_params_.np > 0 // i.e. num of deep parameters >0
case EstimatedParameter::deepPar: case EstimatedParameter::deepPar:
k = (int) estiParDesc.estParams[i].ID1; k = estiParDesc.estParams[i].ID1;
deepParams(k) = estParams(i); deepParams(k) = estParams(i);
break; break;
default: default:
......
...@@ -26,8 +26,9 @@ VDVEigDecomposition::VDVEigDecomposition(const Matrix &m) throw(VDVEigException) ...@@ -26,8 +26,9 @@ VDVEigDecomposition::VDVEigDecomposition(const Matrix &m) throw(VDVEigException)
if (m.getRows() != m.getCols()) if (m.getRows() != m.getCols())
throw(VDVEigException(info, "Matrix is not square in VDVEigDecomposition constructor")); throw(VDVEigException(info, "Matrix is not square in VDVEigDecomposition constructor"));
double tmpwork;
dsyev("V", "U", &n, V.getData(), &lda, D.getData(), &tmpwork, &lwork, &info); dsyev("V", "U", &n, V.getData(), &lda, D.getData(), &tmpwork, &lwork, &info);
lwork = (int) tmpwork; lwork = (lapack_int) tmpwork;
work = new double[lwork]; work = new double[lwork];
if (info < 0) if (info < 0)
throw(VDVEigException(info, "Internal error in VDVEigDecomposition constructor")); throw(VDVEigException(info, "Internal error in VDVEigDecomposition constructor"));
......
...@@ -34,7 +34,6 @@ class VDVEigDecomposition ...@@ -34,7 +34,6 @@ class VDVEigDecomposition
{ {
lapack_int lda, n; lapack_int lda, n;
lapack_int lwork, info; lapack_int lwork, info;
double tmpwork;
double *work; double *work;
bool converged; bool converged;
Matrix V; Matrix V;
...@@ -100,12 +99,14 @@ VDVEigDecomposition::calculate(const Mat &m) throw(VDVEigException) ...@@ -100,12 +99,14 @@ VDVEigDecomposition::calculate(const Mat &m) throw(VDVEigException)
if (m.getCols() != (size_t) n || m.getLd() != (size_t) lda) if (m.getCols() != (size_t) n || m.getLd() != (size_t) lda)
throw(VDVEigException(info, "Matrix not matching VDVEigDecomposition class")); throw(VDVEigException(info, "Matrix not matching VDVEigDecomposition class"));
double tmpwork;
lapack_int tmplwork = -1; lapack_int tmplwork = -1;
V = m; V = m;
dsyev("V", "U", &n, V.getData(), &lda, D.getData(), &tmpwork, &tmplwork, &info); dsyev("V", "U", &n, V.getData(), &lda, D.getData(), &tmpwork, &tmplwork, &info);
if (lwork < tmpwork) if (lwork < (lapack_int) tmpwork)
{ {
lwork = tmpwork; lwork = (lapack_int) tmpwork;
delete[] work; delete[] work;
work = new double[lwork]; work = new double[lwork];
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment