Skip to content

Commit

Permalink
added CMAKE-check for existence of _j0 or j0, should fix issue #124
Browse files Browse the repository at this point in the history
  • Loading branch information
jkriege2 committed Mar 12, 2024
1 parent ffb33a5 commit b2b275f
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 91 deletions.
9 changes: 9 additions & 0 deletions cmake/jkqtplotter_common_compilersettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ math(EXPR JKQtPlotter_BIT_DEPTH ${CMAKE_SIZEOF_VOID_P}*8)

find_package( CImg QUIET )
find_package( OpenCV QUIET )

include(CheckFunctionExists)

set(CMAKE_REQUIRED_INCLUDES "cmath")
CHECK_FUNCTION_EXISTS(j0 JKQtPlotter_HAS_j0)
CHECK_FUNCTION_EXISTS(_j0 JKQtPlotter_HAS__j0)
CHECK_FUNCTION_EXISTS(y0 JKQtPlotter_HAS_y0)
CHECK_FUNCTION_EXISTS(_y0 JKQtPlotter_HAS__y0)
CHECK_FUNCTION_EXISTS(__y0 JKQtPlotter_HAS___y0)
13 changes: 13 additions & 0 deletions cmake/jkqtplotter_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ function(jkqtplotter_setDefaultLibOptions TARGETNAME libBaseName PRECOMPHEADERFI
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
endif()

if(JKQtPlotter_HAS_j0)
target_compile_definitions(${TARGETNAME} PUBLIC JKQtPlotter_HAS_j0)
endif()
if(JKQtPlotter_HAS__j0)
target_compile_definitions(${TARGETNAME} PUBLIC JKQtPlotter_HAS__j0)
endif()
if(JKQtPlotter_HAS_y0)
target_compile_definitions(${TARGETNAME} PUBLIC JKQtPlotter_HAS_y0)
endif()
if(JKQtPlotter_HAS__y0)
target_compile_definitions(${TARGETNAME} PUBLIC JKQtPlotter_HAS__y0)
endif()

# enable TIMING INFO output (if activated by option JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT)
if(JKQtPlotter_BUILD_WITH_TIMING_INFO_OUTPUT)
target_compile_definitions(${TARGETNAME} PRIVATE JKQTBP_AUTOTIMER)
Expand Down
124 changes: 66 additions & 58 deletions lib/jkqtcommon/jkqtpmathtools.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,77 +391,85 @@ inline T jkqtp_inversePropSaveDefault(const T& v) {
return jkqtp_inversePropSave<T>(v, std::numeric_limits<T>::epsilon()*100.0);
}

/*! \brief j0() function (without compiler issues)
\ingroup jkqtptools_math_basic
#if defined(JKQtPlotter_HAS_j0) || defined(JKQtPlotter_HAS__j0)

*/
inline double jkqtp_j0(double x) {
#if Q_CC_MSVC
return _j0(x);
#else
return j0(x);
#endif
}
/*! \brief j0() function (without compiler issues)
\ingroup jkqtptools_math_basic
/*! \brief j1() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_j0(double x) {
#ifdef JKQtPlotter_HAS__j0
return _j0(x);
#elif defined(JKQtPlotter_HAS_j0)
return j0(x);
#endif
}

*/
inline double jkqtp_j1(double x) {
#if Q_CC_MSVC
return _j1(x);
#else
return j1(x);
#endif
}
/*! \brief j1() function (without compiler issues)
\ingroup jkqtptools_math_basic
/*! \brief y0() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_j1(double x) {
#ifdef JKQtPlotter_HAS__j0
return _j1(x);
#elif defined(JKQtPlotter_HAS_j0)
return j1(x);
#endif
}

*/
inline double jkqtp_y0(double x) {
#if Q_CC_MSVC
return _y0(x);
#else
return y0(x);
/*! \brief jn() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_jn(int n, double x) {
#ifdef JKQtPlotter_HAS__j0
return _jn(n,x);
#elif defined(JKQtPlotter_HAS_j0)
return jn(n,x);
#endif
}
#endif
}

/*! \brief y1() function (without compiler issues)
\ingroup jkqtptools_math_basic

*/
inline double jkqtp_y1(double x) {
#if Q_CC_MSVC
return _y1(x);
#else
return y1(x);
#endif
}
#if defined(JKQtPlotter_HAS_y0) || defined(JKQtPlotter_HAS__y0)
/*! \brief y0() function (without compiler issues)
\ingroup jkqtptools_math_basic
/*! \brief jn() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_y0(double x) {
#ifdef JKQtPlotter_HAS__y0
return _y0(x);
#elif defined(JKQtPlotter_HAS_y0)
return y0(x);
#endif
}

*/
inline double jkqtp_jn(int n, double x) {
#if Q_CC_MSVC
return _jn(n,x);
#else
return jn(n,x);
#endif
}
/*! \brief y1() function (without compiler issues)
\ingroup jkqtptools_math_basic
/*! \brief yn() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_y1(double x) {
#ifdef JKQtPlotter_HAS__y0
return _y1(x);
#elif defined(JKQtPlotter_HAS_y0)
return y1(x);
#endif
}

*/
inline double jkqtp_yn(int n, double x) {
#if Q_CC_MSVC
return _yn(n,x);
#else
return yn(n,x);

/*! \brief yn() function (without compiler issues)
\ingroup jkqtptools_math_basic
*/
inline double jkqtp_yn(int n, double x) {
#ifdef JKQtPlotter_HAS__y0
return _yn(n,x);
#elif defined(JKQtPlotter_HAS_y0)
return yn(n,x);
#endif
}
#endif
}


/** \brief calculate the distance between two QPointF points
* \ingroup jkqtptools_math_basic
Expand Down
73 changes: 40 additions & 33 deletions lib/jkqtmath/jkqtpmathparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,13 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
return r;
}

#if defined(JKQtPlotter_HAS_j0) || defined(JKQtPlotter_HAS__j0)
JKQTPMathParser::jkmpResult fJ0(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){
JKQTPMathParser::jkmpResult r;
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("j0 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j0 needs double argument");
#if Q_CC_MSVC
r.num = _j0(params[0].num);
#else
r.num = j0(params[0].num);
#endif
r.num = jkqtp_j0(params[0].num);
return r;
}

Expand All @@ -342,23 +339,41 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("j1 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("j1 needs double argument");
#if Q_CC_MSVC
r.num=_j1(params[0].num);
#else
r.num=j1(params[0].num);
#ifdef JKQtPlotter_HAS_j0
r.num = j1(params[0].num);
#elif defined(JKQtPlotter_HAS__j0)
r.num = _j1(params[0].num);
#endif
return r;
}

JKQTPMathParser::jkmpResult fJn(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){
JKQTPMathParser::jkmpResult r;
r.type=JKQTPMathParser::jkmpDouble;
if (n!=2) p->jkmpError("jn accepts 2 argument");
if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("jn needs double argument");
#ifdef JKQtPlotter_HAS_j0
r.num=_jn(static_cast<int>(params[0].num), params[1].num);
#elif defined(JKQtPlotter_HAS__j0)
r.num=jn(static_cast<int>(params[0].num), params[1].num);
#endif
return r;
}

#endif



#if defined(JKQtPlotter_HAS_y0) || defined(JKQtPlotter_HAS__y0)
JKQTPMathParser::jkmpResult fY0(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){
JKQTPMathParser::jkmpResult r;
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("y0 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y0 needs double argument");
#if Q_CC_MSVC
r.num=_y0(params[0].num);
#else
r.num=y0(params[0].num);
#ifdef JKQtPlotter_HAS_y0
r.num = y0(params[0].num);
#elif defined(JKQtPlotter_HAS__y0)
r.num = _y0(params[0].num);
#endif
return r;
}
Expand All @@ -368,10 +383,10 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=1) p->jkmpError("y1 accepts 1 argument");
if (params[0].type!=JKQTPMathParser::jkmpDouble) p->jkmpError("y1 needs double argument");
#if Q_CC_MSVC
r.num=_y1(params[0].num);
#else
r.num=y1(params[0].num);
#ifdef JKQtPlotter_HAS_y0
r.num = y1(params[0].num);
#elif defined(JKQtPlotter_HAS__y0)
r.num = _y1(params[0].num);
#endif
return r;
}
Expand All @@ -381,26 +396,14 @@ namespace { // anonymous namespace to limit availability to this module (CPP-fil
r.type=JKQTPMathParser::jkmpDouble;
if (n!=2) p->jkmpError("yn accepts 2 argument");
if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("yn needs double argument");
#if Q_CC_MSVC
r.num=_yn(static_cast<int>(params[0].num), params[1].num);
#else
r.num=yn(static_cast<int>(params[0].num), params[1].num);
#ifdef JKQtPlotter_HAS_y0
r.num=_yn(static_cast<int>(params[0].num), params[1].num);
#elif defined(JKQtPlotter_HAS__y0)
r.num=yn(static_cast<int>(params[0].num), params[1].num);
#endif
return r;
}

JKQTPMathParser::jkmpResult fJn(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){
JKQTPMathParser::jkmpResult r;
r.type=JKQTPMathParser::jkmpDouble;
if (n!=2) p->jkmpError("jn accepts 2 argument");
if ((params[0].type!=JKQTPMathParser::jkmpDouble)||(params[1].type!=JKQTPMathParser::jkmpDouble)) p->jkmpError("jn needs double argument");
#if Q_CC_MSVC
r.num=_jn(static_cast<int>(params[0].num), params[1].num);
#else
r.num=jn(static_cast<int>(params[0].num), params[1].num);
#endif
return r;
}

JKQTPMathParser::jkmpResult fSRand(JKQTPMathParser::jkmpResult* params, unsigned char n, JKQTPMathParser* p){
JKQTPMathParser::jkmpResult r;
Expand Down Expand Up @@ -700,12 +703,16 @@ void JKQTPMathParser::addStandardFunctions(){
addFunction("erfc", fErfc);
addFunction("lgamma", flGamma);
addFunction("tgamma", ftGamma);
#if defined(JKQtPlotter_HAS_j0) || defined(JKQtPlotter_HAS__j0)
addFunction("j0", fJ0);
addFunction("j1", fJ1);
addFunction("jn", fJn);
#endif
#if defined(JKQtPlotter_HAS_y0) || defined(JKQtPlotter_HAS__y0)
addFunction("y0", fY0);
addFunction("y1", fY1);
addFunction("yn", fYn);
#endif
addFunction("rand", fRand);
addFunction("srand", fSRand);
addFunction("ceil", fCeil);
Expand Down

0 comments on commit b2b275f

Please sign in to comment.