在哪里可以找到标准的数学函数的算法? [英] Where to find algorithms for standard math functions?

查看:150
本文介绍了在哪里可以找到标准的数学函数的算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找提交补丁的D编程语言标准库,让很多std.math在编译时使用的语言的编译时功能评价设施进行评估。编译时功能评价有若干限制,最重要的是:

I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation has several limitations, the most important ones being:

  1. 您不能使用汇编语言。
  2. 您不能调用C code或code,对于它的来源是,否则无法使用。

若干std.math功能违反了这些和编译时的版本需要写。我在哪里可以得到良好的算法的信息来计算的东西,如对数,指数,权力和三角函数?我preFER算法只是高层次的描述与实际code,有两个原因:

Several std.math functions violate these and compile-time versions need to be written. Where can I get information on good algorithms for computing things such as logarithms, exponents, powers, and trig functions? I prefer just high level descriptions of algorithms to actual code, for two reasons:

  1. 要避免法律的模糊和需要让我的code样子够了不同的,从源头上确保我拥有版权。

  1. To avoid legal ambiguity and the need to make my code look "different enough" from the source to make sure I own the copyright.

我想简单,便携的算法。我不关心微的优化,只要他们至少渐近有效的。

I want simple, portable algorithms. I don't care about micro-optimization as long as they're at least asymptotically efficient.

编辑:D的编译时功能评价模型允许浮动计算在编译的时候从那些在运行时计算反正不同点的结果,所以我不介意我的编译时的算法不给完全相同的结果作为运行时的版本,只要它们不是不准确至实际上显著程度

D's compile time function evaluation model allows floating point results computed at compile time to differ from those computed at runtime anyhow, so I don't care if my compile-time algorithms don't give exactly the same result as the runtime version as long as they aren't less accurate to a practically significant extent.

推荐答案

约翰·哈特的电脑逼近的1968年由John Wiley和儿子。

John Hart Computer Approximations 1968 by John Wiley & Sons.

的计算理想情况下应该匹配precisely什么,他们会做,如果在运行时。这可能会非常棘手。对于许多功能,不进行连续快速收敛在全域,因此algoritms贴在一起的各种方法。

The calculations ideally should match precisely what they would if done at runtime. That can be tricky. For many functions, no series converges quickly over the full domain, so algoritms paste together various methods.

另外,有各种各样的浮点格式。大多数平台(我认为)现在使用IEEE 754.当我写了一个编译器长约1985年,我不得不面对跨平台的浮点格式。这是非常乏味的得到它的权利,因为你的点点拼凑的数字加在一起位,是确保你得到precisely,将被计算在目标机器上的价值。我不知道,如果你要面对这一切。

Also, there are various floating point formats. Most platforms (I think) now use IEEE 754. When I wrote a compiler ca. 1985, I had to deal with cross-platform floating point formats. It was very tedious to get it right, because you have to piece the numbers together bit by bit, being sure that you get precisely the value that would be calculated on the target machine. I don't know if you have to deal with that.

这篇关于在哪里可以找到标准的数学函数的算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆