MEX files: drop C++ preprocessor directives now obsolete

Dynare++ is no longer distributed as a standalone binary.
new-samplers
Sébastien Villemot 2023-12-07 17:56:36 +01:00
parent 56289c72d0
commit 91c677ca7f
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
7 changed files with 9 additions and 39 deletions

View File

@ -457,7 +457,8 @@ shared_module('k_order_welfare', k_order_welfare_src, kwargs : korder_mex_kwargs
# Unit tests
k_order_test_kwargs = { 'include_directories' : [ mex_incdir, korder_incdir ],
k_order_test_kwargs = { 'include_directories' : mex_kwargs['include_directories'] + korder_incdir,
'cpp_args' : mex_kwargs['cpp_args'],
'link_args' : exe_link_args,
'build_rpath' : exe_rpath,
'link_with' : korder_lib }

View File

@ -90,12 +90,10 @@ public:
ConstGeneralMatrix(const GeneralMatrix& m, int i, int j, int nrows, int ncols);
// Create submatrix (with data sharing)
ConstGeneralMatrix(const ConstGeneralMatrix& m, int i, int j, int nrows, int ncols);
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
explicit ConstGeneralMatrix(const mxArray* p) :
data(p), rows {static_cast<int>(mxGetM(p))}, cols {static_cast<int>(mxGetN(p))}, ld {rows}
{
}
#endif
virtual ~ConstGeneralMatrix() = default;
ConstGeneralMatrix& operator=(const ConstGeneralMatrix& v) = delete;
@ -234,12 +232,10 @@ public:
// Create submatrix (with data sharing)
GeneralMatrix(GeneralMatrix& m, int i, int j, int nrows, int ncols);
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
explicit GeneralMatrix(mxArray* p) :
data(p), rows {static_cast<int>(mxGetM(p))}, cols {static_cast<int>(mxGetN(p))}, ld {rows}
{
}
#endif
virtual ~GeneralMatrix() = default;
GeneralMatrix& operator=(const GeneralMatrix& m) = default;

View File

@ -125,7 +125,6 @@ SylvParams::getArrayNames() const
return names;
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
mxArray*
SylvParams::DoubleParamItem::createMatlabArray() const
{
@ -136,11 +135,11 @@ mxArray*
SylvParams::IntParamItem::createMatlabArray() const
{
mxArray* res = mxCreateNumericMatrix(1, 1, mxINT32_CLASS, mxREAL);
# if MX_HAS_INTERLEAVED_COMPLEX
#if MX_HAS_INTERLEAVED_COMPLEX
*mxGetInt32s(res) = value;
# else
#else
*static_cast<int*>(mxGetData(res)) = value;
# endif
#endif
return res;
}
@ -225,4 +224,3 @@ SylvParams::createStructArray() const
return res;
}
#endif

View File

@ -25,9 +25,7 @@
#include <string>
#include <vector>
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
# include <dynmex.h>
#endif
#include <dynmex.h>
enum class status
{
@ -111,9 +109,7 @@ protected:
ParamItem<double>::operator=(val);
return *this;
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
[[nodiscard]] mxArray* createMatlabArray() const;
#endif
};
class IntParamItem : public ParamItem<int>
@ -132,9 +128,7 @@ protected:
ParamItem<int>::operator=(val);
return *this;
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
[[nodiscard]] mxArray* createMatlabArray() const;
#endif
};
class BoolParamItem : public ParamItem<bool>
@ -153,9 +147,7 @@ protected:
ParamItem<bool>::operator=(val);
return *this;
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
[[nodiscard]] mxArray* createMatlabArray() const;
#endif
};
class MethodParamItem : public ParamItem<solve_method>
@ -174,9 +166,7 @@ protected:
ParamItem<solve_method>::operator=(val);
return *this;
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
[[nodiscard]] mxArray* createMatlabArray() const;
#endif
};
public:
@ -224,9 +214,8 @@ public:
void print(const std::string& prefix) const;
void print(std::ostream& fdesc, const std::string& prefix) const;
[[nodiscard]] std::vector<const char*> getArrayNames() const;
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
[[nodiscard]] mxArray* createStructArray() const;
#endif
private:
void copy(const SylvParams& p);
};

View File

@ -107,14 +107,12 @@ Vector::Vector(const Vector& v, int off_arg, int skip, int l) : len(l), data {ne
copy(v.data + off_arg * v.s, v.s * skip);
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
Vector::Vector(mxArray* p) :
len {static_cast<int>(mxGetNumberOfElements(p))}, data {mxGetPr(p)}, destroy {false}
{
if (!mxIsDouble(p) || mxIsComplex(p) || mxIsSparse(p))
throw SYLV_MES_EXCEPTION("This is not a dense array of real doubles.");
}
#endif
bool
Vector::operator==(const Vector& y) const
@ -305,14 +303,12 @@ ConstVector::ConstVector(const double* d, int skip, int l) : len {l}, s {skip},
{
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
ConstVector::ConstVector(const mxArray* p) :
len {static_cast<int>(mxGetNumberOfElements(p))}, data {mxGetPr(p)}
{
if (!mxIsDouble(p))
throw SYLV_MES_EXCEPTION("This is not a MATLAB array of doubles.");
}
#endif
bool
ConstVector::operator==(const ConstVector& y) const

View File

@ -28,9 +28,7 @@
#include <complex>
#include <utility>
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
# include <dynmex.h>
#endif
#include <dynmex.h>
class GeneralMatrix;
class ConstVector;
@ -72,9 +70,7 @@ public:
Vector(const Vector& v, int off_arg, int l);
Vector(Vector& v, int off_arg, int skip, int l);
Vector(const Vector& v, int off_arg, int skip, int l);
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
explicit Vector(mxArray* p);
#endif
Vector& operator=(const Vector& v);
/* The move-assignment operator is not implemented, because moving pointers
across class instances would break the reference semantics that the
@ -198,9 +194,7 @@ public:
ConstVector(const ConstVector& v, int off_arg, int l);
ConstVector(const ConstVector& v, int off_arg, int skip, int l);
ConstVector(const double* d, int skip, int l);
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
explicit ConstVector(const mxArray* p);
#endif
virtual ~ConstVector() = default;
ConstVector& operator=(const ConstVector& v) = delete;
ConstVector& operator=(ConstVector&& v) = delete;

View File

@ -1,6 +1,6 @@
/*
* Copyright © 2004-2011 Ondra Kamenik
* Copyright © 2019 Dynare Team
* Copyright © 2019-2023 Dynare Team
*
* This file is part of Dynare.
*
@ -63,11 +63,9 @@ public:
ConstGeneralMatrix(m, first_row, first_col, rows, cols)
{
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
explicit ConstTwoDMatrix(const mxArray* p) : ConstGeneralMatrix(p)
{
}
#endif
~ConstTwoDMatrix() override = default;
ConstTwoDMatrix& operator=(const ConstTwoDMatrix& v) = delete;
@ -125,11 +123,9 @@ public:
{
}
#if defined(MATLAB_MEX_FILE) || defined(OCTAVE_MEX_FILE)
explicit TwoDMatrix(mxArray* p) : GeneralMatrix(p)
{
}
#endif
~TwoDMatrix() override = default;
TwoDMatrix& operator=(const TwoDMatrix& m) = default;