English 中文(简体)
快速数学算法牺牲准确性
原标题:Faster math algorithm sacrificing accuracy

我正在开发一种游戏,把如此众多的数学功能用于物理学和制造。 ,在Quke3中使用的“Fast inverse sqrt”,其背景是美丽的。

你们是否知道任何比通常更快、准确损失的其他算法?

最佳回答

这些算法在文献中称为“近似算法”。 http://www.amazon.com/s?search-alias=stripbooks&field-isbn=3540653678“rel=“nofollow noreferer”>Approximation Algorithms by Vijay V. Vazirani

sinx ~ x 的情况是一个特例,略为笼统: 查阅

另一种(一些残酷的)技术是随机地将你的一些职能集中起来,然后对你进行直线的倒退。 这样,你就能够很好地描述你的职能,而且:

问题回答

任何连续职能(包括最常见的数学业务)都可能与多功能的交际相当。 这与普通数学功能通常符合的相对简单特性(如补充法)和桌旁观一起,为建立快速近似算法的标准技术(以及像系统数学图书馆所使用的高准确性方法的基础)提供了依据。

但是,泰勒系列通常是一个不好的选择;Chebyshev或微型聚合物在大多数计算用途方面有更好的错误特征。 小型聚合物的标准技术是使用Remes Algorithm,该软件以多种商业数学软件实施,或者如果你知道你会做些什么,你可以开展日常工作。

对于记录,应当避免在现代处理器上出现“最深层的根基”,因为使用浮点对等地估算指令(rsqrts/>/>>>上载SSE、vrsqrte上的“近地天体N”,vrsqrtefp<>。 即便是目前英特尔处理器的(非近似)硬件根基也相当快。

小型X:in(x) ~= x 是常用于物理学的一种

Niko有一些很好的建议,我补充说,老的时装表。

I ve多次在高效实时精度方面成功地利用了循环功能(sin/cos/tan)一览表。 泥土的这种方式更为困难,但如果你的投入范围受到限制(如 screen板),那么它就难以为速度打上标语,而且你可以确切地调整空间/精密贸易。 你们也可以利用寻找共同的范围,然后就少有的情况而言,框架附带作用。

Paul

从Doom源代码来看,大约距离2个D点之间,无需使用泥土或三元测量功能:

fixed_t P_AproxDistance(fixed_t dx, fixed_t dy )
{
    dx = abs(dx);
    dy = abs(dy);
    if (dx < dy)
        return dx+dy-(dx>>1);
    else
        return dx+dy-(dy>>1);
}

注:x >> 1x / 2相同,但较快的是,良好的现代汇编者现在自动这样做,但后来又如此大。

任何令人兴奋的倾向通常都是如此。 进行模拟的10次速度将加快,但结果比模拟的1 000次少。





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...