Sorry that should work:
#ifdef _MSC_VER
#include <direct.h>
#endif
int nlopt_isinf(double x) {
#ifdef HAVE_ISINF
return isinf(x);
#elif defined(_MSC_VER)
return _finite(x)==0;
#else
return fabs(x) >= HUGE_VAL * 0.99 ;
#endif
}
On Mon, Jul 2, 2012 at 6:03 PM, Benoit Scherrer <[email protected]>wrote:
> Hi,
>
> I'm using nlopt in a project, using the BOBYQA optimization.
>
> I did a runtime profiling of my code with Visual Studio (so under Windows)
> and
> surprisingly one of the bottlenecks (after my objective function) was
> nlopt_isinf
> (see screenshots)
>
> A fix might be :
>
> #ifdef MSVC
> #include <direct.h>
> #endif
>
> int nlopt_isinf(double x) {
> #ifdef HAVE_ISINF
> return isinf(x);
> #elif MSVC
> return _finite(x)==0;
> #else
> return fabs(x) >= HUGE_VAL * 0.99 ;
> #endif
> }
>
>
> I Don't know if _finite exists for all WIN32 or only MSVC
>
> B
>
>
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss