Skip to content
Snippets Groups Projects
Commit 96e3a1b7 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

k_order_perturbation: fixed illegal cast

(cherry picked from commit 34ab1a56)
parent 871a2728
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <cctype> #include <cctype>
#include <cassert>
#ifdef _MSC_VER #ifdef _MSC_VER
...@@ -303,8 +304,11 @@ extern "C" { ...@@ -303,8 +304,11 @@ extern "C" {
map<string, ConstTwoDMatrix>::const_iterator cit = mm.begin(); map<string, ConstTwoDMatrix>::const_iterator cit = mm.begin();
++cit; ++cit;
plhs[0] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL); plhs[0] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL);
TwoDMatrix g((*cit).second.numRows(), (*cit).second.numCols(), mxGetPr(plhs[0]));
g = (const TwoDMatrix &)(*cit).second; // Copy Dynare++ matrix into MATLAB matrix
const ConstVector &vec = (*cit).second.getData();
assert(vec.skip() == 1);
memcpy(mxGetPr(plhs[0]), vec.base(), vec.length() * sizeof(double));
} }
if (kOrder >= 2) if (kOrder >= 2)
{ {
...@@ -314,8 +318,12 @@ extern "C" { ...@@ -314,8 +318,12 @@ extern "C" {
{ {
{ {
plhs[ii] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL); plhs[ii] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL);
TwoDMatrix g_ii((*cit).second.numRows(), (*cit).second.numCols(), mxGetPr(plhs[ii]));
g_ii = (const TwoDMatrix &)(*cit).second; // Copy Dynare++ matrix into MATLAB matrix
const ConstVector &vec = (*cit).second.getData();
assert(vec.skip() == 1);
memcpy(mxGetPr(plhs[ii]), vec.base(), vec.length() * sizeof(double));
++ii; ++ii;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment