Bytecode: remove MSVC++ specific portions
parent
f9f50ff19a
commit
5ef440ad9b
|
@ -50,103 +50,6 @@
|
|||
# define CHAR_LENGTH 2
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <limits>
|
||||
# define M_E 2.71828182845904523536
|
||||
# define M_LOG2E 1.44269504088896340736
|
||||
# define M_LOG10E 0.434294481903251827651
|
||||
# define M_LN2 0.693147180559945309417
|
||||
# define M_LN10 2.30258509299404568402
|
||||
# define M_PI 3.14159265358979323846
|
||||
# define M_PI_2 1.57079632679489661923
|
||||
# define M_PI_4 0.785398163397448309616
|
||||
# define M_1_PI 0.318309886183790671538
|
||||
# define M_2_PI 0.636619772367581343076
|
||||
# define M_1_SQRTPI 0.564189583547756286948
|
||||
# define M_2_SQRTPI 1.12837916709551257390
|
||||
# define M_SQRT2 1.41421356237309504880
|
||||
# define M_SQRT_2 0.707106781186547524401
|
||||
# define NAN numeric_limits<double>::quiet_NaN()
|
||||
|
||||
# define isnan(x) _isnan(x)
|
||||
# define isinf(x) (!_finite(x))
|
||||
# define fpu_error(x) (isinf(x) || isnan(x))
|
||||
|
||||
# define finite(x) _finite(x)
|
||||
|
||||
class MSVCpp_missings
|
||||
{
|
||||
public:
|
||||
inline double
|
||||
asinh(double x) const
|
||||
{
|
||||
if (x == 0.0)
|
||||
return 0.0;
|
||||
double ax = abs(x);
|
||||
return log(x+ax*sqrt(1.+1./(ax*ax)));
|
||||
}
|
||||
|
||||
inline double
|
||||
acosh(double x) const
|
||||
{
|
||||
if (x == 0.0)
|
||||
return 0.0;
|
||||
double ax = abs(x);
|
||||
return log(x+ax*sqrt(1.-1./(ax*ax)));
|
||||
}
|
||||
|
||||
inline double
|
||||
atanh(double x) const
|
||||
{
|
||||
return log((1+x)/(1-x))/2;
|
||||
}
|
||||
|
||||
inline double
|
||||
erf(double x) const
|
||||
{
|
||||
const double a1 = -1.26551223, a2 = 1.00002368,
|
||||
a3 = 0.37409196, a4 = 0.09678418,
|
||||
a5 = -0.18628806, a6 = 0.27886807,
|
||||
a7 = -1.13520398, a8 = 1.48851587,
|
||||
a9 = -0.82215223, a10 = 0.17087277;
|
||||
double v = 1;
|
||||
double z = abs(x);
|
||||
if (z <= 0)
|
||||
return v;
|
||||
double t = 1 / (1 + 0.5 * z);
|
||||
v = t*exp((-z*z) +a1+t*(a2+t*(a3+t*(a4+t*(a5+t*(a6+t*(a7+t*(a8+t*(a9+t*a10)))))))));
|
||||
if (x < 0)
|
||||
v = 2 - v;
|
||||
return 1 - v;
|
||||
}
|
||||
|
||||
inline double
|
||||
nearbyint(double x) const
|
||||
{
|
||||
return floor(x + 0.5);
|
||||
}
|
||||
|
||||
inline double
|
||||
fmax(double x, double y) const
|
||||
{
|
||||
if (x > y)
|
||||
return x;
|
||||
else
|
||||
return y;
|
||||
}
|
||||
|
||||
inline double
|
||||
fmin(double x, double y) const
|
||||
{
|
||||
if (x < y)
|
||||
return x;
|
||||
else
|
||||
return y;
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
//#define DEBUG
|
||||
using namespace std;
|
||||
|
||||
|
@ -160,12 +63,6 @@ class GeneralExceptionHandling
|
|||
{
|
||||
string ErrorMsg;
|
||||
public:
|
||||
#ifdef _MSC_VER
|
||||
~GeneralExceptionHandling()
|
||||
{
|
||||
FreeLibrary(hinstLib);
|
||||
};
|
||||
#endif
|
||||
GeneralExceptionHandling(string ErrorMsg_arg) : ErrorMsg{move(ErrorMsg_arg)}
|
||||
{
|
||||
};
|
||||
|
@ -288,11 +185,7 @@ using table_conditional_global_type = map<int, vector_table_conditional_local_ty
|
|||
extern "C" bool utIsInterruptPending();
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
class ErrorMsg : public MSVCpp_missings
|
||||
#else
|
||||
class ErrorMsg
|
||||
#endif
|
||||
{
|
||||
private:
|
||||
bool is_load_variable_list;
|
||||
|
|
|
@ -32,59 +32,6 @@
|
|||
#endif
|
||||
|
||||
using namespace std;
|
||||
#ifdef _MSC_VER
|
||||
# include <windows.h>
|
||||
HINSTANCE hinstLib;
|
||||
|
||||
# define UMFPACK_INFO 90
|
||||
# define UMFPACK_CONTROL 20
|
||||
/* used in all UMFPACK_report_* routines: */
|
||||
# define UMFPACK_PRL 0 /* print level */
|
||||
/* returned by all routines that use Info: */
|
||||
# define UMFPACK_OK (0)
|
||||
# define UMFPACK_STATUS 0 /* UMFPACK_OK, or other result */
|
||||
|
||||
typedef void (*t_umfpack_dl_free_numeric)(void **Numeric);
|
||||
t_umfpack_dl_free_numeric umfpack_dl_free_numeric;
|
||||
typedef void (*t_umfpack_dl_free_symbolic)(void **Symbolic);
|
||||
t_umfpack_dl_free_symbolic umfpack_dl_free_symbolic;
|
||||
typedef int64_t (*t_umfpack_dl_solve)(int64_t sys,
|
||||
const int64_t Ap[],
|
||||
const int64_t Ai[],
|
||||
const double Ax[],
|
||||
double X[],
|
||||
const double B[],
|
||||
void *Numeric,
|
||||
const double Control[UMFPACK_CONTROL],
|
||||
double Info[UMFPACK_INFO]);
|
||||
t_umfpack_dl_solve umfpack_dl_solve;
|
||||
typedef int64_t (*t_umfpack_dl_numeric)(const int64_t Ap[],
|
||||
const int64_t Ai[],
|
||||
const double Ax[],
|
||||
void *Symbolic,
|
||||
void **Numeric,
|
||||
const double Control[UMFPACK_CONTROL],
|
||||
double Info[UMFPACK_INFO]);
|
||||
t_umfpack_dl_numeric umfpack_dl_numeric;
|
||||
typedef int64_t (*t_umfpack_dl_symbolic)(int64_t n_row,
|
||||
int64_t n_col,
|
||||
const int64_t Ap[],
|
||||
const int64_t Ai[],
|
||||
const double Ax[],
|
||||
void **Symbolic,
|
||||
const double Control[UMFPACK_CONTROL],
|
||||
double Info[UMFPACK_INFO]);
|
||||
t_umfpack_dl_symbolic umfpack_dl_symbolic;
|
||||
typedef void (*t_umfpack_dl_report_info)(const double Control[UMFPACK_CONTROL],
|
||||
const double Info[UMFPACK_INFO]);
|
||||
t_umfpack_dl_report_info umfpack_dl_report_info;
|
||||
typedef void (*t_umfpack_dl_report_status)(const double Control[UMFPACK_CONTROL],
|
||||
int64_t status);
|
||||
t_umfpack_dl_report_status umfpack_dl_report_status;
|
||||
typedef void (*t_umfpack_dl_defaults)(double Control[UMFPACK_CONTROL]);
|
||||
t_umfpack_dl_defaults umfpack_dl_defaults;
|
||||
|
||||
#endif
|
||||
|
||||
dynSparseMatrix::dynSparseMatrix()
|
||||
{
|
||||
|
@ -105,78 +52,6 @@ dynSparseMatrix::dynSparseMatrix()
|
|||
lu_inc_tol = 1e-10;
|
||||
Symbolic = nullptr;
|
||||
Numeric = nullptr;
|
||||
#ifdef _MSC_VER
|
||||
// Get a handle to the DLL module.
|
||||
hinstLib = LoadLibrary(TEXT("libmwumfpack.dll"));
|
||||
// If the handle is valid, try to get the function address.
|
||||
if (hinstLib)
|
||||
{
|
||||
umfpack_dl_free_numeric = (t_umfpack_dl_free_numeric) GetProcAddress(hinstLib, "umfpack_dl_free_numeric");
|
||||
if (!umfpack_dl_free_numeric)
|
||||
{
|
||||
mexPrintf("umfpack_dl_free_numeric not found\n");
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_free_numeric is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_free_symbolic = (t_umfpack_dl_free_symbolic) GetProcAddress(hinstLib, "umfpack_dl_free_symbolic");
|
||||
if (!umfpack_dl_free_symbolic)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_free_symbolic is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_solve = (t_umfpack_dl_solve) GetProcAddress(hinstLib, "umfpack_dl_free_solve");
|
||||
if (!umfpack_dl_solve)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_solve is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_numeric = (t_umfpack_dl_numeric) GetProcAddress(hinstLib, "umfpack_dl_numeric");
|
||||
if (!umfpack_dl_numeric)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_numeric is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_symbolic = (t_umfpack_dl_symbolic) GetProcAddress(hinstLib, "umfpack_dl_symbolic");
|
||||
if (!umfpack_dl_symbolic)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_symbolic is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_report_info = (t_umfpack_dl_report_info) GetProcAddress(hinstLib, "umfpack_dl_report_info");
|
||||
if (!umfpack_dl_report_info)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_report_info is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_report_status = (t_umfpack_dl_report_status) GetProcAddress(hinstLib, "umfpack_dl_report_status");
|
||||
if (!umfpack_dl_report_status)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_report_status is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_defaults = (t_umfpack_dl_defaults) GetProcAddress(hinstLib, "umfpack_dl_defaults");
|
||||
if (!umfpack_dl_defaults)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_defaults is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mexPrintf("library loading error\n");
|
||||
ostringstream tmp;
|
||||
tmp << " in main, libmwumfpack.dll not found. \n Check that \\Program files\\MATLAB\\RXXXXX\\bin\\win64 is in the current path.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
dynSparseMatrix::dynSparseMatrix(const int y_size_arg, const int y_kmin_arg, const int y_kmax_arg, const bool print_it_arg, const bool steady_state_arg, const int periods_arg,
|
||||
|
@ -210,77 +85,6 @@ dynSparseMatrix::dynSparseMatrix(const int y_size_arg, const int y_kmin_arg, con
|
|||
cusparse_handle = cusparse_handle_arg;
|
||||
CUDA_descr = descr_arg;
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
// Get a handle to the DLL module.
|
||||
hinstLib = LoadLibrary(TEXT("libmwumfpack.dll"));
|
||||
// If the handle is valid, try to get the function address.
|
||||
if (hinstLib != NULL)
|
||||
{
|
||||
umfpack_dl_free_numeric = (t_umfpack_dl_free_numeric) GetProcAddress(hinstLib, "umfpack_dl_free_numeric");
|
||||
if (!umfpack_dl_free_numeric)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_free_numeric is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_free_symbolic = (t_umfpack_dl_free_symbolic) GetProcAddress(hinstLib, "umfpack_dl_free_symbolic");
|
||||
if (!umfpack_dl_free_symbolic)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_free_symbolic is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_report_info = (t_umfpack_dl_report_info) GetProcAddress(hinstLib, "umfpack_dl_report_info");
|
||||
if (!umfpack_dl_report_info)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_report_info is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_solve = (t_umfpack_dl_solve) GetProcAddress(hinstLib, "umfpack_dl_solve");
|
||||
if (!umfpack_dl_solve)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_solve is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_numeric = (t_umfpack_dl_numeric) GetProcAddress(hinstLib, "umfpack_dl_numeric");
|
||||
if (!umfpack_dl_numeric)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_numeric is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_symbolic = (t_umfpack_dl_symbolic) GetProcAddress(hinstLib, "umfpack_dl_symbolic");
|
||||
if (!umfpack_dl_symbolic)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_symbolic is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_report_status = (t_umfpack_dl_report_status) GetProcAddress(hinstLib, "umfpack_dl_report_status");
|
||||
if (!umfpack_dl_report_status)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_report_status is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
umfpack_dl_defaults = (t_umfpack_dl_defaults) GetProcAddress(hinstLib, "umfpack_dl_defaults");
|
||||
if (!umfpack_dl_defaults)
|
||||
{
|
||||
ostringstream tmp;
|
||||
tmp << " in libmwumfpack.dll, the function umfpack_dl_defaults is not found.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mexPrintf("library loading error\n");
|
||||
ostringstream tmp;
|
||||
tmp << " in main, libmwumfpack.dll not found. \n Check that \\Program files\\MATLAB\\RXXXXX\\bin\\win64 in the current path.";
|
||||
throw FatalExceptionHandling(tmp.str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -3332,17 +3136,7 @@ void
|
|||
dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, double *Ax, double *b, int n, int Size, double slowc_l, bool is_two_boundaries, int it_, vector_table_conditional_local_type vector_table_conditional_local)
|
||||
{
|
||||
SuiteSparse_long status, sys = 0;
|
||||
#ifndef _MSC_VER
|
||||
double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO], res[n];
|
||||
#else
|
||||
double *Control, *Info, *res;
|
||||
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
||||
test_mxMalloc(Control, __LINE__, __FILE__, __func__, UMFPACK_CONTROL * sizeof(double));
|
||||
Info = (double *) mxMalloc(UMFPACK_INFO * sizeof(double));
|
||||
test_mxMalloc(Info, __LINE__, __FILE__, __func__, UMFPACK_INFO * sizeof(double));
|
||||
res = (double *) mxMalloc(n * sizeof(double));
|
||||
test_mxMalloc(res, __LINE__, __FILE__, __func__, n * sizeof(double));
|
||||
#endif
|
||||
|
||||
umfpack_dl_defaults(Control);
|
||||
Control[UMFPACK_PRL] = 5;
|
||||
|
@ -3449,28 +3243,13 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
|
|||
mxFree(Ai);
|
||||
mxFree(Ax);
|
||||
mxFree(b);
|
||||
#ifdef _MSC_VER
|
||||
mxFree(Control);
|
||||
mxFree(Info);
|
||||
mxFree(res);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, double *Ax, double *b, int n, int Size, double slowc_l, bool is_two_boundaries, int it_)
|
||||
{
|
||||
SuiteSparse_long status, sys = 0;
|
||||
#ifndef _MSC_VER
|
||||
double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO], res[n];
|
||||
#else
|
||||
double *Control, *Info, *res;
|
||||
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
||||
test_mxMalloc(Control, __LINE__, __FILE__, __func__, UMFPACK_CONTROL * sizeof(double));
|
||||
Info = (double *) mxMalloc(UMFPACK_INFO * sizeof(double));
|
||||
test_mxMalloc(Info, __LINE__, __FILE__, __func__, UMFPACK_INFO * sizeof(double));
|
||||
res = (double *) mxMalloc(n * sizeof(double));
|
||||
test_mxMalloc(res, __LINE__, __FILE__, __func__, n * sizeof(double));
|
||||
#endif
|
||||
|
||||
umfpack_dl_defaults(Control);
|
||||
Control[UMFPACK_PRL] = 5;
|
||||
|
@ -3528,11 +3307,6 @@ dynSparseMatrix::Solve_LU_UMFPack(SuiteSparse_long *Ap, SuiteSparse_long *Ai, do
|
|||
mxFree(Ai);
|
||||
mxFree(Ax);
|
||||
mxFree(b);
|
||||
#ifdef _MSC_VER
|
||||
mxFree(Control);
|
||||
mxFree(Info);
|
||||
mxFree(res);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3546,17 +3320,7 @@ dynSparseMatrix::Solve_LU_UMFPack(mxArray *A_m, mxArray *b_m, int Size, double s
|
|||
double *Ax = mxGetPr(A_m);
|
||||
double *B = mxGetPr(b_m);
|
||||
SuiteSparse_long status, sys = 0;
|
||||
#ifndef _MSC_VER
|
||||
double Control[UMFPACK_CONTROL], Info[UMFPACK_INFO], res[n];
|
||||
#else
|
||||
double *Control, *Info, *res;
|
||||
Control = (double *) mxMalloc(UMFPACK_CONTROL * sizeof(double));
|
||||
test_mxMalloc(Control, __LINE__, __FILE__, __func__, UMFPACK_CONTROL * sizeof(double));
|
||||
Info = (double *) mxMalloc(UMFPACK_INFO * sizeof(double));
|
||||
test_mxMalloc(Info, __LINE__, __FILE__, __func__, UMFPACK_INFO * sizeof(double));
|
||||
res = (double *) mxMalloc(n * sizeof(double));
|
||||
test_mxMalloc(res, __LINE__, __FILE__, __func__, n * sizeof(double));
|
||||
#endif
|
||||
void *Symbolic, *Numeric;
|
||||
umfpack_dl_defaults(Control);
|
||||
|
||||
|
@ -3590,12 +3354,6 @@ dynSparseMatrix::Solve_LU_UMFPack(mxArray *A_m, mxArray *b_m, int Size, double s
|
|||
}
|
||||
mxDestroyArray(A_m);
|
||||
mxDestroyArray(b_m);
|
||||
#ifdef _MSC_VER
|
||||
mxFree(Control);
|
||||
mxFree(Info);
|
||||
mxFree(res);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef CUDA
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2007-2017 Dynare Team
|
||||
* Copyright © 2007-2021 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -26,9 +26,7 @@
|
|||
#include <map>
|
||||
#include <ctime>
|
||||
#include "dynblas.h"
|
||||
#if !(defined _MSC_VER)
|
||||
# include "dynumfpack.h"
|
||||
#endif
|
||||
#include "dynumfpack.h"
|
||||
|
||||
#ifdef CUDA
|
||||
# include "cuda.h"
|
||||
|
@ -102,9 +100,6 @@ const double mem_increasing_factor = 1.1;
|
|||
class dynSparseMatrix : public Evaluate
|
||||
{
|
||||
public:
|
||||
#if (defined _MSC_VER)
|
||||
typedef int64_t SuiteSparse_long;
|
||||
#endif
|
||||
dynSparseMatrix();
|
||||
dynSparseMatrix(const int y_size_arg, const int y_kmin_arg, const int y_kmax_arg, const bool print_it_arg, const bool steady_state_arg, const int periods_arg, const int minimal_solving_periods_arg, const double slowc_arg
|
||||
#ifdef CUDA
|
||||
|
|
|
@ -1224,8 +1224,5 @@ main(int nrhs, const char *prhs[])
|
|||
mxFree(ya);
|
||||
if (direction)
|
||||
mxFree(direction);
|
||||
#ifdef _MSC_VER_
|
||||
/*fFreeResult =*/ FreeLibrary(hinstLib);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue