arctan是如何实现的? [英] How is arctan implemented?

查看:1488
本文介绍了arctan是如何实现的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有弧函数的许多实现都深入到FPATAN指令。 FPATAN如何实施?假设我们有1位符号,M位尾数和N位指数,那么得到这个数的反正切的算法是什么?应该有这样的算法,因为FPU是这样做的。

解决方案

三角函数确实有很丑陋的实现,有点摆弄。我认为在这里找到能够解释实际使用的算法的人是相当困难的。

这是一个atan2实现: https: //sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/ieee754/dbl-64/e_atan2.c;h=a287ca6656b210c77367eec3c46d72f18476d61d;hb=HEAD



编辑:其实我找到了这个: http:// www。 netlib.org/fdlibm/e_atan2.c ,这很容易理解,但可能会因为那个(?)而变慢。



这在一些电路中,CPU不必做所有这些工作。


Many implementation of the library goes deep down to FPATAN instuction for all arc-functions. How is FPATAN implemented? Assuming that we have 1 bit sign, M bits mantissa and N bits exponent, what is the algorithm to get the arctangent of this number? There should be such algorithm, since the FPU does it.

解决方案

Trigonometric functions do have pretty ugly implementations that are hacky and do lots of bit fiddling. I think it will be pretty hard to find someone here that is able to explain an algorithm that is actually used.

Here is an atan2 implementation: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/ieee754/dbl-64/e_atan2.c;h=a287ca6656b210c77367eec3c46d72f18476d61d;hb=HEAD

Edit: Actually I found this one: http://www.netlib.org/fdlibm/e_atan2.c which is a lot easier to follow, but probably slower because of that (?).

The FPU does all this in some circuits so the CPU doesn't have to do all this work.

这篇关于arctan是如何实现的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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