preprocessor and matlab mex fixes for clang compilation
parent
a72cc3ff48
commit
5352fb4d16
|
@ -37,6 +37,8 @@
|
||||||
# define CHAR_LENGTH 2
|
# define CHAR_LENGTH 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ASCII_POUND_SIGN_CODE 156
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#define M_E 2.71828182845904523536
|
#define M_E 2.71828182845904523536
|
||||||
|
@ -328,20 +330,24 @@ public:
|
||||||
string temp;
|
string temp;
|
||||||
int pos1 = -1, pos2 = -1;
|
int pos1 = -1, pos2 = -1;
|
||||||
string tmp_n(str.length(), ' ');
|
string tmp_n(str.length(), ' ');
|
||||||
|
string dollar, pound, tilde;
|
||||||
|
dollar = "$";
|
||||||
|
pound = (char)ASCII_POUND_SIGN_CODE;
|
||||||
|
tilde = "~";
|
||||||
for (unsigned int i = 0; i < str.length(); i++)
|
for (unsigned int i = 0; i < str.length(); i++)
|
||||||
{
|
{
|
||||||
if (str[i] != '$' && str[i] != '£')
|
if (dollar.compare(&str[i]) != 0 && pound.compare(&str[i]) != 0)
|
||||||
temp += str[i];
|
temp += str[i];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (str[i] == '$')
|
if (dollar.compare(&str[i]) == 0)
|
||||||
pos1 = int(temp.length());
|
pos1 = int(temp.length());
|
||||||
else
|
else
|
||||||
pos2 = int(temp.length());
|
pos2 = int(temp.length());
|
||||||
if (pos1 >= 0 && pos2 >= 0)
|
if (pos1 >= 0 && pos2 >= 0)
|
||||||
{
|
{
|
||||||
tmp_n.erase(pos1, pos2-pos1+1);
|
tmp_n.erase(pos1, pos2-pos1+1);
|
||||||
tmp_n.insert(pos1, pos2-pos1, '~');
|
tmp_n.insert(pos1, pos2-pos1, tilde[0]);
|
||||||
pos1 = pos2 = -1;
|
pos1 = pos2 = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +414,7 @@ public:
|
||||||
res << P_endo_names[CHAR_LENGTH*(variable_num+i*nb_endo)];
|
res << P_endo_names[CHAR_LENGTH*(variable_num+i*nb_endo)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mexPrintf("=> Unknown endogenous variable n° %d", variable_num);
|
mexPrintf("=> Unknown endogenous variable # %d", variable_num);
|
||||||
break;
|
break;
|
||||||
case eExogenous:
|
case eExogenous:
|
||||||
case eExogenousDet:
|
case eExogenousDet:
|
||||||
|
@ -419,7 +425,7 @@ public:
|
||||||
res << P_exo_names[CHAR_LENGTH*(variable_num+i*nb_exo)];
|
res << P_exo_names[CHAR_LENGTH*(variable_num+i*nb_exo)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mexPrintf("=> Unknown exogenous variable n° %d", variable_num);
|
mexPrintf("=> Unknown exogenous variable # %d", variable_num);
|
||||||
break;
|
break;
|
||||||
case eParameter:
|
case eParameter:
|
||||||
if (variable_num < nb_param)
|
if (variable_num < nb_param)
|
||||||
|
@ -429,7 +435,7 @@ public:
|
||||||
res << P_param_names[CHAR_LENGTH*(variable_num+i*nb_param)];
|
res << P_param_names[CHAR_LENGTH*(variable_num+i*nb_param)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mexPrintf("=> Unknown parameter n° %d", variable_num);
|
mexPrintf("=> Unknown parameter # %d", variable_num);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1271,7 +1277,7 @@ public:
|
||||||
tmp_out << "$";
|
tmp_out << "$";
|
||||||
tmp_out << " / ";
|
tmp_out << " / ";
|
||||||
if (isinf(r))
|
if (isinf(r))
|
||||||
tmp_out << "£";
|
tmp_out << (char)ASCII_POUND_SIGN_CODE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tmp_out << " / ";
|
tmp_out << " / ";
|
||||||
|
@ -1434,7 +1440,7 @@ public:
|
||||||
if (compute)
|
if (compute)
|
||||||
{
|
{
|
||||||
if (isnan(r))
|
if (isnan(r))
|
||||||
tmp_out << "$ ^ £";
|
tmp_out << "$ ^ " << (char)ASCII_POUND_SIGN_CODE;
|
||||||
else
|
else
|
||||||
tmp_out << " ^ ";
|
tmp_out << " ^ ";
|
||||||
}
|
}
|
||||||
|
@ -1476,7 +1482,7 @@ public:
|
||||||
if (compute)
|
if (compute)
|
||||||
{
|
{
|
||||||
if (isnan(r))
|
if (isnan(r))
|
||||||
tmp_out << "$ PowerDeriv £";
|
tmp_out << "$ PowerDeriv " << (char)ASCII_POUND_SIGN_CODE;
|
||||||
else
|
else
|
||||||
tmp_out << "PowerDeriv";
|
tmp_out << "PowerDeriv";
|
||||||
}
|
}
|
||||||
|
@ -1550,7 +1556,7 @@ public:
|
||||||
if (compute)
|
if (compute)
|
||||||
{
|
{
|
||||||
if (isnan(r))
|
if (isnan(r))
|
||||||
tmp_out << "$log£(" << v1 << ")";
|
tmp_out << "$log" << (char)ASCII_POUND_SIGN_CODE << "(" << v1 << ")";
|
||||||
else
|
else
|
||||||
tmp_out << "log(" << v1 << ")";
|
tmp_out << "log(" << v1 << ")";
|
||||||
}
|
}
|
||||||
|
@ -1568,7 +1574,7 @@ public:
|
||||||
if (compute)
|
if (compute)
|
||||||
{
|
{
|
||||||
if (isnan(r))
|
if (isnan(r))
|
||||||
tmp_out << "$log10£(" << v1 << ")";
|
tmp_out << "$log10" << (char)ASCII_POUND_SIGN_CODE << "(" << v1 << ")";
|
||||||
else
|
else
|
||||||
tmp_out << "log10(" << v1 << ")";
|
tmp_out << "log10(" << v1 << ")";
|
||||||
}
|
}
|
||||||
|
@ -1774,11 +1780,7 @@ public:
|
||||||
}
|
}
|
||||||
tmp_out.str("");
|
tmp_out.str("");
|
||||||
tmp_out << function_name << "(";
|
tmp_out << function_name << "(";
|
||||||
#ifndef _MSC_VER
|
|
||||||
string ss[nb_input_arguments];
|
|
||||||
#else
|
|
||||||
vector<string> ss(nb_input_arguments);
|
vector<string> ss(nb_input_arguments);
|
||||||
#endif
|
|
||||||
for (unsigned int i = 0; i < nb_input_arguments; i++)
|
for (unsigned int i = 0; i < nb_input_arguments; i++)
|
||||||
{
|
{
|
||||||
ss[nb_input_arguments-i-1] = Stack.top();
|
ss[nb_input_arguments-i-1] = Stack.top();
|
||||||
|
@ -1832,11 +1834,7 @@ public:
|
||||||
tmp_out.str("");
|
tmp_out.str("");
|
||||||
tmp_out << function_name << "(";
|
tmp_out << function_name << "(";
|
||||||
tmp_out << arg_func_name.c_str() << ", " << fc->get_row() << ", {";
|
tmp_out << arg_func_name.c_str() << ", " << fc->get_row() << ", {";
|
||||||
#ifndef _MSC_VER
|
|
||||||
string ss[nb_add_input_arguments];
|
|
||||||
#else
|
|
||||||
vector<string> ss(nb_input_arguments);
|
vector<string> ss(nb_input_arguments);
|
||||||
#endif
|
|
||||||
for (unsigned int i = 0; i < nb_add_input_arguments; i++)
|
for (unsigned int i = 0; i < nb_add_input_arguments; i++)
|
||||||
{
|
{
|
||||||
ss[nb_add_input_arguments-i-1] = Stack.top();
|
ss[nb_add_input_arguments-i-1] = Stack.top();
|
||||||
|
@ -1867,11 +1865,7 @@ public:
|
||||||
}
|
}
|
||||||
tmp_out.str("");
|
tmp_out.str("");
|
||||||
tmp_out << function_name << "(";
|
tmp_out << function_name << "(";
|
||||||
#ifndef _MSC_VER
|
|
||||||
string ss[nb_input_arguments];
|
|
||||||
#else
|
|
||||||
vector<string> ss(nb_input_arguments);
|
vector<string> ss(nb_input_arguments);
|
||||||
#endif
|
|
||||||
for (unsigned int i = 0; i < nb_input_arguments; i++)
|
for (unsigned int i = 0; i < nb_input_arguments; i++)
|
||||||
{
|
{
|
||||||
ss[nb_input_arguments-i-1] = Stack.top();
|
ss[nb_input_arguments-i-1] = Stack.top();
|
||||||
|
@ -1924,11 +1918,7 @@ public:
|
||||||
tmp_out.str("");
|
tmp_out.str("");
|
||||||
tmp_out << function_name << "(";
|
tmp_out << function_name << "(";
|
||||||
tmp_out << arg_func_name.c_str() << ", " << fc->get_row() << ", " << fc->get_col() << ", {";
|
tmp_out << arg_func_name.c_str() << ", " << fc->get_row() << ", " << fc->get_col() << ", {";
|
||||||
#ifndef _MSC_VER
|
|
||||||
string ss[nb_add_input_arguments];
|
|
||||||
#else
|
|
||||||
vector<string> ss(nb_input_arguments);
|
vector<string> ss(nb_input_arguments);
|
||||||
#endif
|
|
||||||
for (unsigned int i = 0; i < nb_add_input_arguments; i++)
|
for (unsigned int i = 0; i < nb_add_input_arguments; i++)
|
||||||
{
|
{
|
||||||
ss[nb_add_input_arguments-i-1] = Stack.top();
|
ss[nb_add_input_arguments-i-1] = Stack.top();
|
||||||
|
@ -1959,11 +1949,7 @@ public:
|
||||||
}
|
}
|
||||||
tmp_out.str("");
|
tmp_out.str("");
|
||||||
tmp_out << function_name << "(";
|
tmp_out << function_name << "(";
|
||||||
#ifndef _MSC_VER
|
|
||||||
string ss[nb_input_arguments];
|
|
||||||
#else
|
|
||||||
vector<string> ss(nb_input_arguments);
|
vector<string> ss(nb_input_arguments);
|
||||||
#endif
|
|
||||||
for (unsigned int i = 0; i < nb_input_arguments; i++)
|
for (unsigned int i = 0; i < nb_input_arguments; i++)
|
||||||
{
|
{
|
||||||
ss[nb_input_arguments-i-1] = Stack.top();
|
ss[nb_input_arguments-i-1] = Stack.top();
|
||||||
|
|
|
@ -527,7 +527,7 @@ main(int nrhs, const char *prhs[])
|
||||||
for (vector<s_plan>::iterator it = splan.begin(); it != splan.end(); it++)
|
for (vector<s_plan>::iterator it = splan.begin(); it != splan.end(); it++)
|
||||||
{
|
{
|
||||||
mexPrintf("----------------------------------------------------------------------------------------------------\n");
|
mexPrintf("----------------------------------------------------------------------------------------------------\n");
|
||||||
mexPrintf("suprise n°%d\n", i+1);
|
mexPrintf("suprise #%d\n", i+1);
|
||||||
if (it->exo.length())
|
if (it->exo.length())
|
||||||
mexPrintf(" plan fliping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
mexPrintf(" plan fliping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
||||||
else
|
else
|
||||||
|
@ -605,7 +605,7 @@ main(int nrhs, const char *prhs[])
|
||||||
for (vector<s_plan>::iterator it = spfplan.begin(); it != spfplan.end(); it++)
|
for (vector<s_plan>::iterator it = spfplan.begin(); it != spfplan.end(); it++)
|
||||||
{
|
{
|
||||||
mexPrintf("----------------------------------------------------------------------------------------------------\n");
|
mexPrintf("----------------------------------------------------------------------------------------------------\n");
|
||||||
mexPrintf("perfect foresight n°%d\n", i+1);
|
mexPrintf("perfect foresight #%d\n", i+1);
|
||||||
if (it->exo.length())
|
if (it->exo.length())
|
||||||
mexPrintf(" plan flipping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
mexPrintf(" plan flipping var=%s (%d) exo=%s (%d) for the following periods and with the following values:\n", it->var.c_str(), it->var_num, it->exo.c_str(), it->exo_num);
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2010-2011 Dynare Team
|
* Copyright (C) 2010-2013 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -62,13 +62,13 @@ public:
|
||||||
};
|
};
|
||||||
virtual ~DiscLyapFast() {};
|
virtual ~DiscLyapFast() {};
|
||||||
template <class MatG, class MatV, class MatX >
|
template <class MatG, class MatV, class MatX >
|
||||||
void solve_lyap(const MatG &G, const MatV &V, MatX &X, double tol, size_t flag_ch) throw (DLPException);
|
void solve_lyap(const MatG &G, const MatV &V, MatX &X, double tol = 1e-16, size_t flag_ch = 0) throw (DLPException);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class MatG, class MatV, class MatX >
|
template <class MatG, class MatV, class MatX >
|
||||||
void
|
void
|
||||||
DiscLyapFast::solve_lyap(const MatG &G, const MatV &V, MatX &X, double tol = 1e-16, size_t flag_ch = 0) throw (DLPException)
|
DiscLyapFast::solve_lyap(const MatG &G, const MatV &V, MatX &X, double tol, size_t flag_ch) throw (DLPException)
|
||||||
{
|
{
|
||||||
P0 = V;
|
P0 = V;
|
||||||
P1 = V;
|
P1 = V;
|
||||||
|
|
|
@ -210,7 +210,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
|
||||||
ostringstream tmp_output, tmp1_output, global_output;
|
ostringstream tmp_output, tmp1_output, global_output;
|
||||||
expr_t lhs = NULL, rhs = NULL;
|
expr_t lhs = NULL, rhs = NULL;
|
||||||
BinaryOpNode *eq_node;
|
BinaryOpNode *eq_node;
|
||||||
ostringstream Uf[symbol_table.endo_nbr()];
|
vector<ostringstream> Uf(symbol_table.endo_nbr());
|
||||||
map<expr_t, int> reference_count;
|
map<expr_t, int> reference_count;
|
||||||
temporary_terms_t local_temporary_terms;
|
temporary_terms_t local_temporary_terms;
|
||||||
ofstream output;
|
ofstream output;
|
||||||
|
|
Loading…
Reference in New Issue