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

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

问题描述

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

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.

推荐答案

三角函数确实有非常丑陋的实现,它们很hacky并且做了大量的摆弄.我认为在这里很难找到能够解释实际使用的算法的人.

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.

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

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

实际上我找到了这个:http://www.netlib.org/fdlibm/e_atan2.c 更容易理解,但可能会因此而变慢(?).

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 (?).

FPU 在某些电路中完成所有这些工作,因此 CPU 不必完成所有这些工作.

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

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

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