erf / erfc (error function / complementary error function)
Hi,
I'm trying to use erfc in my app.
I used it successfully in CodeBlocks using math.h, but it looks like neither math.h or cmath or QtCore/qmath.h have got erfc in Qt.
Is there a way to use this function on Qt or a way to use the math.h I have for CodeBlocks in Qt?
Thanks in advance.
Re: erf / erfc (error function / complementary error function)
Both erf() and erfc() are C-standard (not Qt-standard) functions. Include math.h, math.h should be on the standard INCLUDE path. If it is not, search math.h by your file manager, you should be successful. As to Linux, glibc knows both erf() and erfc().
Re: erf / erfc (error function / complementary error function)
Quote:
Originally Posted by
Radek
math.h should be on the standard INCLUDE path. If it is not, search math.h by your file manager, you should be successful.
It is on the standard path, and so is cmath.h.
I found math.h inside the mingw folder, which is inside the Tools folder.
I tried including the path all the way to math.h, like this
<../../Tools/mingw491_32/i686-w64-mingw32/include/c++/tr1/math.h>
<../../Qt/Tools/mingw491_32/i686-w64-mingw32/include/c++/tr1/math.h>
<C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/c++/tr1/math.h>
but had no success.
I'm gonna try to set mingw as the compiler.
Edited: I have also tried to add
INCLUDEPATH += <C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/c++/tr1/math.h>
to my .pro, but no success.
Re: erf / erfc (error function / complementary error function)
What actually is the error you are getting?
Cheers,
_
Re: erf / erfc (error function / complementary error function)
Quote:
Originally Posted by
anda_skoa
What actually is the error you are getting?
'erfc': identifier not found
Re: erf / erfc (error function / complementary error function)
And you are including math.h in that source file?
What about other functions from math.h? Say sin()?
Cheers,
_
Re: erf / erfc (error function / complementary error function)
I'm currently including QtCore/qmath.h, which has sin and exp (I'm also using exp in my app).
I tried replacing it with math.h, and it recognizes sin and exp, but not erfc.
Re: erf / erfc (error function / complementary error function)
#include <math.h> should suffice. If you suspect your standard C libraries (or the math.h header file) being somehow strange, remove #include <math.h> and add in the files containing erf() or erfc():
Code:
extern "C"
{
double erf( double x);
double erfc( double x);
}
If the code does not link (undefined externals) then your C libraries do not know erf() and erfc(). Change the compiler (and the libraries) because the libraries are too obsolete. erf() and erfc() are C-standard since C99.
Re: erf / erfc (error function / complementary error function)
I'm gonna have to change the compiler, the other things did not work.
I'm currently using the MSVC2012 compiler, which came with Qt for windows.
I found mingw in my Qt/Tools folder, which has math.h with erf and erfc, that's why I tried to include it. The only math.h files in my Qt folder are inside mingw.
Thanks
Re: erf / erfc (error function / complementary error function)
You are headed for big trouble if you are trying to use headers from mingw in programs you are compiling with MSVC. Like mixing fire and gasoline.
Quote:
MSVC2012 compiler, which came with Qt for windows.
Really? I'd like to know when Microsoft jumped onto the Qt wagon. And I'd like to know where you downloaded that Qt version. I'd sure like to save the thousands of dollars I give M$ every year for my MSVC updates.
In Visual Studio 9 (VS 2008), math.h and cmath do not contain declarations for erf() / erfc(). In Visual Studio 12 (VS 2013), math.h and cmath do contain these functions, so the runtime libraries must also. I don't know about VS 2012 - I do not have that installed.
But Google is your friend.
Re: erf / erfc (error function / complementary error function)
Not declared in the 2012 compiler headers:
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
The Boost Math tool kit contains implementations of those functions but may be overkill