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