diff --git a/dynare++/parser/cc/formula.y b/dynare++/parser/cc/formula.y index d8d53405e..1325aee77 100644 --- a/dynare++/parser/cc/formula.y +++ b/dynare++/parser/cc/formula.y @@ -3,6 +3,8 @@ /* $Id: formula.y 1749 2008-03-28 11:59:29Z kamenik $ */ +#include + #include "location.h" #include "formula_parser.h" #include "formula_tab.hh" diff --git a/dynare++/parser/cc/parser_exception.cpp b/dynare++/parser/cc/parser_exception.cpp index f6ee32ccc..fbd0e28f9 100644 --- a/dynare++/parser/cc/parser_exception.cpp +++ b/dynare++/parser/cc/parser_exception.cpp @@ -4,6 +4,7 @@ #include "parser_exception.h" #include +#include using namespace ogp; diff --git a/dynare++/sylv/cc/GeneralMatrix.cpp b/dynare++/sylv/cc/GeneralMatrix.cpp index 69c48b6f2..1c42806cc 100644 --- a/dynare++/sylv/cc/GeneralMatrix.cpp +++ b/dynare++/sylv/cc/GeneralMatrix.cpp @@ -456,7 +456,11 @@ bool ConstGeneralMatrix::isFinite() const { for (int i = 0; i < numRows(); i++) for (int j = 0; j < numCols(); j++) +#ifndef _MSC_VER if (! std::isfinite(get(i,j))) +#else + if (! _finite(get(i,j))) +#endif return false; return true; } diff --git a/dynare++/sylv/cc/Vector.cpp b/dynare++/sylv/cc/Vector.cpp index a5186cf09..889389ed9 100644 --- a/dynare++/sylv/cc/Vector.cpp +++ b/dynare++/sylv/cc/Vector.cpp @@ -354,7 +354,11 @@ double ConstVector::dot(const ConstVector& y) const bool ConstVector::isFinite() const { int i = 0; +#ifndef _MSC_VER while (i < length() && isfinite(operator[](i))) +#else + while (i < length() && _finite(operator[](i))) +#endif i++; return i == length(); } diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index 55a682df8..394faae03 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -22,7 +22,10 @@ #include #include "SparseMatrix.hh" -using namespace std; +#ifdef _MSC_VER +unsigned long _nan[2] = { 0xffffffff, 0x7fffffff }; +double NAN = *((double *) _nan); +#endif SparseMatrix::SparseMatrix() { @@ -39,12 +42,7 @@ SparseMatrix::SparseMatrix() tbreak_g = 0; start_compare = 0; restart = 0; - IM_i.clear(); -#ifdef _MSC_VER - nan__[0] = 0xffffffff; - nan__[1] = 0x7fffffff; - NAN = *( double* )nan__; -#endif + IM_i.clear(); } int diff --git a/mex/sources/bytecode/SparseMatrix.hh b/mex/sources/bytecode/SparseMatrix.hh index b5abe589d..39f483ec1 100644 --- a/mex/sources/bytecode/SparseMatrix.hh +++ b/mex/sources/bytecode/SparseMatrix.hh @@ -26,16 +26,51 @@ #include #include #include "Mem_Mngr.hh" -#ifdef _MSC_VER - #include -#endif #define NEW_ALLOC #define MARKOVITZ using namespace std; - - - + +#ifdef _MSC_VER +# include + +extern unsigned long _nan[2]; +extern double NAN; + +inline bool isnan(double value) +{ + return _isnan(value); +} + +inline bool isinf(double value) +{ + return (std::numeric_limits::has_infinity && + value == std::numeric_limits::infinity()); +} + +template +inline T asinh(T x) +{ + return log(x+sqrt(x*x+1)); +} + +template +inline T acosh(T x) +{ + if (!(x>=1.0)) + return sqrt(-1.0); + return log(x+sqrt(x*x-1.0)); +} + +template +inline T atanh(T x) +{ + if(!(x>-1.0 && x<1.0)) + return sqrt(-1.0); + return log((1.0+x)/(1.0-x))/2.0; +} + +#endif struct t_save_op_s { @@ -66,43 +101,6 @@ class SparseMatrix void fixe_u(double **u, int u_count_int, int max_lag_plus_max_lead_plus_1); void Read_SparseMatrix(string file_name, const int Size, int periods, int y_kmin, int y_kmax, bool steady_state, bool two_boundaries); void Read_file(string file_name, int periods, int u_size1, int y_size, int y_kmin, int y_kmax, int &nb_endo, int &u_count, int &u_count_init, double* u); - -#ifdef _MSC_VER - unsigned long nan__[2]; - double NAN; - - inline bool isnan(double value) - { - return value != value; - } - - inline bool isinf(double value) - { - return (std::numeric_limits::has_infinity && - value == std::numeric_limits::infinity()); - } - - - inline double asinh(double x) - { - return log(x+sqrt(x*x+1)); - } - - template - inline T acosh(T x) - { - if(!(x>=1.0)) return sqrt(-1.0); - return log(x+sqrt(x*x-1.0)); - } - - template - inline T atanh(T x) - { - if(!(x>-1.0 && x<1.0)) return sqrt(-1.0); - return log((1.0+x)/(1.0-x))/2.0; - } - -#endif private: void Init(int periods, int y_kmin, int y_kmax, int Size, map ,int>, int> &IM); diff --git a/preprocessor/CodeInterpreter.hh b/preprocessor/CodeInterpreter.hh index 367cb2412..abfa44d1f 100644 --- a/preprocessor/CodeInterpreter.hh +++ b/preprocessor/CodeInterpreter.hh @@ -36,6 +36,18 @@ #endif #endif +#ifdef _MSC_VER +typedef __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +# include +#endif using namespace std; diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc index 630073512..cb8ba7fb2 100644 --- a/preprocessor/ExprNode.cc +++ b/preprocessor/ExprNode.cc @@ -1379,21 +1379,12 @@ UnaryOpNode::eval_opcode(UnaryOpcode op_code, double v) throw (EvalException) return(sinh(v)); case oTanh: return(tanh(v)); -#ifndef _WIN64 case oAcosh: return(acosh(v)); case oAsinh: return(asinh(v)); case oAtanh: return(atanh(v)); -#else - case oAcosh: - throw EvalException(); - case oAsinh: - throw EvalException(); - case oAtanh: - throw EvalException(); -#endif case oSqrt: return(sqrt(v)); case oSteadyState: