exp

Fast Exp calculation: possible to improve accuracy without losing too much performance?

给你一囗甜甜゛ 提交于 2019-11-27 04:19:16
问题 I am trying out the fast Exp(x) function that previously was described in this answer to an SO question on improving calculation speed in C#: public static double Exp(double x) { var tmp = (long)(1512775 * x + 1072632447); return BitConverter.Int64BitsToDouble(tmp << 32); } The expression is using some IEEE floating point "tricks" and is primarily intended for use in neural sets. The function is approximately 5 times faster than the regular Math.Exp(x) function. Unfortunately, the numeric

Why does my Visual C++ .exe project build create .lib and .exp files?

时光毁灭记忆、已成空白 提交于 2019-11-26 23:15:23
问题 I have a solution consisting of 3 projects. One is a static library, and two are console-based .exe files that depend on and link against this library. Their settings seem to be identical. I build one of them: 1>------ Build started: Project: masksample, Configuration: Debug Win32 ------ 1>Compiling... 1>stdafx.cpp 1>Compiling... 1>masksample.cpp 1>Compiling manifest to resources... 1>Linking... 1>LINK : C:\Users\DarekSz\Praca\cci\Debug\masksample.exe not found or not built by the last

Deal with overflow in exp using numpy

本秂侑毒 提交于 2019-11-26 11:12:59
问题 Using numpy, I have this definition of a function: def powellBadlyScaled(X): f1 = 10**4 * X[0] * X[1] - 1 f2 = numpy.exp(-numpy.float(X[0])) + numpy.exp(-numpy.float(X[1])) - 1.0001 return f1 + f2 This function is evaluated a huge number of times on an optimization routine. It often raises exception: RuntimeWarning: overflow encountered in exp I understand that operand cannot be stored in allocated space for a float. But how can I overcome the problem? 回答1: You can use the bigfloat package.