Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

erf function on Windows

Scheibe__Patrick
New Contributor I
612 Views
Hi,
what is the right way to use erf and erfc on a windows box with the Intel compiler?
My code is running fine on Linux but on windows it complains about these special
functions.
I searched the forum and scanned through mathimf.h and tgmath.h without success.
I don't see the reason why it's not included for Windows as well.
Is there a short solution and maybe an explanation?
Cheers
Patrick
0 Kudos
4 Replies
Om_S_Intel
Employee
612 Views

You need to include mathimf.h header to use these function using Intel compiler.

// testcase.cpp
#include

#include

double smallx, largex, value;

int main(void)

{

smallx = 0.1;

largex = 10.0;

value = erf(smallx); /* value = 0.112463 */

printf("Error value for 0.1: %lf\n", value);

value = erfc(largex); /* value = 2.088488e-45 */

printf("Error value for 10.0: %le\n", value);

}

c:\>icl testcase.cpp

Intel C++ Compiler XE for applications running on IA-32, Version 12.0.1.127 B

uild 20101116

Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

testcase.cpp

Microsoft Incremental Linker Version 10.00.30319.01

Copyright (C) Microsoft Corporation. All rights reserved.

-out:testcase.exe

testcase.obj

c:\>testcase.exe

Error value for 0.1: 0.112463

Error value for 10.0: 2.088488e-045

0 Kudos
Scheibe__Patrick
New Contributor I
612 Views
Hi Om,
I tried this already before posting here. The problem is that I include about 20 header files into one sourcefile since I'm having mostly template code.
I used math.h in many of the others and therefore I get:
# error " is incompatible with system !"

Any ideas to that? Otherwise I would write an approximation since I don't need a very fast/accurate version of the function.
Cheers
Patrick
0 Kudos
Om_S_Intel
Employee
612 Views

This function in not in in Microsoft Visual studio compiler. You may use mathimf.h in place of math.h. You can also use it using #ifdef. If Intel compiler is in use use mathimf.helse use math.h.

0 Kudos
Scheibe__Patrick
New Contributor I
612 Views
Yes, I noticed that. Usually I'm developing under Linux and I only compile my stuff for collegues for Windows from time to time.
I thought there is maybe a better solution that replacing all math.h includes with some ifdefs.
I have an approximation of erf now, which does the job.
Thank you very much for your help.
Cheers
Patrick
0 Kudos
Reply