Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
a3640239
Commit
a3640239
authored
Sep 21, 2010
by
Sébastien Villemot
Browse files
Removed all MSVC workarounds, since we can now definitely drop this compiler on
Windows/64-bit platform
parent
750f92ac
Changes
18
Hide whitespace changes
Inline
Side-by-side
dynare++/integ/cc/vector_function.cweb
View file @
a3640239
...
...
@@ -155,11 +155,7 @@ void GaussConverterFunction::eval(const Vector& point, const ParameterSignal& si
@<|GaussConverterFunction::multiplier| code@>=
double GaussConverterFunction::calcMultiplier() const
{
#ifndef _MSC_VER
return sqrt(pow(M_PI, -1*indim()));
#else
return sqrt(pow(3.14159265358979323846, -1*indim()));
#endif
}
@
...
...
dynare++/kord/decision_rule.cweb
View file @
a3640239
...
...
@@ -683,11 +683,7 @@ void GenShockRealization::get(int n, Vector& out)
Vector r(numShocks());
RandomShockRealization::get(n, r);
for (int j = 0; j < numShocks(); j++)
#ifndef _MSC_VER
if (! isfinite(out[j]))
#else
if (!_finite(out[j]))
#endif
out[j] = r[j];
}
...
...
dynare++/kord/decision_rule.hweb
View file @
a3640239
...
...
@@ -631,13 +631,7 @@ damp by one half.
if (fnorm <= flastnorm)
urelax_found = true;
else
#ifndef _MSC_VER
urelax *= std::min(0.5, flastnorm/fnorm);
#else
/* MSVC doesn't define std::min() (should be in <algorithm>),
but instead has a macro in <windows.h> */
urelax *= min(0.5, flastnorm/fnorm);
#endif
}
...
...
dynare++/kord/first_order.cweb
View file @
a3640239
...
...
@@ -295,11 +295,7 @@ void FirstOrder::journalEigs()
}
JournalRecord jr(journal);
double mod = sqrt(alphar[i]*alphar[i]+alphai[i]*alphai[i]);
#ifndef _MSC_VER
mod = mod/round(100000*std::abs(beta[i]))*100000;
#else // MSVC doesn't respect C99 standard and doesn't define round(); use floor(x+0.5) instead
mod = mod/floor(100000*std::abs(beta[i])+0.5)*100000;
#endif
jr << i << "\t(" << alphar[i] << "," << alphai[i] << ") / " << beta[i]
<< " \t" << mod << endrec;
}
...
...
dynare++/kord/global_check.cweb
View file @
a3640239
...
...
@@ -373,11 +373,7 @@ f^i(x_1,\ldots,x_i) &=
for (qmcpit run = beg; run != end; ++run, icol++) {
Vector ycol(ymat, icol);
Vector x(run.point());
#ifndef _MSC_VER
x.mult(2*M_PI);
#else
x.mult(2*3.14159265358979323846);
#endif
ycol[0] = 1;
for (int i = 0; i < d; i++) {
Vector subsphere(ycol, 0, i+1);
...
...
dynare++/kord/journal.cweb
View file @
a3640239
...
...
@@ -7,18 +7,16 @@
#include "journal.h"
#include "kord_exception.h"
#if !defined(__MINGW32__)
&& !defined(_MSC_VER)
#if !defined(__MINGW32__)
# include <sys/resource.h>
# include <sys/utsname.h>
#endif
#include <cstdlib>
#ifndef _MSC_VER
# include <unistd.h>
#endif
#include <unistd.h>
#include <ctime>
SystemResources _sysres;
#if defined(__MINGW32__)
|| defined(_MSC_VER)
#if defined(__MINGW32__)
@<|sysconf| Win32 implementation@>;
#endif
...
...
@@ -27,50 +25,6 @@ SystemResources _sysres;
#define _SC_AVPHYS_PAGES 3
#endif
#ifdef _MSC_VER
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag = 0;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
tmpres /= 10; /*convert into microseconds*/
/*converting file time to unix epoch*/
tmpres -= 11644473600000000ULL;
tv->tv_sec = (long)(tmpres / 1000000UL);
tv->tv_usec = (long)(tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#endif
@<|SystemResources| constructor code@>;
@<|SystemResources::pageSize| code@>;
@<|SystemResources::physicalPages| code@>;
...
...
@@ -134,7 +88,7 @@ void SystemResources::getRUS(double& load_avg, long int& pg_avail,
gettimeofday(&now, NULL);
elapsed = now.tv_sec-start.tv_sec + (now.tv_usec-start.tv_usec)*1.0e-6;
#if !defined(__MINGW32__)
&& !defined(_MSC_VER)
#if !defined(__MINGW32__)
struct rusage rus;
getrusage(RUSAGE_SELF, &rus);
utime = rus.ru_utime.tv_sec+rus.ru_utime.tv_usec*1.0e-6;
...
...
@@ -148,7 +102,7 @@ void SystemResources::getRUS(double& load_avg, long int& pg_avail,
majflt = -1;
#endif
#if !defined(__MINGW32__) &&
!defined(_MSC_VER) &&
!defined(__CYGWIN32__)
#if !defined(__MINGW32__) && !defined(__CYGWIN32__)
getloadavg(&load_avg, 1);
#else
load_avg = -1.0;
...
...
@@ -260,7 +214,7 @@ void Journal::printHeader()
(*this)<< "General Public License, see http://www.gnu.org/license/gpl.html\n";
(*this)<< "\n\n";
#if !defined(__MINGW32__)
&& !defined(_MSC_VER)
#if !defined(__MINGW32__)
utsname info;
uname(&info);
(*this)<< "System info: ";
...
...
dynare++/kord/journal.hweb
View file @
a3640239
...
...
@@ -17,11 +17,7 @@
#include "int_sequence.h"
#ifdef _MSC_VER
# include <Winsock2.h>
#else
# include <sys/time.h>
#endif
#include <sys/time.h>
#include <cstdio>
#include <iostream>
#include <fstream>
...
...
dynare++/kord/random.cweb
View file @
a3640239
...
...
@@ -42,7 +42,7 @@ double RandomGenerator::normal()
@<|SystemRandomGenerator::uniform| code@>=
double SystemRandomGenerator::uniform()
{
#if !defined(__MINGW32__)
&& !defined(_MSC_VER)
#if !defined(__MINGW32__)
return drand48();
#else
return ((double)rand())/RAND_MAX;
...
...
@@ -53,7 +53,7 @@ double SystemRandomGenerator::uniform()
@<|SystemRandomGenerator::initSeed| code@>=
void SystemRandomGenerator::initSeed(int seed)
{
#if !defined(__MINGW32__)
&& !defined(_MSC_VER)
#if !defined(__MINGW32__)
srand48(seed);
#else
srand(seed);
...
...
dynare++/src/nlsolve.cpp
View file @
a3640239
...
...
@@ -7,11 +7,6 @@
#include
<cmath>
#ifdef _MSC_VER
// For _finite()
# include <cfloat>
#endif
using
namespace
ogu
;
/** This should not be greater than DBL_EPSILON^(1/2). */
...
...
@@ -37,11 +32,7 @@ double GoldenSectionSearch::search(OneDFunction& f, double x1, double x2)
else
x
=
b
+
dx
;
double
fx
=
f
.
eval
(
x
);
#ifndef _MSC_VER
if
(
!
std
::
isfinite
(
fx
))
#else
if
(
!
_finite
(
fx
))
#endif
return
x1
;
if
(
b
-
x1
>
x2
-
b
)
{
// x is on the left from b
...
...
@@ -78,11 +69,7 @@ double GoldenSectionSearch::search(OneDFunction& f, double x1, double x2)
bool
GoldenSectionSearch
::
init_bracket
(
OneDFunction
&
f
,
double
x1
,
double
&
x2
,
double
&
b
)
{
double
f1
=
f
.
eval
(
x1
);
#ifndef _MSC_VER
if
(
!
std
::
isfinite
(
f1
))
#else
if
(
!
_finite
(
f1
))
#endif
throw
DynareException
(
__FILE__
,
__LINE__
,
"Safer point not finite in GoldenSectionSearch::init_bracket"
);
...
...
@@ -99,11 +86,7 @@ bool GoldenSectionSearch::init_bracket(OneDFunction& f, double x1, double& x2, d
double
bsym
=
2
*
x2
-
b
;
double
fbsym
=
f
.
eval
(
bsym
);
// now we know that f1, f2, and fb are finite
#ifndef _MSC_VER
if
(
std
::
isfinite
(
fbsym
))
{
#else
if
(
_finite
(
fbsym
))
{
#endif
// we have four numbers f1, fb, f2, fbsym, we test for the
// following combinations to find the bracket:
// [f1,f2,fbsym], [f1,fb,fbsym] and [f1,fb,fbsym]
...
...
@@ -162,11 +145,7 @@ bool GoldenSectionSearch::search_for_finite(OneDFunction& f, double x1, double&
double
f2
=
f
.
eval
(
x2
);
b
=
(
1
-
golden
)
*
x1
+
golden
*
x2
;
double
fb
=
f
.
eval
(
b
);
#ifndef _MSC_VER
found
=
std
::
isfinite
(
f2
)
&&
std
::
isfinite
(
fb
);
#else
found
=
_finite
(
f2
)
&&
_finite
(
fb
);
#endif
if
(
!
found
)
x2
=
b
;
cnt
++
;
...
...
dynare++/sylv/cc/GeneralMatrix.cpp
View file @
a3640239
...
...
@@ -456,11 +456,7 @@ 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
;
}
...
...
dynare++/sylv/cc/Vector.cpp
View file @
a3640239
...
...
@@ -354,11 +354,7 @@ 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
();
}
...
...
dynare++/tl/cc/fine_container.cweb
View file @
a3640239
...
...
@@ -21,11 +21,7 @@ SizeRefinement::SizeRefinement(const IntSequence& s, int nc, int max)
int nr = s[i]/max;
if (s[i] % max != 0)
nr++;
#ifndef _MSC_VER
int ss = (nr>0) ? (int)round(((double)s[i])/nr) : 0;
#else // MSVC doesn't respect C99 standard and doesn't define round(); use floor(x+0.5) instead
int ss = (nr>0) ? (int)floor((((double)s[i])/nr) + 0.5) : 0;
#endif
for (int j = 0; j < nr - 1; j++) {
rsizes.push_back(ss);
ind_map.push_back(i);
...
...
dynare++/tl/cc/sparse_tensor.cweb
View file @
a3640239
...
...
@@ -10,11 +10,6 @@
#include <cmath>
#ifdef _MSC_VER
// For finite()
# include <cfloat>
#endif
@<|SparseTensor::insert| code@>;
@<|SparseTensor::isFinite| code@>;
@<|SparseTensor::getFoldIndexFillFactor| code@>;
...
...
@@ -39,13 +34,8 @@ void SparseTensor::insert(const IntSequence& key, int r, double c)
"Row number out of dimension of tensor in SparseTensor::insert");
TL_RAISE_IF(key.size() != dimen(),
"Wrong length of key in SparseTensor::insert");
#ifndef _MSC_VER
TL_RAISE_IF(! std::isfinite(c),
"Insertion of non-finite value in SparseTensor::insert");
#else
TL_RAISE_IF(! _finite(c),
"Insertion of non-finite value in SparseTensor::insert");
#endif
iterator first_pos = m.lower_bound(key);
@<check that pair |key| and |r| is unique@>;
...
...
@@ -72,11 +62,7 @@ bool SparseTensor::isFinite() const
bool res = true;
const_iterator run = m.begin();
while (res && run != m.end()) {
#ifndef _MSC_VER
if (! std::isfinite((*run).second.second))
#else
if (! _finite((*run).second.second))
#endif
res = false;
++run;
}
...
...
dynare++/utils/cc/exception.h
View file @
a3640239
...
...
@@ -27,13 +27,7 @@ namespace ogu {
strncpy
(
file
,
f
,
file_length
-
1
);
file
[
file_length
-
1
]
=
'\0'
;
line
=
l
;
#ifndef _MSC_VER
strncpy
(
mes
,
m
,
std
::
min
(
mes_length
-
1
,(
int
)
strlen
(
m
)));
#else
/* MSVC doesn't define std::min() (should be in <algorithm>),
but instead has a macro in <windows.h> */
strncpy
(
mes
,
m
,
min
(
mes_length
-
1
,(
int
)
strlen
(
m
)));
#endif
mes
[
mes_length
-
1
]
=
'\0'
;
}
Exception
(
const
char
*
f
,
int
l
,
const
std
::
string
&
m
)
...
...
@@ -41,13 +35,7 @@ namespace ogu {
strncpy
(
file
,
f
,
file_length
-
1
);
file
[
file_length
-
1
]
=
'\0'
;
line
=
l
;
#ifndef _MSC_VER
strncpy
(
mes
,
m
.
c_str
(),
std
::
min
(
mes_length
-
1
,(
int
)
m
.
length
()));
#else
/* MSVC doesn't define std::min() (should be in <algorithm>),
but instead has a macro in <windows.h> */
strncpy
(
mes
,
m
.
c_str
(),
min
(
mes_length
-
1
,(
int
)
m
.
length
()));
#endif
mes
[
mes_length
-
1
]
=
'\0'
;
}
virtual
~
Exception
()
{}
...
...
mex/sources/bytecode/Interpreter.cc
View file @
a3640239
/*
* Copyright (C) 2007-200
9
Dynare Team
* Copyright (C) 2007-20
1
0 Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -17,12 +17,6 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef _MSC_VER
/* In order to get M_PI, M_SQRT2 with Microsoft Visual C++, the following
must be defined before including <cmath> */
# define _USE_MATH_DEFINES
#endif
#include
<cstring>
#include
<sstream>
#include
"Interpreter.hh"
...
...
@@ -1047,15 +1041,10 @@ Interpreter::print_expression(it_code_type it_code, bool evaluate)
Stack
.
push
(
tmp_out
.
str
());
break
;
case
oErf
:
#ifndef _MSC_VER
Stackf
.
push
(
erf
(
v1f
));
tmp_out
.
str
(
""
);
tmp_out
<<
"erf("
<<
v1
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#else
// erf() does not exist in Microsoft Visual C++
mexErrMsgTxt
(
"bytecode: erf() not supported on your platform"
);
#endif
break
;
default:
;
...
...
@@ -1078,15 +1067,10 @@ Interpreter::print_expression(it_code_type it_code, bool evaluate)
switch
(
op
)
{
case
oNormcdf
:
#ifndef _MSC_VER
Stackf
.
push
(
0.5
*
(
1
+
erf
((
v1f
-
v2f
)
/
v3f
/
M_SQRT2
)));
tmp_out
.
str
(
""
);
tmp_out
<<
"normcdf("
<<
v1
<<
", "
<<
v2
<<
", "
<<
v3
<<
")"
;
Stack
.
push
(
tmp_out
.
str
());
#else
// erf() does not exist in Microsoft Visual C++
mexErrMsgTxt
(
"bytecode: normcdf() not supported on your platform"
);
#endif
break
;
case
oNormpdf
:
Stackf
.
push
(
1
/
(
v3f
*
sqrt
(
2
*
M_PI
)
*
exp
(
pow
((
v1f
-
v2f
)
/
v3f
,
2
)
/
2
)));
...
...
@@ -1949,14 +1933,9 @@ Interpreter::compute_block_time(int Per_u_, bool evaluate, int block_num, int si
#endif
break
;
case
oErf
:
#ifndef _MSC_VER
Stack
.
push
(
erf
(
v1
));
#
ifdef DEBUG
#ifdef DEBUG
tmp_out
<<
" |erf("
<<
v1
<<
")|"
;
# endif
#else
// erf() does not exist in Microsoft Visual C++
mexErrMsgTxt
(
"bytecode: erf() not supported on your platform"
);
#endif
break
;
default:
...
...
@@ -1974,14 +1953,9 @@ Interpreter::compute_block_time(int Per_u_, bool evaluate, int block_num, int si
switch
(
op
)
{
case
oNormcdf
:
#ifndef _MSC_VER
Stack
.
push
(
0.5
*
(
1
+
erf
((
v1
-
v2
)
/
v3
/
M_SQRT2
)));
#
ifdef DEBUG
#ifdef DEBUG
tmp_out
<<
" |normcdf("
<<
v1
<<
", "
<<
v2
<<
", "
<<
v3
<<
")|"
;
#endif
#else
// erf() does not exist in Microsoft Visual C++
mexErrMsgTxt
(
"bytecode: normcdf() not supported on your platform"
);
#endif
break
;
case
oNormpdf
:
...
...
mex/sources/bytecode/SparseMatrix.cc
View file @
a3640239
/*
* Copyright (C) 2007-200
9
Dynare Team
* Copyright (C) 2007-20
1
0 Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -25,11 +25,6 @@
#include
<sstream>
#include
"SparseMatrix.hh"
#ifdef _MSC_VER
unsigned
long
_nan
[
2
]
=
{
0xffffffff
,
0x7fffffff
};
double
NAN
=
*
((
double
*
)
_nan
);
#endif
SparseMatrix
::
SparseMatrix
()
{
pivotva
=
NULL
;
...
...
mex/sources/bytecode/SparseMatrix.hh
View file @
a3640239
/*
* Copyright (C) 2007-200
9
Dynare Team
* Copyright (C) 2007-20
1
0 Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -31,55 +31,6 @@
using
namespace
std
;
#ifdef _MSC_VER
# include <limits>
#include
<boost/math/special_functions/erf.hpp>
#define M_SQRT2 1.4142135623730950488016887242097
#define M_PI 3.1415926535897932384626433832795
#define erf(x) boost::math::erf(x)
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
{
short
int
lag
,
operat
;
...
...
preprocessor/CodeInterpreter.hh
View file @
a3640239
...
...
@@ -36,18 +36,7 @@
# 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
#include
<stdint.h>
using
namespace
std
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment