Results 1 to 11 of 11

Thread: erf / erfc (error function / complementary error function)

  1. #1
    Join Date
    Jan 2015
    Posts
    22
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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.

  2. #2
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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().

  3. #3
    Join Date
    Jan 2015
    Posts
    22
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: erf / erfc (error function / complementary error function)

    Quote Originally Posted by Radek View Post
    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.
    Last edited by guiismiti; 3rd February 2015 at 14:15.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: erf / erfc (error function / complementary error function)

    What actually is the error you are getting?

    Cheers,
    _

  5. #5
    Join Date
    Jan 2015
    Posts
    22
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: erf / erfc (error function / complementary error function)

    Quote Originally Posted by anda_skoa View Post
    What actually is the error you are getting?
    'erfc': identifier not found

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  7. #7
    Join Date
    Jan 2015
    Posts
    22
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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.

  8. #8
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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():
    Qt Code:
    1. extern "C"
    2. {
    3. double erf( double x);
    4. double erfc( double x);
    5. }
    To copy to clipboard, switch view to plain text mode 
    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.

  9. The following user says thank you to Radek for this useful post:

    guiismiti (3rd February 2015)

  10. #9
    Join Date
    Jan 2015
    Posts
    22
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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

  11. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

    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.

  12. The following user says thank you to d_stranz for this useful post:

    guiismiti (3rd February 2015)

  13. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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

  14. The following user says thank you to ChrisW67 for this useful post:

    guiismiti (3rd February 2015)

Similar Threads

  1. C++ need help with GDI plus function - error
    By Cplusplus in forum General Programming
    Replies: 0
    Last Post: 3rd May 2014, 16:02
  2. Replies: 2
    Last Post: 19th August 2013, 08:51
  3. QWaitCondition function wait() error
    By freekill in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2010, 01:54
  4. Replies: 0
    Last Post: 4th November 2009, 10:21
  5. no matching function error
    By arpspatel in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2009, 15:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.