MCPcopy Create free account
hub / github.com/Derious/cuMPC / approx_exp

Function approx_exp

test/test_CORE/test_exp.cpp:7–19  ·  view source on GitHub ↗

实现近似计算公式

Source from the content-addressed store, hash-verified

5#include <algorithm>
6// 实现近似计算公式
7double approx_exp(double x, int r = 8) {
8 if (x > 0) return 0; // 只处理 x <= 0 的情况
9
10 double base = 1.0 + x / (256);
11 double result = base;
12
13 // 计算2^r次方
14 for (int i = 0; i < r; i++) {
15 result *= result;
16 }
17
18 return result;
19}
20
21double pade_approximation(double x) {
22 if (x > 0) return 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected