Various minor changes for compatibility with MS Visual C++ and GCC 4.4
git-svn-id: https://www.dynare.org/svn/dynare/trunk@3105 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
8651edc42c
commit
31ed196c44
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
/* $Id: formula.y 1749 2008-03-28 11:59:29Z kamenik $ */
|
/* $Id: formula.y 1749 2008-03-28 11:59:29Z kamenik $ */
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include "location.h"
|
#include "location.h"
|
||||||
#include "formula_parser.h"
|
#include "formula_parser.h"
|
||||||
#include "formula_tab.hh"
|
#include "formula_tab.hh"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "parser_exception.h"
|
#include "parser_exception.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
using namespace ogp;
|
using namespace ogp;
|
||||||
|
|
||||||
|
|
|
@ -456,7 +456,11 @@ bool ConstGeneralMatrix::isFinite() const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numRows(); i++)
|
for (int i = 0; i < numRows(); i++)
|
||||||
for (int j = 0; j < numCols(); j++)
|
for (int j = 0; j < numCols(); j++)
|
||||||
|
#ifndef _MSC_VER
|
||||||
if (! std::isfinite(get(i,j)))
|
if (! std::isfinite(get(i,j)))
|
||||||
|
#else
|
||||||
|
if (! _finite(get(i,j)))
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,11 @@ double ConstVector::dot(const ConstVector& y) const
|
||||||
bool ConstVector::isFinite() const
|
bool ConstVector::isFinite() const
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
#ifndef _MSC_VER
|
||||||
while (i < length() && isfinite(operator[](i)))
|
while (i < length() && isfinite(operator[](i)))
|
||||||
|
#else
|
||||||
|
while (i < length() && _finite(operator[](i)))
|
||||||
|
#endif
|
||||||
i++;
|
i++;
|
||||||
return i == length();
|
return i == length();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,10 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "SparseMatrix.hh"
|
#include "SparseMatrix.hh"
|
||||||
|
|
||||||
using namespace std;
|
#ifdef _MSC_VER
|
||||||
|
unsigned long _nan[2] = { 0xffffffff, 0x7fffffff };
|
||||||
|
double NAN = *((double *) _nan);
|
||||||
|
#endif
|
||||||
|
|
||||||
SparseMatrix::SparseMatrix()
|
SparseMatrix::SparseMatrix()
|
||||||
{
|
{
|
||||||
|
@ -40,11 +43,6 @@ SparseMatrix::SparseMatrix()
|
||||||
start_compare = 0;
|
start_compare = 0;
|
||||||
restart = 0;
|
restart = 0;
|
||||||
IM_i.clear();
|
IM_i.clear();
|
||||||
#ifdef _MSC_VER
|
|
||||||
nan__[0] = 0xffffffff;
|
|
||||||
nan__[1] = 0x7fffffff;
|
|
||||||
NAN = *( double* )nan__;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -26,16 +26,51 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include "Mem_Mngr.hh"
|
#include "Mem_Mngr.hh"
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <limits>
|
|
||||||
#endif
|
|
||||||
#define NEW_ALLOC
|
#define NEW_ALLOC
|
||||||
#define MARKOVITZ
|
#define MARKOVITZ
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# include <limits>
|
||||||
|
|
||||||
|
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<double>::has_infinity &&
|
||||||
|
value == std::numeric_limits<double>::infinity());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T asinh(T x)
|
||||||
|
{
|
||||||
|
return log(x+sqrt(x*x+1));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T acosh(T x)
|
||||||
|
{
|
||||||
|
if (!(x>=1.0))
|
||||||
|
return sqrt(-1.0);
|
||||||
|
return log(x+sqrt(x*x-1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
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
|
struct t_save_op_s
|
||||||
{
|
{
|
||||||
|
@ -67,43 +102,6 @@ class SparseMatrix
|
||||||
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_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);
|
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<double>::has_infinity &&
|
|
||||||
value == std::numeric_limits<double>::infinity());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline double asinh(double x)
|
|
||||||
{
|
|
||||||
return log(x+sqrt(x*x+1));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
inline T acosh(T x)
|
|
||||||
{
|
|
||||||
if(!(x>=1.0)) return sqrt(-1.0);
|
|
||||||
return log(x+sqrt(x*x-1.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
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:
|
private:
|
||||||
void Init(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int> ,int>, int> &IM);
|
void Init(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int> ,int>, int> &IM);
|
||||||
void ShortInit(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int> ,int>, int> &IM);
|
void ShortInit(int periods, int y_kmin, int y_kmax, int Size, map<pair<pair<int, int> ,int>, int> &IM);
|
||||||
|
|
|
@ -36,6 +36,18 @@
|
||||||
#endif
|
#endif
|
||||||
#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 <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -1379,21 +1379,12 @@ UnaryOpNode::eval_opcode(UnaryOpcode op_code, double v) throw (EvalException)
|
||||||
return(sinh(v));
|
return(sinh(v));
|
||||||
case oTanh:
|
case oTanh:
|
||||||
return(tanh(v));
|
return(tanh(v));
|
||||||
#ifndef _WIN64
|
|
||||||
case oAcosh:
|
case oAcosh:
|
||||||
return(acosh(v));
|
return(acosh(v));
|
||||||
case oAsinh:
|
case oAsinh:
|
||||||
return(asinh(v));
|
return(asinh(v));
|
||||||
case oAtanh:
|
case oAtanh:
|
||||||
return(atanh(v));
|
return(atanh(v));
|
||||||
#else
|
|
||||||
case oAcosh:
|
|
||||||
throw EvalException();
|
|
||||||
case oAsinh:
|
|
||||||
throw EvalException();
|
|
||||||
case oAtanh:
|
|
||||||
throw EvalException();
|
|
||||||
#endif
|
|
||||||
case oSqrt:
|
case oSqrt:
|
||||||
return(sqrt(v));
|
return(sqrt(v));
|
||||||
case oSteadyState:
|
case oSteadyState:
|
||||||
|
|
Loading…
Reference in New Issue